CSC 141 / QUIZ 3 / UNGRADED PRACTICE

A little practice before Tuesday.

Eleven short questions to help you prepare for Quiz 3. Predict first, choose an answer, then read the explanation.

Quiz: Tuesday, October 27, 2026, 11:00–11:15 AM.
Classes 14–16. Nine multiple-choice questions on loops and strings.

These are different questions from the graded quiz. Practice as often as you like. No name, student ID, or submission is required; this page does not record a grade.

Course home · Quiz 2 practice

What to review

For each snippet, trace the loop one pass at a time with a small table and write the exact output before checking it. The quiz will not ask you to write a complete program.

01 What does this program print?
n = 1
while n < 10:
    print(n)
    n = n * 3
02 What values does range(1, 10, 4) produce?
03 What values does range(5, 0, -2) produce?
04 What does this program print?
total = 0
for n in range(1, 4):
    total += n
print(total)
05 What does this program print?
for n in range(1, 4):
    total = 0
    total += n
print(total)
06 count_evens(6) should return 3. What does this version return?
def count_evens(n):
    count = 0
    for k in range(1, n):
        if k % 2 == 0:
            count += 1
    return count
07 Why does this loop never end?
count = 0
while count < 3:
    print("hi")
08 What does this program print?
s = "banana"
print(s[0] + s[-1])
09 What is the value of "banana"[1:4]?
10 What happens when this program runs?
s = "banana"
s[0] = "B"
print(s)
11 What does this program print?
count = 0
for ch in "queue":
    if ch in "aeiou":
        count += 1
print(count)