What is python function?

Description

To see what is python function, syntax
and example.

Definition of function.
      • Function blocks begin with the keyword
        def.
      • Followed by the function name and
        parentheses ().
      • The code block within every function
        starts with a  colon (:) and is
        indented.
      • Any input parameters or arguments
        should be placed  within these
        parentheses.

Syntax.

    • We can also define parameters
      inside these  parentheses.
    • def functionname( arguments ):

Code block

  • Return statement

Function call statement.

  • To call the function by passing
    the arguments to the  function.
  • We can also call a function
    using 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