0

I don't understand thus question. Can anyone help me?

num = 7 if num > 3 print("3") if num < 5 print("5") if num == 7 print("7") answer: 3 I don't understand it. Shouldn't it be 3 and 7, since the first and third one is true? Somebody help me!

24th Feb 2017, 10:32 AM
Darren Ong
Darren Ong - avatar
3 Respuestas
+ 2
num==7 will be checked only if num<5 condition is true (because it is Inside this loop) so 3 is output.
24th Feb 2017, 11:00 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
+ 1
No, 3 is correct due to indentation the following if statements belong to the previous if statement. So num == 7 isn't reached.
24th Feb 2017, 10:43 AM
ChaoticDawg
ChaoticDawg - avatar
0
oh ok thanks a lot!!
24th Feb 2017, 10:48 AM
Darren Ong
Darren Ong - avatar