πŸ” Loops

🎯 Learning Targets

AP Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.

Do Now (in p5)

In p5, draw as many circles as you can in the next 3 minutes.

Loopy

Drawing a bunch of circles is terrible. Let’s not do that.

function draw() is a loop. What if we wanted to write our own?

Let’s go to NYU:

4.1 p5.js: while and for loop from shiffman on Vimeo.

while loops

Work like a conditional:

if (something True){
    // do this code
} else {
    // do this code
}
while(something True){
    // run this code over and over again
}