return statement is used to pass back the value from the function that is called and executed. We can say that the return statement is end of the function. Any statements beyond the return statement are not executed.
Let us see an example below:
def sum(c,d):
e = c+d
return e
print("This is function")
a = 10
b = 10
print(sum(a,b))
In the above program, sum function has return statement which is returning e value. return is treated as end of the function by interpreter and any statements beyond return are not executed. Any statements written beyond main are allowed but they shall be ignored by the Python interpreter.
0 Comments