Repeating code

In this chapter we will learn about "loops", where programs can go back, iterate, and continue learning. It's one of the most important pieces of the programming puzzles!

There are many computers in a car, including one that shows the speed on the dashboard. But it's not just a once, it has to repeatedly check how fast the wheels are moving, figure out what that means for speed, and display it. And it should not stop until the car is turned off. The only way to do this is by using loops.

When you watch video on YouTube, it is not a still image, but several images one after the other, up to 60 different ones per second. These are received over the internet and drawn one at a time in a loop. Part of the loop is also waiting a few extra milliseconds (thousandths of a second, it's a long time in the computer world) for the images to come in at the right rate. Otherwise, the video would fast forward.