+ 2

What is the deifference between return and print statement in python?

7th Aug 2019, 3:43 AM
Akaash Tripathi
Akaash Tripathi - avatar
2 Answers
+ 3
You can use return value as assignments, but you can't use print as assignments. For example, we now have 2 functions, printSquare() and returnSquare(), you can see the difference by their names. #print the square of 10 print(returnSquare(10)) printSquare(10) #Assign a variable to the square of 10 Carrie = returnSquare(10) #You can't use printSquare() to assign a variable.
7th Aug 2019, 4:19 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
+ 1
return doesn't output anything on the screen, it just transports a value out of a function to the place where it was called.
7th Aug 2019, 7:38 AM
HonFu
HonFu - avatar