O'Reilly logo

Teach Your Kids to Code by Bryson Payne

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

Chapter 4. Loops Are Fun (You Can Say That Again)

We’ve used loops since our very first program to draw repeating shapes. Now it’s time to learn how to build our own loops from scratch. Whenever we need to do something over and over again in a program, loops allow us to repeat those steps without having to type each one separately. Figure 4-1 shows a visual example—a rosette made up of four circles.

A four-circle rosette pattern

Figure 4-1. A four-circle rosette pattern

Let’s think about how we might write a program to draw four circles overlapping as shown. As you saw in Chapter 2, Turtle’s circle() command draws a circle with the radius we specify inside its parentheses. Those ...

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