- 1

What is the output of this code? spam = 7 if spam > 5: print("five") if spam > 8: print("eight")

why is it five?

5th Dec 2016, 3:49 AM
Jose Sagastizado
Jose Sagastizado - avatar
9 ответов
+ 2
It should be five, since the first statement evaluates to true and the second to false
21st Jul 2020, 11:07 AM
Goke Ekundayo
Goke Ekundayo - avatar
+ 1
Huh
5th Dec 2016, 4:08 AM
Keto Z
Keto Z - avatar
+ 1
5
12th Jun 2022, 2:51 PM
Ash Ketchum
0
Because spam (here declared 7) is greater than 5, first if loop evaluates to true and executes the print statement second if statement is false and hence the print statement is skipped.
5th Dec 2016, 3:46 PM
shailesh
shailesh - avatar
0
oh OK thx
5th Dec 2016, 7:54 PM
Jose Sagastizado
Jose Sagastizado - avatar
0
five
17th Dec 2016, 12:11 AM
jann carlos lopez
0
its 5
9th Oct 2019, 10:12 AM
Tanbeer
0
5
26th Jan 2023, 7:43 AM
kangana Desani
kangana Desani - avatar
- 1
5
7th Dec 2016, 6:40 AM
Dmitry Borisovich Ilin
Dmitry Borisovich Ilin - avatar