In this video you will learn about how to return value from function in python.
Return value from function
Python allows us to return value from a function after performing the desired operation. The value is returned using return keyword. Whenever return statement is executed the value and control both transferred back from function definition to the function call. Consider the following example:
def get_sum(a,b,c):
d=a+b+c
return d
x=get_sum(10,20,30)
print(x)
In the above example, when we call function get_sum(10,20,30) then the control is transferred to the function call, the argument 10,20,30 are stored into a,b,c respectively. The sum of a,b,c is stored into d, and at last the value of d is returned using return keyword. The returned value is stored into x, that is printed using print().
Note: If we do not return anything from a function then by default functions returns None in python. None is a special value in python, which means nothing.
def an_example():
pass
x=an_example()
print(x)#None
Notice that when we do not want to do anything in the function then we use pass keyword in the definition.
#python_by_tarun_sir #tarun_sir #python #tarun_sir_python #python_video_48 #return_value_from_function_in_python #python_tutorial #when_None_is_returned_in_python