0

Can any one explain return statement in python

I am a beginner im totally confused what return satement will do..., Can anyone explain detailly the difference between print and return statement... 🙏

17th Jun 2020, 8:05 AM
E Ragul
E Ragul - avatar
2 Answers
+ 2
Print is for make text go to screen Return is for functions like def pwr(x, y) : return x**y Num=pwr(2,3) Now num will be equal to 8 because return is for returning value to the calling statement
17th Jun 2020, 8:19 AM
ycsvenom
ycsvenom - avatar
+ 4
Function is a block of code, that can be ran by calling its name. When you call a function it returns (evaluates) a value to the position the function was called. For a function to return a value it's code block needs to contain an accessible return statement, which is basically just a return keyword followed by the value you want to return. def f(): return "tomato" var = f() print(var) #tomato
17th Jun 2020, 8:15 AM
Seb TheS
Seb TheS - avatar