What keyword starts a loop that iterates over each item in a sequence in Python?
for
What built-in Python function is commonly used to generate a sequence of numbers for a for loop?
range()
In the guided practice example, what function is used to get user input (typed by the user) and convert it to an integer?
input() and int() — e.g., int(input("Enter a number: "))
In a for loop, what Python syntax indicates the start of the block of statements to repeat?
a colon (:) and indentation to start the block
What does range(5) produce as the sequence of integers (write them in order)?
0,1,2,3,40,1,2,3,4
The independent practice asks to create lists odd_numbers and even_numbers from 0 to 20. Which numbers (0, 1, 2, ...) should go into even_numbers? Give the first four even numbers from that range
Even numbers: 0, 2, 4, 6 (first four from 0 to 20
Write the general form (using variable names) of a Python for loop that iterates over a sequence named seq. (Answer should be one line.)
for item in seq:
How do you use range() to produce the numbers 2, 4, 6, 8? Write the exact range() call
range(2,9,2) or range(2,9,2)range(2,9,2) produces 2,4,6,8 (or more directly range(2,9,2)range(2,9,2)) — note: alternative range(2,9,2)range(2,9,2) uses stop 9 so 8 is last
The sample solution uses for i in range(2,21,2) for even numbers. What is the role of the 21 in that call?
21 is the stop value (one past the last number to include 20).
Explain in one short sentence why using a for loop is better than writing the same code multiple times
It avoids repetition and reduces errors by running the same statements for each item automatically
What are the three arguments of range(start, stop, step)? Describe what each one does in one phrase
Write a short program (4–6 lines) that creates an empty list called numbers, uses a for loop with range(5) to prompt the user to enter five integers, appends them, then prints the list. (Use the same style as the guided practice.)
Example: numbers = []
for i in range(5):
numbers.append(int(input("Enter a number: ")))
print(numbers)
Given a list called fruits = ["apple", "banana", "cherry"], what will this loop print?
for fruit in fruits:
print(fruit.upper())
APPLE
BANANA
CHERRY
Predict the list produced by list(range(1, 10, 3)). (Write the numbers in order.)
[1,4,7]
Master challenge: Describe (in 2–3 sentences) how you would modify the program that separates odd and even numbers so that it also counts how many odd numbers and how many even numbers there are, and then prints those counts after printing the lists.
print("Even count:", len(even_numbers)) and print("Odd count:", len(odd_numbers)).