Hi, everyone! I'm a bit busy this week so lesson notes are gonna be briefer. Reach out for more detailed explanations if you need them, though.
Class Problems/Homework - Questions 6-7 (7 is hard, if it's too hard wait until the solutions come out on Saturday night or ask for help)
range() is a built-in function in Python that creates a list in increasing order based off of three parameters: start, stop, and skip. By default, start is 0, and skip is 1. Start is the number you want the list to start from. Stop is the number that the list will stop right before reaching it. Skip is the interval you want the list to increase by (it can be negative for decreasing order).
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
^Why does the number I give for the stop parameter never included in the list? Count the numbers in that list. Since in programming we use 0 to refer to the first item in a list, starting from 0 and counting to 9 creates the 10 item list that you requested. Using range(num) creates a list of len() = num.
NESTED FOR LOOPS (not covered in class yet, read only if you want)
Nested for loops are loops inside loops. Each iteration of the outside loop will make its nested loop run completely each time.
for i in range(10):
for j in range(10):
^ In this example, "hello" will be printed 100 times.
^ Also, the variables you initialize to iterate through nested loops can't be the same. Across separate loops it's fine. But nested loops are connected and the program will get confused if you use duplicate variable names.
That's all, folks. See ya
-Bonnie (and Alan)