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.
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 ...
Get Teach Your Kids to Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.