Return Function in Python | Tutorial 23 | Python tutorial | Python in Urdu | Hindi | Ali Code

Veröffentlicht am: 07 September 2023
auf dem Kanal: Ali Code
80
2

#learnpython #pythontutorial #pythoninurdu #pythoninhindi #alicode
Return Function in Python | Python for Beginners | Python in Urdu | Python in Hindi | Ali Code

Python – Return Function from Function

The return statement in Python is used to exit a function and return a value. You can use the return statement to make your functions send Python objects back to the caller code. These objects are known as the function’s return value. You can use them to perform further computation in your programs.

Here is an example of how to use the return statement in Python:

def my_function():
return "Hello World!"

print(my_function())
Copy
This will output:

Hello World!
Copy
You can also return multiple values from a function using tuples. Here is an example:

def my_function():
return 1, 2, 3

a, b, c = my_function()

print(a)
print(b)
print(c)
Copy
This will output:

1
2
3

Function name with parenthesis calls the function, while the function name without parenthesis returns the reference to the function.

Now, let us understand how execution happens for this program. Following is a step by step execution flow of the above program.

Define function1().
Define function2().
Call function1().
function2 reference is returned from function1. Observe that function2 is mentioned without parenthesis. We are returning the function reference, not calling it.
Assign the returned function reference to x.
x() calls the function assigned to x.
Execute print() statement inside function2().


   • Python Project | Tutorial 21 | Student Sch...  

   • Python Print Statement in Hindi | Tutorial...  


Auf dieser Seite können Sie das Online-Video Return Function in Python | Tutorial 23 | Python tutorial | Python in Urdu | Hindi | Ali Code mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Ali Code 07 September 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 80 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!