Dictionaries · Program Purpose

Read — build a mental model L2 Comprehension Macro Structure ~3 min

What is this dictionary program for?

What overall problem is this program solving? Avoid describing only the syntax.

counts = {}
for word in ["red", "blue", "red", "green", "red"]:
    if word in counts:
        counts[word] = counts[word] + 1
    else:
        counts[word] = 1
print(counts)

Choose one

Why this activity was chosen
  • Bloom level: L2 Comprehension: Name the problem the fragment is solving.
  • Block Model level: Macro Structure (step 4 of 4): the purpose of the whole program: the problem it solves and the goal it serves.
  • Misconception targeted: shown after you answer, so it does not give the answer away.

Students often describe syntax ('it uses a for loop') instead of purpose ('it finds the largest value'). Purpose items separate mechanism from intention — a distinction needed when judging AI-generated code that may be locally plausible but globally wrong.

AI’s role here: AI may contrast a syntactic description with a purpose description after the attempt. It must not tell the student the purpose first.