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

Publié le: 07 septembre 2023
sur la chaîne: 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...  


Sur cette page du site, vous pouvez voir la vidéo en ligne Return Function in Python | Tutorial 23 | Python tutorial | Python in Urdu | Hindi | Ali Code durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Ali Code 07 septembre 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 80 fois et il a aimé 2 téléspectateurs. Bon visionnage!