Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Break | While Loops: Essentials
Python Loops
course content

Зміст курсу

Python Loops

Python Loops

1. While Loops: Get Started
2. While Loops: Essentials
3. For Loops
4. Nested Loops

Break

break is a special command to leave the loop at any moment. It can be used either inside general finite loops or infinite loops with constantly True conditions, like while True:.

123456789
a = 96 while True: if a < 101: a += 1 elif a > 101: a -= 1 else: print('a reached 101') break
copy

This loop could be infinite, but we're lucky to have the break after a becomes equal to 101. After that, loop is over and next lines of code are executing.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 3
toggle bottom row

Break

break is a special command to leave the loop at any moment. It can be used either inside general finite loops or infinite loops with constantly True conditions, like while True:.

123456789
a = 96 while True: if a < 101: a += 1 elif a > 101: a -= 1 else: print('a reached 101') break
copy

This loop could be infinite, but we're lucky to have the break after a becomes equal to 101. After that, loop is over and next lines of code are executing.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 3
toggle bottom row

Break

break is a special command to leave the loop at any moment. It can be used either inside general finite loops or infinite loops with constantly True conditions, like while True:.

123456789
a = 96 while True: if a < 101: a += 1 elif a > 101: a -= 1 else: print('a reached 101') break
copy

This loop could be infinite, but we're lucky to have the break after a becomes equal to 101. After that, loop is over and next lines of code are executing.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

break is a special command to leave the loop at any moment. It can be used either inside general finite loops or infinite loops with constantly True conditions, like while True:.

123456789
a = 96 while True: if a < 101: a += 1 elif a > 101: a -= 1 else: print('a reached 101') break
copy

This loop could be infinite, but we're lucky to have the break after a becomes equal to 101. After that, loop is over and next lines of code are executing.

Завдання

Simulate the game. For the current number of user's points increment it by 5 if it is even number, or decrease by 3 if it is odd number. The game is over when value of points reaches 17. If it happened, print the message The game is over and leave the loop.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 3
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt