O'Reilly logo

Python Projects for Kids by Jessica Ingrassellino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loops

Loops are a kind of control flow, but they rerun the same block of code over and over again until something else tells the loop to stop repeating itself. This is a bit different from conditional statements since these only run the block of code once. The two kinds of loop are while and for. Both types of loop are really useful.

while

while is one kind of loop. When we make a while loop, the program repeats itself until a given block of code happens. When programming a while loop, we need to create some rules, or our program will run forever.

For example, we can make this rule: when the calculator is on, perform the following steps:

  1. Run the calculator.
  2. Prompt the user to keep calculating.
  3. When the user hits the else statement, turn the calculator ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required