+ 1
If statement problem
nun=7 if num <7, print (â3â) if num <5, print (â5â) if num ==7, print (â7â) why the answer is 3? Does it not 5?
5 RĂ©ponses
+ 5
Arvonce
In response to your second question:
num = 7
if num >3: #true
print('3') # 3 is printed
elif ..... etc # progam is not looking at these lines of code because it has already returned a true statement.
Remember:
if returns a result if true
elif means that if the IF statement is not true, then is this statement true.
else returns a result if no true options exist, or if false.
+ 7
num = 7
if num < 7:
print("3")
elif num < 5:
print("5")
elif num == 7:
print("7")
please do revise the if else concepts and your question is not clear enough.
+ 3
đđđ Sweet
+ 1
Thanks Rik, I got it now
0
num = 7
if num > 3:
print("3")
elif num < 5:
print("5")
elif num == 7:
print("7")
what is the output? I did the tutour if statement, the practice question, which gave a answer 3 I cant understand, why is 3