+ 1

why the output is not 7?

What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7")

17th Feb 2019, 11:59 AM
Dee Pan Kar
Dee Pan Kar - avatar
3 Answers
+ 9
It checks if num > 3. It is, so it prints "3" and then goes further. It checks if num < 5. It is *not*, so it does not go any deeper in the code block. Since it is the last instruction, the program ends with only "3" being printed out.
17th Feb 2019, 12:05 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
37
19th Feb 2019, 3:03 PM
Adil Hussain
Adil Hussain - avatar
19th Feb 2019, 3:13 PM
Adil Hussain
Adil Hussain - avatar