+ 2

I am not understanding why this code given below should have '3' as the solution. This is the code though

num = 7 if num > 3: print("3") if num>5: print("5") if num == 7: print("7") This question also occured in one of the quizzes and it would be great help if anyone coud explain me this. Thanks :)

23rd Sep 2020, 12:09 PM
Fantasybeing8
Fantasybeing8 - avatar
2 Answers
+ 9
Is that so! You will get '3' '5' '7' has the output since all the conditions will result true. Error in the line 6th line it isn't intended
23rd Sep 2020, 12:22 PM
chaithra Gowda
chaithra Gowda - avatar
+ 3
7>3,prints 3 Then 7>5,prints 5 Then 7==7,prints 7
23rd Sep 2020, 12:22 PM
Abhay
Abhay - avatar