how to define a function in python

As per the latest trends set python is the most exploring programming language,expert says in the middle of 21st century 70% of the day life application will be depend on python programming language, python and artificial intelligence definitely will brings miracle in the middle of 21st century.So being a programmer without python programming language you cant survive in 21st century.Like other programming language function in python is also so basically our question is how to define a function in python.To define a function in python programming language, python has its on syntax. lets see the syntax

   return [EXPRESSION]

def            => Function blocks begin with this keyword def 
FUNCTION-NAME  => Name of the function you can define your own name

PARAMETER      => It the Parameter passing to the function when function was called

FUNCTION_BLOCK => Function code block

EXPRESSION     =>  return [EXPRESSION] passing back an expression to the caller

See example

def sum(a,b):
 resultvalue = a+b
 return resultvalue

x =10
y = 40
x =60
y = 40

how to define a function in python

def printPrime(lower,upper):
 print( "prime numbers between "+str(lower)+ ", "+str(upper))
 for num in range(lower,upper + 1):
    if num > 1:
       for i in range(2,num):
           if (num % i) == 0:

x =10
y = 20
x =1180
y = 1200

how to define a prime number display function in python

1 thought on “how to define a function in python”

Leave a Reply

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