+ 2
Def Function
1)def cube(num): return num*num*num cube(3) Output: No output. 2)def cube(num): print(num*num*num) print(cube(3)) Output: 27 None Can somebody pls explain why the output is like that? Thx
5 Antworten
+ 3
Hey M.O.HONOR
In Your Query,
Case 1: You returning the value but you won’t assigned any variable to hold that value or even you won’t used print() function so that the return value can be consoled to your screen whereas in Case2: the return value can be consoled to screen because you used print() function which will show the value of your function as ouput to the console screen.
+ 4
M.O.HONOR
print function is used to display output on the screen...
In 1st case you only pass the argument and return the value and doesn't use print function to display it
In 2nd case you use print function that is visible in output....
+ 2
Thank you Indira and Ryan
+ 1
Glad To Help 😊