CBSE Class 11 Computer Science Question 41 of 80

Conditional and Looping Constructs — Question 11

Back to all questions
11
Question

Question 7(v)

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.