return Statement

 
we write a return statement in a function to leave a function and give the calculated value when a defined function is called.

Syntax:

return < expression to be returned as output >  

An argument, a statement, or a value can be used in the return statement, which is given as output when a specific task or function is completed. If we do not write a return statement, then None object is returned by a defined function.

Code:

# Python code to demonstrate the use of return statements  
  
# Defining a function with return statement  
def square( num ):  
    return num**2  
   
# Calling function and passing arguments.  
print( "With return statement" )  
print( square( 39 ) )  
  
# Defining a function without return statement   
def square( num ):  
     num**2   
  
# Calling function and passing arguments.  
print( "Without return statement" )  
print( square( 39 ) )  


Output:

With return statement
1521
Without return statement
None