CBSE Class 11 Informatics Practices Question 50 of 75

Conditional and Looping Constructs — Question 22

Back to all questions
22
Question

Question 7(e)

Write the output of the following:

for x in range (10, 20):
   if (x == 15):
      break
   print(x)
Answer
Output
10
11
12
13
14
Explanation

The code starts a for loop where x iterates over the range from 10 to 19. Within each iteration, it checks if x is equal to 15. If true, the break statement exits the loop. Therefore, the loop prints numbers from 10 to 14, each on a new line.