+ 1

Can any one help me in understanding the statement "def" in python functions through codes?

11th Jul 2019, 7:14 AM
KEERTHANA PEDDAPYATA
KEERTHANA PEDDAPYATA - avatar
4 odpowiedzi
+ 3
Def tells the interpreter that you are making a function. A function is a block of code that you can reuse Syntax is as follows def [function name]([parameters]): [Indented block of code] For example def Add(num1, num2): return num1 + num2 The functions can be as complicated as neccecary. A couple codes: https://code.sololearn.com/cHQsyXd20yw9/?ref=app https://code.sololearn.com/caacxummGwBc/?ref=app https://code.sololearn.com/c02u2z9mGS99/?ref=app https://code.sololearn.com/cHTf0Kdc03uv/?ref=app https://code.sololearn.com/cLcbNLvxL1zG/?ref=app https://code.sololearn.com/cR5vZ2Im19DB/?ref=app https://code.sololearn.com/c1feUTu5uV2c/?ref=app https://code.sololearn.com/cr2bE8cvDCSN/?ref=app
11th Jul 2019, 7:54 AM
Trigger
Trigger - avatar
+ 2
def is used as a keyword to tell the program that we are defining a function. def func_name(): Means that we are declaring a function named func_name, with no parameters. And the next code block will belong to the function. def func_name(): print("This statement belongs to func_name") print("This statement also belongs to func_name") print("This statement does not belong to func_name")
11th Jul 2019, 9:28 AM
Seb TheS
Seb TheS - avatar
+ 1
>>> "def" is "define" True def function_name(): #work 😊
11th Jul 2019, 7:53 AM
Ayan Fox
Ayan Fox - avatar
0
Def == define It is a keyword to say to the computer, hey! You got a function here!
11th Jul 2019, 7:19 AM
Drax
Drax - avatar