What is python function?

Description

To see what is python function, syntax and example.

Definition of function
      • Function blocks begin with the keyworddef.
      • Followed by the function name andparentheses ().
      • The code block within every functionstarts with a colon (:) and isindented.
      • Any input parameters or argumentsshould be placed within theseparentheses.
Syntax.
    • We can also define parametersinside these parentheses.
    • def functionname( arguments ):
Code block
  • Return statement
Function call statement.
  • To call the function by passingthe arguments to the function.
  • We can also call a functionusing by pass referen

#python function
def sum(a,b):
c=a+b
if(a==b):
print(c+2)
else:
print(c)
print(“****First execution*****”)

#calling the function
sum(5,6)

#calling by reference
input1=5
input2=5
print(“****Second execution*****”)
sum(input1,input2)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit