Skip to main content

Section 16.17 Mixed Review

Bring multiple CS1 concepts together in this review activity.

Subsection 16.17.1 Part A: Code Dissubsection

Checkpoint 16.17.1.

def count_long_words(words):
    total = 0
    for word in words:
        if len(word) > 4:
            total = total + 1
    return total

items = ["book", "banana", "pen", "laptop"]
result = count_long_words(items)
print(result)
Identify the function name, parameter, return type, loop used, condition checked, and output.

Subsection 16.17.2 Part B: Trace

Checkpoint 16.17.2.

Complete a trace table for the program above with columns for iteration, word, whether len(word) > 4, and total.

Subsection 16.17.3 Part C: Fix

Checkpoint 16.17.3.

The code below is meant to count how many even numbers are in a list, but it has errors. Correct it.

Subsection 16.17.4 Part D: Create

Checkpoint 16.17.4.

Write a function named count_a_words(words) that takes a list of strings and returns how many words start with the letter a. Then write three test calls.

Subsection 16.17.5 Think About ...

Checkpoint 16.17.5.

Which topic in this section felt strongest for you? Which one needs more review?
You have attempted of activities on this page.