Python functions | Sololearn: Learn to code for FREE!

+1

Python functions

def count(): does the above syntax make sense?

4/29/2019 6:46:59 AM

Uthpala

16 Answers

New Answer

+4

Uthpala Function attributes and function arguments are two different things. function attributes def fun(): pass fun.__doc__ or fun_doc fun.__dict__ or fun_dict etc.. function arguments def fun(a,b): // a, b are arguments pass But yes you can have function with no arguments and no values for attributes (__doc__ string or __dict__ remains empty)

+1

Uthpala I think i have already mentioned that ! anyways fun.__doc__ is an attribute def fun: "" This function prints "hello" """ print("hello") print(fun.__doc__) // prints - this function prints hello Do note the intendation of doc string for more info see https://www.python.org/dev/peps/pep-0232/ function arguments you already know

+1

Function are so much easier to get arguments and different things

0

@swim .....yes please

0

got it thank you so much

0

Uthpala ๐Ÿ‘๐Ÿ™‚

0

0

bruh this useless no cool no pog

0

0

Yes this is function it's call whenever you need without arguments.

-1

No, there must be some code after the function is defined.

-1

@swim, can you please explain attributes and arguments in detail? in def fun(a,b) a and b are arguments....which are attributes???

-2

Uthpala No, but this does def fun(): pass or def fun(): pass As it is a function with empty body

-2

@aymane and @swim, sorry for not describing my question, can we have no attributes in function? is my question

-2

Yes you can, def count(): pass Is a function that does nothing, no attributes or arguments are required.

-2

It will be easier to understand attributes after studying classes, don't rush it. However,if you still want to just ask again.