While and For Loops
Loops allow programs to do the same piece over and over again with slight changes until they want it to stop. When making a loop you want to answer 3 questions:
What do you want to repeat? What do you want to change each time? How long should we repeat?
A while loop seems very similar to an if statement, with a boolean expressions and a piece of code that it runs if true. They are similar but a while loop has a special condition that means it jumps back to the top of the loop each time it reaches the end to check if the boolean statement is still true. If it is still true it runs the loop again, if it isn't it carries on. For loops are similar to While loops on the surface, the main difference is that all of the conditions of the loop are inside the initial perens "()." For loops can also be "nested" inside other for loops. This allows you to loop two (or more) sets of conditions. For example, you could repeat an image, shape or string in both the x and y axis to make a grid (see below.) Project: Build a House.
![A table of programming for While and For Loops.](https://static.wixstatic.com/media/b86045_6f660791f5944981b4436dfdb38de322~mv2.png/v1/fill/w_602,h_888,al_c,q_90,enc_auto/b86045_6f660791f5944981b4436dfdb38de322~mv2.png)