Big Idea 1.4 | Python Errors (Quick Lesson + Quiz)

2 min read

Python Errors: The Three Types

AP CSP Big Idea 1.4 - Identifying and Correcting Errors

Type What happens Example
Syntax Code won’t run at all Missing : or )
Runtime Code runs, then crashes IndexError, ZeroDivisionError
Logic Code runs, answer is wrong Returns evens when you wanted odds

Debugging tips: read the traceback bottom-up, print suspicious variables, and test with known answers.

10-Question Quiz

Pick the best answer for each. Run the cell at the bottom to score yourself.

1. Which error type stops a program from running at all?

  • A) Logic
  • B) Runtime
  • C) Syntax
  • D) Overflow

2. A program runs but prints the wrong answer. What kind of error?

  • A) Syntax
  • B) Logic
  • C) Runtime
  • D) None

3. print("hi" (missing closing parenthesis) is what kind of error?

  • A) Logic
  • B) Runtime
  • C) Syntax
  • D) Overflow

4. Dividing by zero in Python raises which kind of error?

  • A) Syntax
  • B) Runtime
  • C) Logic
  • D) None

5. A list has 26 items. Accessing myList[26] causes a:

  • A) Syntax error
  • B) Logic error
  • C) Runtime error (IndexError)
  • D) No error

6. When reading a Python traceback, you should usually start from:

  • A) The top
  • B) The bottom
  • C) The middle
  • D) It doesn’t matter

7. Which is the BEST first step to debug a logic error?

  • A) Delete the code
  • B) Print variables to see actual values
  • C) Restart the computer
  • D) Ignore it

8. Every Python for and if header must end with a:

  • A) Semicolon ;
  • B) Colon :
  • C) Period .
  • D) Comma ,

9. Which loop correctly visits every index of a 26-item list?

  • A) while i <= 26:
  • B) while i < 26:
  • C) while i > 26:
  • D) while i == 26:

10. A test case is useful because it:

  • A) Makes the code shorter
  • B) Confirms code returns expected output for a known input
  • C) Removes all errors automatically
  • D) Replaces the need to read code
# Type your answers as letters (A, B, C, or D)
answers = {
    1: "",
    2: "",
    3: "",
    4: "",
    5: "",
    6: "",
    7: "",
    8: "",
    9: "",
    10: "",
}

key = {1:"C", 2:"B", 3:"C", 4:"B", 5:"C", 6:"B", 7:"B", 8:"B", 9:"B", 10:"B"}

score = 0
for q, correct in key.items():
    if answers[q].strip().upper() == correct:
        score += 1
    else:
        print(f"Q{q}: your answer '{answers[q]}' — correct is {correct}")

print(f"\nScore: {score}/10")

Course Timeline