AP CSP Topic 1.4 Guided Notes - Identifying and Correcting Errors
Big Idea 1: Creative Development · Topic 1.4 · Guided Notes (Student)
Identifying and Correcting Errors — Guided Notes
Fill these in during class or catch up here if you were absent. Print this page or work on paper — then check yourself with the CFUs on the Topic 1.4 page.
Print these notesTopic 1.4 lesson pageAll CSP topics
Day 1: It Ran Perfectly. It's Still Wrong.
Today’s objectives
- Identify an error in an algorithm or program and classify it as a logic, syntax, run-time, or overflow error (LO CRD-2.I)
- Correct errors by choosing from the five effective ways: test cases, hand tracing, visualizations, debuggers, and extra output statements (LO CRD-2.I)
Bell ringer
A pancake recipe has been sabotaged. Step 1: Stir flour, milk, and two eggs into a smooth batter. Step 2: Wozzle the batter frimly until it grebbles. Step 3: Divide the batter evenly among zero bowls. Step 4: Add 2 cups of salt so the pancakes taste sweet. Step 5: Cook three minutes per side and serve.
Three steps are broken — find all three, and write HOW each fails differently: one can't be understood, one can't be carried out, and one 'works' but ruins breakfast.
01. The Four Error Types
Key Vocabulary (LO CRD-2.I)
| Term | Definition (write it) |
|---|---|
| Logic error | |
| Syntax error | |
| Run-time error | |
| Overflow error | |
| Hand tracing |
Four Failures, Four Fingerprints
- A logic error still .
- A syntax error breaks .
- A run-time error occurs .
Watch out — “If It Runs, It's Correct”
Myth: A program that runs from start to finish without a single error message has no errors in it.
Explain why this is wrong:
Name That Error
Five bug reports from student projects. Classify each one using the four CED error types.
Complete the empty cells.
| Bug report | What execution looked like | Error type |
|---|---|---|
| The statement "score <- score +" is missing its second operand | The language cannot understand the statement; the program never starts | |
| A trip-cost app runs "each <- cost / people" and a user enters 0 people | The program halts with an error message in the middle of execution | |
| A gradebook averages three quizzes with "avg <- (q1 + q2 + q3) / 2" | Runs cleanly every time; every printed average is higher than it should be | |
| A step counter's daily total passes the largest value its storage allows | The computer attempts to handle a number outside the defined range | |
| A password checker approves some incorrect passwords | Runs cleanly for every input; the accept/reject behavior is wrong |
Stop and think
- A weather app crashes the moment a user taps 'refresh' while the phone is offline. A teammate calls it a logic error. Correct the classification if needed, and defend your answer in one sentence.
- Explain how a program can be completely free of syntax errors and still be wrong. Name the error type that survives a clean, message-free run.
- A scoreboard suddenly shows 0 right after a team's score passes the largest value the program can store. Which error type is this, and what makes it different from a logic error?
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 1.4 page.
02. Five Ways to Find and Fix
The CED's Five-Tool Debugging Kit
Watch the values
Probe the behavior
- The CED's five ways to find and correct errors are test cases, hand tracing, visualizations, debuggers, and .
- A test case pairs a defined input with .
- Hand tracing means .
AP TIP: If a question asks how to FIND an error, the answer comes from this list of five — memorize them as a set.
Deep Dive · Beyond the AP Exam
Deep Dive: Inside a Debugger
- A breakpoint makes the debugger .
- A debugger is essentially hand tracing .
Stop and think
- A program's final answer is wrong but nothing ever crashes. Which two of the five ways would you reach for first, and what would each one reveal?
- A teammate keeps pasting extra output statements into 300 lines of code to hunt one bug. Name the tool from the five that does the same job without editing the program, and give one advantage it has.
- Write one complete test case for a program that converts total minutes into hours-and-minutes form: give the defined input AND the exact expected output.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 1.4 page.
Today in one box
- Four error types, four fingerprints: logic (runs, behaves incorrectly), syntax (language rules broken, never runs), run-time (fails during execution), overflow (number outside the defined range)
- Logic errors are the silent ones — a clean, message-free run proves nothing
- Five ways to find and correct errors: test cases, hand tracing, visualizations, debuggers, extra output statements
- Overflow's fixed-bit machinery is waiting for you in Topic 2.1
Before next class: A grade calculator works perfectly for 85, 92, and 74 — ship it? Tomorrow: the three numbers that break it.
Day 2: The Three Numbers That Break It
Today’s objectives
- Identify inputs and their corresponding expected outputs or behaviors that can be used to check the correctness of a program (LO CRD-2.J)
- Choose test inputs at and just beyond the extremes — the minimum and maximum — that the program requirements define (LO CRD-2.J)
Bell ringer
Yesterday's teaser: a grade calculator averages three scores and prints a letter grade. Its requirements say each score is a whole number from 0 to 100. It works perfectly for 85, 92, and 74.
Write the three test scores you would type to try to BREAK this program — and for each one, what a correctly built program should do with it. Why those three numbers, and not, say, 60?
01. Testing with Defined Inputs
Key Vocabulary (LO CRD-2.J)
| Term | Definition (write it) |
|---|---|
| Test case | |
| Extremes | |
| Program requirements |
Testing Is a Loop, Not a Victory Lap
- Testing uses defined inputs to ensure that a program is producing .
- Programmers use the results from testing to .
- Before running a test case, you must already know .
Test AT the Extremes — and JUST BEYOND
At the extremes
Just beyond the extremes
- Boundary testing targets the edges of the allowed range — meaning .
- Strong test inputs demonstrate expected outcomes at or .
- For an input just beyond the range, the expected behavior comes from .
AP TIP: 'At or just beyond the extremes' is CED wording. Middle-of-the-range inputs make weak tests — the exam expects boundary picks.
Watch out — “Normal Values Make Good Tests”
Myth: Testing means running the program on a few typical, middle-of-the-range inputs — if 85, 92, and 74 all work, the program works.
Explain why this is wrong:
Reading Requirements, Choosing Inputs
For each requirement, choose test inputs at the extremes and just beyond them — and say why. The requirements decide what 'expected' means.
Complete the empty cells.
| Requirement | At the extremes | Just beyond | Why these inputs |
|---|---|---|---|
| Quiz scores: whole numbers 0–100 | 0 and 100 | -1 and 101 | Legal boundaries must produce real grades; out-of-range must be rejected, not averaged |
| Movie rating: 1–5 stars | One-step-outside inputs expose a form that accepts any number and corrupts the average | ||
| Password length: 8–16 characters | 8-character and 16-character passwords | The extreme is the LENGTH — the requirement defines what property gets measured | |
| ATM withdrawal: $20–$500 | 19 and 501 |
Stop and think
- A ticket site's requirements: orders of 1 to 8 tickets. List the four boundary inputs you would test and the expected behavior for each one.
- A program passed tests at 85, 92, and 74, then crashed on 0 the day it launched. Using yesterday's vocabulary, classify the crash; using today's, name the testing habit that would have caught it early.
- A countdown app accepts a number of days from 1 to 365. A tester adds the input 366 and a teammate objects that 366 'isn't a real input, so testing it is a waste.' Settle the argument, citing what defined test inputs are supposed to demonstrate.
- Why can't you write a single correct test case for a program whose requirements were never written down? Answer in one sentence that uses the word 'expected.'
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 1.4 page.
Common AP Traps
Three ways Topic 1.4 loses points on the exam — one minute now, real points in May.
Logic vs. run-time — in your own words:
Overflow is an error type here — in your own words:
Test just beyond the extremes — in your own words:
Identifying and Correcting Errors, in One Slide
- Four error types: logic (runs, behaves incorrectly), syntax (language rules broken, never runs), run-time (fails during execution), overflow (number outside the defined range).
- Five ways to find and correct errors: test cases, hand tracing, visualizations, debuggers, adding extra output statements.
- Testing runs defined inputs against expected outcomes — and the results drive revision.
- The strongest test inputs sit at or just beyond the extremes: the minimum and the maximum.
- Program requirements are needed to identify appropriate defined inputs — they decide what 'expected' even means.
Exit check — I can…
- ☐ classify a failure as logic, syntax, run-time, or overflow (LO CRD-2.I)
- ☐ name the five ways to find and correct an error (LO CRD-2.I)
- ☐ choose test inputs at and just beyond the extremes (LO CRD-2.J)
- ☐ use program requirements to decide what to test (LO CRD-2.J)
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]