Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
94
34
450
50.3K
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr Answer: 1 Solution: We have num=75, and then an if-elif ladder. We meet the first if-condition. Is num<= 50? No. So we must skip that block and see the next elif condition. Is num<=75? Yes! So this block is run. Printed 1. Now, do we have to check any more elifs? +
English
1
1
8
1.8K
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr No. Once an if or elif condition is satisfied and it's block executed... python breaks out of the if-elif ladder. So the further elif conditions are not checked, there is no chance of executing any of their blocks. Think of it as checking conditions till you find a true +
English
1
0
1
100
Paylaş