Question #355

What is the output of the code snippet below?
number = 28
for num in range(25, 30):
    if number > num:

Here, the Python control reaches line 4 three times and line 6 one time. During the iteration of the for loop in line 2, when values of num are 25, 26 and 27 (i.e. values smaller than 28), the control is reaching line 4 and when num is 28, it is reaching line 6 before breaking out from the loop. (

Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵