0
Def in python
Guys what does def mean and what does it do? Aside elif
4 Answers
+ 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")
+ 2
Well appreciated
+ 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.
+ 1
Calvin Thomas well said... Thanks