If statements | SoloLearn: Learn to code for FREE!

0

If statements

num=7 If num>3: Print(“3”) If num <5: Print(“5”) If num ==7: Print(“7”) Answerr >>> 3 Why not >>> 3 7

9/30/2018 2:56:36 PM

fente

5 Answers

New Answer

+5

If the first condition is True, the first indented code block is executed, so "3" is printed and the second condition is evaluated. Since the second condition is False, the second indented code block is not executed, so "5" is not printed and the third condition is not evaluated so "7" is never printed. btw make sure you don't capitalize "if" and "print" 😉

+3

Because of the indentation, 3rd if is part of 2nd if. And both depend on 1st. This would give you 3 and 7. num = 7 if num > 3: print(“3”) if num < 5: print(“5”) if num == 7: print(“7”)

+2

fente post your code here.

0

it writes 3 because it is first

0

I did not write code