 Now that we've introduced loops, we can write another traditional simple program called fizzbuzz. The fizzbuzz program simply prints all of the integers from 1 to 100, except instead of any integer evenly divisible by 3, the program prints fizz, and except for any integer evenly divisible by 5, it prints buzz. And then for any integer evenly divisible by both 3 and 5, the program prints fizzbuzz. To start, we know we're going to be printing a range of numbers from 1 up to 100. So first we're going to want a loop in which a variable starts with a value 1, it gets incremented each iteration until, in the last iteration, it has the value 100. So here the variable x is given the initial value 1, and then the loop tests whether or not x is less than or equal to 100, and so every time this condition tests true, the body of the while loop will execute for another iteration. At the end of the body, we increment the value of x. We take the current value of x, add 1, and then assign the result to x itself. So what we have here is a loop which in the first iteration, x has the value 1, in the second iteration, x has the value 2, in the third iteration, x has the value 3, and so forth until in the last iteration, x will have the value 100, which then will get incremented to 101, and so the condition will then test false because 101 is not less than or equal to 100. Now in each iteration of the loop, we're going to need to determine whether the value of x is equally divisible by 3, and whether it is equally divisible by 5. When a number is equally divisible by 3, the modulus of that number by 3 will be 0, so we do mod x3 and test whether that is equal to 0. That will assign true or false to the variable by 3. And then we do the same for 5, taking the modulus of x by 5, testing whether the result is equal to 0, and assigning the true or false value to by 5. Based upon these two variables, we then need to decide which thing to print among four mutually exclusive cases. When both by 3 and by 5 are true, that means that x is evenly divisible by both 3 and 5, so we print fizzbuzz. In the case where x is divisible by 3 but not by 5, we print fizz, and in the case where x is divisible by 5 but not by 3, we print buzz. Lastly, in the case where x is not divisible by either 3 or 5, we print the value of x itself. So that's the entirety of the fizzbuzz program. It prints all the numbers from 1 to 100, except when the number is evenly divisible by 3 and 5, it prints fizzbuzz instead, and when the number is evenly divisible by just 3, it prints fizz, and when the number is evenly divisible by just 5, it prints buzz. A very important thing to note here is that the ordering of the mutually exclusive cases matters in this example. Given how we wrote our conditions, our second and third cases test true when the first case tests true, because of course when both by 3 and by 5 are true at the same time, by 3 and by 5 are true individually. So if we reorder these cases, we can get the wrong behavior. For example, if we put the case of just by 3 is true first, then we'd print fizz when we're supposed to print fizzbuzz, because the just by 3 case would test true when both by 3 and by 5 are true. Likewise, if we put the case of just by 5 is true before the case of by 3 and by 5, then we'd print buzz when we're supposed to print fizzbuzz. One way to think about this is that our case conditions have been partly left implicit by their order. In an if statement with elif clauses, the condition of the elif clauses implicitly require that all previous conditions test false. So in our original ordering, when we put the condition of by 3 and by 5 first, the second condition by 3 implicitly requires that the condition by 3 and by 5 tested false. If we wanted to keep the same logic, but write these clauses in reverse order, we'd have to change the condition from just by 3 to by 3 and not by 5. So the lesson is when writing your mutually exclusive cases, be sure to either fully state the conditions or simply be cognizant of what's being left implied in their order.