Class - 12 CBSE Computer Science Important Output Questions 2025
Write the output of the following:
for x in range(10, 20):
if (x == 15):
break
print(x)
Python
Python Control Flow
4 Likes
Answer
15
Working
The code sets up a for loop that iterates over a range of numbers from 10 to 19. During each iteration, the variable x takes on these values sequentially. Within the loop, an if statement checks if x is equal to 15. When x reaches 15, the condition is met, and the break statement is executed, immediately exiting the loop. As a result, the loop terminates prematurely, and the value of x at the point of exit, which is 15, is printed.
Answered By
2 Likes