KnowledgeBoat Logo
|

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