Conditionals · Code Improvement

Shape — improve or specify L5 Synthesis Macro Structure ~5 min

Tidy the repeated tests

An AI generated this grading function. It gives the right answer, but it keeps re-testing conditions it already knows. Refactor it so the logic is clearer without changing what it returns. You may write code or describe the changes in words.

def grade(mark):
    if mark >= 70:
        return "A"
    if mark < 70:
        if mark >= 60:
            return "B"
    if mark < 60:
        return "C"
Why this activity was chosen
  • Bloom level: L5 Synthesis: Improve a working but weak generated solution.
  • 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.

Synthesis here means revising an existing artefact: names, structure, edge cases. Students start from AI-like output so the task is judgement plus rewriting, not blank-page authorship.

AI’s role here: AI may later comment on the student's revision. It must not hand back a fully rewritten program as the student's answer.