I don't understand thus question. Can anyone help me? | SoloLearn: Learn to code for FREE!

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!

2/24/2017 10:32:41 AM

Darren Ong

3 Answers

New Answer

+2

num==7 will be checked only if num<5 condition is true (because it is Inside this loop) so 3 is output.

+1

No, 3 is correct due to indentation the following if statements belong to the previous if statement. So num == 7 isn't reached.

0

oh ok thanks a lot!!