0
Wrong answer?
So I came across this question and it states the answer is 3. Wouldn't it be 3 and 7? Is question was found on if statements. Question 3/3. ---- What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") ----
4 Réponses
+ 3
Effoffwillyageez The point is that "if num == 7" is more indented than "if num < 5". The condition num < 5 is false, so it won't even check if num == 7. Everything that is on the same indentation level as "if num < 5" (or even further indented) won't be executed because the initial condition num < 5 is false. Anything after line 4 won't be executed.
+ 1
the answer is 3 because the condition was met on the first if statement and the next nested was false. so it stopped
0
Oh. So if the condition is met before the rest of the code inside the nest is executed then it doesn't need to execute the rest?
0
python compiler executes line by line so output will be 3 when first condition faiks then it jumps to next one hope you are cleared