0

Def in python

Guys what does def mean and what does it do? Aside elif

24th Jul 2021, 5:33 AM
Wisdak
Wisdak - avatar
4 Antworten
+ 5
def is used to define function and function is used to execute a particular task. #function definition def function_name(): #logic ---------- And elif is a conditional statement which is used to decide if any case "if" condition get failed then "elif" condition will execute based on the condition passed with "elif". #if elif conditional statements if 1 < 2: print ("1 is less than 2") elif 2 < 3: print ("2 is less than 3")
24th Jul 2021, 5:37 AM
A͢J
A͢J - avatar
+ 2
Well appreciated
24th Jul 2021, 5:39 AM
Wisdak
Wisdak - avatar
+ 1
KwaByte What the 'def' keyword actually does is to create a new function object in the heap and store its reference in the variable specified after it. When the byte-code compiler finds a pair of parentheses just before a function reference, the code is transformed in such a way that the function object in the heap is called. I hope that this helps.
24th Jul 2021, 6:52 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Calvin Thomas well said... Thanks
24th Jul 2021, 7:02 AM
Wisdak
Wisdak - avatar