Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 18
Tahir Usman due to the evaluation order It must evaluate the innermost execution before moving on to the next one Take this code for instace def foo(x): return x + 1 def bar(x): return x * 2 print(bar(foo(20))) As you can see, the "bar" function takes the return value of "foo" so it has to be evaluated first "foo" takes the value 20 and return 21 which is then passed to the "bar" function which in turn returns 42 which is outputted by "print"
19th Apr 2019, 9:06 PM
Burey
Burey - avatar
+ 30
Yes same doubt here can any one explain it
21st May 2019, 1:55 PM
Rapt[#Demure]
Rapt[#Demure] - avatar
+ 15
The print function does not have a return value So going thru the evaluation order the inner most print call print("Hello") is executed and outputs "Hello" Each other print call will output the value which retuned from the call of print which is None you can test yourself to see what a function with no return value prints def foo(): x = 42 # doesn't matter what the function does, as long as it doesn't return anything print(foo()) output: None
19th Apr 2019, 8:54 PM
Burey
Burey - avatar
+ 7
Just print() function returns None
19th Apr 2019, 9:22 PM
‎ ‎
‎          ‎ - avatar
+ 7
Muhammad Reshma i've explained it here See my previous answer to this post
21st May 2019, 2:55 PM
Burey
Burey - avatar
+ 6
Burey bro, why it doesn't print none none none hello?
19th Apr 2019, 9:00 PM
Tahir Usman
Tahir Usman - avatar
+ 5
19th Apr 2019, 9:51 PM
Burey
Burey - avatar
+ 3
Print expects a string, which is only true for the innermost one?
19th Apr 2019, 8:49 PM
::sк::
::sк:: - avatar
+ 2
"print( )" is actually a function, and it prints the statements inside the paratheneses, known as arguments. The innermost print prints "Hello". But the next print does not have any string argument, and the value is absent. Absence of a value in python 3 is declared by "None". As the other prints don't have string arguments, they print None.
21st Apr 2019, 7:06 AM
Kushaal Kumar Pothula
Kushaal Kumar Pothula - avatar
0
Salut
20th Apr 2019, 9:06 AM
Ameth Ba
Ameth Ba - avatar
0
F
21st Apr 2019, 2:32 PM
Дмитрий Бойко
Дмитрий Бойко - avatar
0
Mnv
21st Apr 2019, 4:28 PM
Muktar Beg
0
Print ("hello to the world") RUN hello to the world
21st Apr 2019, 9:27 PM
danavel odonkor
danavel odonkor - avatar