Hi, welcome to this new video. So, now that we understand Boolean logic, we also understand conditional statements, we can start thinking that conditionals could be a way of iterating through the data, right? There's a particular kind of loop, or a form of iteration that uses conditionals as a mode of continuing executing something. And that is the while loop, right? So let's look at the structure and the syntax of the while loop. The while loop says, while a certain condition, in this case a Boolean statement, is true, right? Then we have a block of code that would be executed, and it will be executed infinitely while that condition is true. So in many ways, while loops are considered dangerous because they have the possibility of locking the program into an infinite loop, right? And that's something that you want to avoid. That's something that would crash your computer. So if you can avoid a while statement, especially when you're starting, it makes sense to do so. But you'll realize that there's some circumstances in which a while statement or a while loop is actually very useful because you don't know how many times you need to iterate over the data, right? You might need to iterate until certain task is finished. And in those cases, a while loop is a really good way to go, right? So let's look at the syntax a bit further. Let's imagine that we have a variable called count, and that count starts at 1, right? So we could say while that count is smaller or equal than 5, right? Let's say print that count, right? And if we would end up there, that statement would run forever. But in that same code block, we would add a condition, or basically a part of the code that would change the value of our count variable to a plus equal one. Meaning add one to whatever value you have. So we would go from one to two to two to three, and eventually we would reach a condition that when we evaluate the while, basically the Boolean statement is count smaller or equal than five, that would result to be false, right? We would go out of the loop, and the loop will finish. So it's, in this case, a clean way to determine when are you in the loop and when you're out. Perhaps you use it when you're really kind of finished evaluating the data that you have, or you've completed a task and you can move on, right? So let's write an example using some design principles and some ideas of design that would use this while loop. So here we are back in processing. So what I would like to do, I've created a black background as we have been doing. Let's just create an x variable of = 600. What we're going to try to do here is a series of concentric circles, all of them with these different random colors. And we will gradually see how we could actually loop in a way that it's not nondeterministic, meaning that we could even include certain randomness to the amount of iterations that we take, right? So let's start by saying while x is bigger than 5, right? So we're starting with an x that is 600. Is x bigger than five? That's true. We will do an ellipse that uses the coordinate 600, 300, x, x. So x is going to be our radius, the radius of the ellipse. And if we would run this code, don't run this code right now, because it would actually crash. We would run infinitely, right? As we discussed. So let's just add a statement that says x- =, which is a way of saying subtract to your value. Let's start with something like maybe 50, right? So we start with 600, we subtract 50, we're in 550, and we keep going down at a rate of 50 every time until we get below 5 or below 0, if you want to put a 0, that's totally fine. But until we reach this condition, right? So let's make sure that our ellipse has, maybe it's going to be white for now. So let's do fill 255, and also stroke of black. Otherwise we wouldn't see anything that is going on, right? Let's see what we get. So we have this ellipse that is drawn here. We actually start drawing the biggest one. We know that 600 is the size, the height of our canvas. So that is the first ellipse. And then on top of that, we draw a slightly smaller one, which is 50 pixels smaller as we're using that x within the radius, right? So that's all fine, but let's just play a little bit and do some variations. So, of course, if we do this value smaller, that means that we're going to do more loops, right? You could get kind of a closer iteration. You can do even tighter, right? As you can see, you can get the number of iterations is changing, right? But what if we would use something like random, right? Let's import the random module here all the way to the top. Import random, right? And here we could say x- = random.randrange between 1 and 20. So sometimes we want to decrease the amount of x by 1, I'm going to always keep at least a 1 here because I would like to get closer and closer to getting out of the loop, right? So sometimes 1, sometimes 20 or maybe even 30, right? If we want to just do less versions of that loop. And what you could see here, because we're doing this in the draw loop, right? We're drawing a slightly different sequence every time. That might be a little bit difficult on the eye. So we're going to just maybe remove this draw loop right now and let's just do one sequence of that, only one version of this drawing. As you can see here, this is not looping at the same rate. We don't know exactly how many times we're going to loop, but we're going to eventually get out of that loop, right? So we're actually achieving a very specific kind of effect here that maybe is more interesting, right? Let's play with this idea a little bit further and use, when I create a few variables here, I'm going to use an r representing red, and I'm going to do a random.range between 0 and 255. I really like seeing how some designs look with some color variation. So I'm going to repeat this three times. You're going to see me do this throughout the series, which is using certain randoms for RGB. And now here we can do r, g, b. So the field will be a random color, right? And you can see that this composition is using random colors. Every time that we run, it will be different. It would be different in the gaps of the circle. Maybe you want to include even something bigger, like 60, right? So sometimes the gaps are going to be thicker, sometimes they're going to be smaller. And we're using random colors, right? If you would like to increase the circle size. So, like your first ellipse being larger, right? So maybe it includes, oops, not so big, maybe extends outside the realm of the screen or gets clipped here. You can certainly increase that. Our loop will always move downwards until it kind of gets below five. So again, you can try something kind of much larger that it would actually cover the entirety of the screen, right? So here we go. And again, this is all randomly colored. Every time that we run this, we're going to get a different composition. So as you can see, there's a lot of creative ways in which you can use this kind of while loop, especially when you don't know exactly the number of times that you might need to perform an iteration. So very useful. And I'll see you in the next video where we'll continue looking at different statements for design.