Students, Day 9 focuses on iterating over lists with loops—no more manual ranges if not needed! First, initialize a list: numbers = [1, 2, 3, 4, 5]—comma-separated items in brackets. This creates a list of integers.
Write a program that defines a list of numbers from 1 to 5, then uses a for loop to print each number and its square. (Concepts: for loops with lists, list initialization)
Example
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num, "squared is", num ** 2)The for loop: for num in numbers:—this goes through each item in the list one by one, assigning it to num temporarily. No need for range() here; it's direct. Inside the indented block, print(num, "squared is", num ** 2)—** is exponentiation for squaring. It auto-adds spaces between arguments in print().
Run: Prints "1 squared is 1", "2 squared is 4", up to 5. Simple! In 10-15 min, change the list to strings (e.g., names) and loop to print lengths (len(num)). This shows loops aren't just for numbers—great for processing data sets. You're automating repetition over collections now!

Key Concepts:
- For Loop (with lists): Iterates over each element in a list, assigning it to a variable (e.g., for item in my_list:) to perform actions on each.
- List Initialization: Creating a list by directly assigning values inside square brackets (e.g., [value1, value2]).
- Exponentiation Operator (**): Raises a number to a power (e.g., 2 ** 3 = 8).
