Informatics Practices
Write the output of the following:
for x in range (10, 20):
if (x == 15):
break
print(x)
Python Control Flow
3 Likes
Answer
10
11
12
13
14
Working
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.
Answered By
1 Like
Related Questions
Write the output of the following:
for j in range (10,6,-2) : print (j*2)Write the output of the following:
for x in range (1, 6) : for y in range (1, x+1): print (x, ' ', y)Write the output of the following:
for x in range (10, 20): if (x % 2 == 0): continue print (x)Write the output of the following program on execution if x = 50:
if x > 10: if x > 25: print ( 'ok' ) if x > 60: print ( 'good' ) elif x > 40: print ( 'average' ) else: print ('no output')