6. For Loops Quiz

6.1. Question 1

What is the main purpose of using a “for loop” in a Python program?

Correct. For loops let you step through items or repeat code cleanly.

Incorrect. For loops guide the path of your code rather than shutting down power.

Incorrect. Loops repeat instructions instead of converting variable data types.

Incorrect. Checking inputs uses selection structures like if statements.


6.2. Question 2

When looping through a string text variable like “Welcome” using a for loop, what does the loop look at during each step?

Incorrect. A for loop breaks the sequence down rather than processing it in one block.

Correct. The loop steps through the string letter by letter, from left to right.

Incorrect. The loop continues until it has checked every single character in the sequence.

Incorrect. It processes every active character inside the string variable.


6.3. Question 3

Look at this line of code: for character in "Hello": What is the purpose of the word character in this statement?

Incorrect. This is a variable name chosen by the programmer.

Incorrect. Clearing the screen requires calling display.clear().

Correct. Each time the loop repeats, the next letter in the string is placed inside this variable.

Incorrect. It manages code execution loop states instead of display font layouts.


6.4. Question 4

If a for loop is set up to step through the string variable text “winner”, how many total times will the code block inside the loop repeat?

Incorrect. It repeats once for every single letter in the word.

Incorrect. Count the number of characters in the sequence carefully.

Correct. The word “winner” contains exactly 6 letters, so the loop executes its inner code block 6 times.

Incorrect. A for loop stops automatically once it reaches the end of the sequence.


6.5. Question 5

Look at this loop statement: for digit in "2023": What value will be stored inside the variable digit during the very first step of the loop?

Correct. Loops process sequences from start to finish, so it grabs the first character on the left first.

Incorrect. This is the second character in the sequence layout.

Incorrect. This is the final character at the end of the sequence.

Incorrect. The loop isolates individual elements rather than duplicating the entire string.


6.6. Question 6

What punctuation mark must always be placed at the very end of a for loop setup header line in Python?

Incorrect. Python headers do not use standard sentence periods.

Incorrect. Question marks are not valid syntax markers in Python structure definitions.

Correct. A colon tells Python that an indented block of instructions is starting right below it.

Incorrect. Semicolons are not used to open loop blocks.


6.7. Question 7

How does Python know which lines of code belong inside your loop block and should be repeated?

Incorrect. Quotes identify text string variables, not code structures.

Correct. Consistent indentation groups blocks of code together in Python.

Incorrect. Capitals are used for constants.

Incorrect. They must be indented, not just placed below the header.


6.8. Question 8

Suppose you have a list containing exactly 4 names. If you loop through that list sequence using a for loop, how many total times will the instructions inside your loop block execute?

Incorrect. A for loop repeats for every individual element in the sequence, not just the first one.

Incorrect. The loop stops automatically once it reaches the end of the 4 items.

Correct. The loop runs exactly once for each item in the collection sequence, resulting in 4 iterations.

Incorrect. Unlike a while True statement, a for loop terminates naturally when the sequence is exhausted.


6.9. Question 9

A student creates a list of items called tools containing 3 elements. They write a for item in tools: loop header. What value is placed inside the temporary variable item during the final run of the loop?

Incorrect. The loop breaks the sequence down to process individual values step by step.

Incorrect. The first item is processed during the initial iteration on step one.

Correct. Python processes sequential structures from left to right, meaning the final item is assigned on the last iteration.

Incorrect. The loop tracking variable copies the actual data item from the list.


6.10. Question 10

A student creates two sequences: a list of colors (Red, Green) and a list of shapes (Circle, Star). They write the following nested loops:

for color_item in colors:
    for shape_item in shapes:
        display.scroll(color_item + " " + shape_item)

How many total combined pairs (lines of text) will be scrolled when this code runs?

Incorrect. The outer loop runs 2 times, and for each of those steps, the inner loop must complete its full cycle.

Incorrect. You must multiply the number of items in the first list by the number of items in the second list.

Correct. The outer loop runs 2 times, and for each step, the inner loop runs 2 times (2 multiplied by 2 equals 4 total loop combinations: Red Circle, Red Star, Green Circle, Green Star).

Incorrect. Both lists contain active elements, so the inner scroll instruction executes completely.