What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: pr | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: pr

19th Jan 2017, 2:01 PM
Basim Ali
Basim Ali - avatar
13 Answers
+ 6
I guess some of you have thought that the answer would be 3 and 7 but it is only 3, because this if num < 5: print("5") code isn't True, the loop won't continue with further indented statements! which means once a false statement is between the 2 true statements the code will not go further to check if there are more true statements.
3rd Mar 2022, 2:09 PM
Harod Geremew
Harod Geremew - avatar
+ 1
The output is 3, since '7' is not equal to 7
11th Jan 2020, 2:52 AM
Erick Diaz
Erick Diaz - avatar
+ 1
3 is correct answer
27th Feb 2021, 5:54 AM
v manojbabu
v manojbabu - avatar
0
the answer is 3 bruh
29th Jan 2020, 10:29 AM
Femzi
Femzi - avatar
0
I guess the answer's 3 cause; since this >>>if num < 5: print("5")<<< portion isn't True, the loop won't continue with further indented statements!
24th Jul 2020, 6:55 PM
Faisal Al Rashid
Faisal Al Rashid - avatar
0
3 is the correct anwser
3rd Mar 2021, 3:56 PM
Victor
0
The answer = 3
29th Mar 2021, 9:12 PM
Ben Jnr
Ben Jnr - avatar
0
why is 3?
28th Apr 2021, 9:33 AM
Daniela
0
3 if statements returns a value for true statements else no further computation of the code.
23rd Jun 2021, 8:45 PM
Terer Gideon
Terer Gideon - avatar
0
3
27th Aug 2021, 1:12 PM
PRINCE KUMAR
PRINCE KUMAR - avatar
0
3
6th Dec 2021, 10:41 PM
Vesnelda Obiri
Vesnelda Obiri - avatar
0
3
9th Nov 2022, 5:18 AM
kinzang namgay
kinzang namgay - avatar
- 2
the output is 3 and 7.
3rd Feb 2017, 5:44 AM
Ruslan Ovcharenko
Ruslan Ovcharenko - avatar