Control Structures
Normally, lines of code run in order, but you can change the way the computer moves through your code. This section will focus on conditional statements (if/elif/else) and loops (for and while)
Conditional Statements
If
If-Else
If-Elif-Else
Loops
Loops cause code to run repeatedly
While Loops
While loops run code as long as the condition described in the logical test is true.
Real World Examples - Breathe. Repeat for the rest of your life. - While you are hungry, eat - While an unauthorized person is in your supervillain lair, fire lasers at them
For Loops
For loops will iterate through a set of items, such as a list of names, a range of numbers, or the contents of a folder.
Real World Examples - Print all the items in a player's inventory (for each item in the inventory, print the item's name) - Give each student in the class a cupcake (for each student, give them a cupcake) -