Python IF condition | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Python IF condition

What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") shouldn't that give 2 outputs? 3 and 7?

5th Nov 2019, 3:29 PM
Adham Khaled
Adham Khaled - avatar
1 Resposta
+ 2
No. Firstly it asks if num > 3 and it is true. Then it asks if num < 5, and it is false. Because the third if is inside the second if, it is not going to run. So, the only output is 3
5th Nov 2019, 3:42 PM
šŸ‡ Alex Tușinean šŸ’œ
šŸ‡ Alex Tușinean šŸ’œ - avatar