Learning to Program in Python for Kids

of all ages and Linux on a Raspberry Pi by Philip M Russell



Whats this used for?

Well occasionally I get lazy and don't want to write or type out things every time. Thats where the loop comes in.

While loops are often used when you are not quite sure how many times you want to do something. I want to say hello Philip until something happens. 
Sometimes this can be just counting using a Counter in this case

What does the counter do

I put something in a box. I take it out of the box add 1 to it and put it back in.

If this is in a loop then each time I do the loop this number will get bigger. If I want to I can count in 2's by making the counter add two each time

Here is the code to copy in 

count =0
while (count <20):
 print ("the counter = ", count);
 count = count + 2;
print ("End of program");