AP CSP Topic 3.3 Guided Notes - Mathematical Expressions

Big Idea 3: Algorithms and Programming · Topic 3.3 · Guided Notes (Student)

Mathematical Expressions — 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 3.3 page.

Print these notesAll CSP topics

Day 1: From Idea to Ordered Steps

Today’s objectives

  • Describe what an algorithm is and express one using natural language, a diagram, or pseudocode, knowing every algorithm is built from sequencing, selection, and iteration (LO AAP-2.A)
  • Represent a step-by-step process as sequential code statements that execute in the order they are written (LO AAP-2.B)
  • Identify the parts of an expression and explain that every expression evaluates to a single value using a defined order of operations (LO AAP-2.B)

Bell ringer

Here are five instructions for figuring a 20% tip and total on a $40 meal, but they are SHUFFLED: (1) DISPLAY the total. (2) Set bill to 40. (3) Set total to bill plus tip. (4) Set tip to bill times 0.2. (5) (there is only one order that actually works.)

Write the four real steps in the ONLY order that produces the right answer. Then, in 2–3 sentences: what went wrong if you tried to compute 'total' before 'tip' existed? What does that tell you about whether the order of steps is part of the instructions or just decoration?

01. Algorithms and Sequencing

Key Vocabulary (LO AAP-2.A)

Term Definition (write it)
Algorithm
Pseudocode
Sequencing
Selection
Iteration

What an Algorithm Is

  • Describing an algorithm as 'finite' guarantees that it .
  • The difference between EXPRESSING an algorithm and IMPLEMENTING it is that implementing requires .
  • Sequencing, selection, and iteration matter because every possible algorithm can be built by .

One Algorithm, Written as Code

The 'cost of 2 adult and 3 child tickets' algorithm, as exam pseudocode and as runnable Python.

AP Pseudocode (what the exam tests)

adultPrice ← 12
childPrice ← 8
total ← adultPrice * 2 + childPrice * 3
DISPLAY(total)

Python (the runnable version)

adultPrice = 12
childPrice = 8
total = adultPrice * 2 + childPrice * 3
print(total)

Output

48

Run and edit this yourself in the coding exercises for this topic.

Express It vs Implement It

Expressing an algorithm

Implementing an algorithm

  • The reason the AP exam uses pseudocode instead of one real language is that pseudocode is .
  • An algorithm has to be IMPLEMENTED in a programming language whenever the goal is to .

AP TIP: On the exam you read and write PSEUDOCODE, never a specific language's syntax — that is exactly why the reference sheet exists.

Stop and think

  1. In your own words, define 'algorithm' and give one everyday (non-computing) example that fits the definition. Explain why it qualifies.
  2. Name the three constructs from which every algorithm can be built, and give a one-line description of each.
  3. A classmate says pseudocode is 'just Python with the semicolons removed.' Correct this: what is pseudocode really for, and why does the AP exam use it instead of a specific language?

Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.3 page.

02. Sequential Code and Expressions

Statements Run in Order; Expressions Make One Value

  • Because sequential statements run in the order written, reordering two dependent steps can .
  • However many operators and parts it contains, an expression is always evaluated down to .
  • Clarity and readability are worth the effort because thoughtful naming and ordering let a reader .

Each Statement Feeds the Next

Three statements, top to bottom; the expression price * quantity evaluates to one value stored in subtotal.

AP Pseudocode (what the exam tests)

price ← 12
quantity ← 3
subtotal ← price * quantity
DISPLAY(subtotal)

Python (the runnable version)

price = 12
quantity = 3
subtotal = price * quantity
print(subtotal)

Output

36

Run and edit this yourself in the coding exercises for this topic.

What Does Each Expression Evaluate To?

An expression is evaluated to ONE value. For each, name what kind of expression it is and the single value it produces. (Assume price = 12, quantity = 3.)

Complete the empty cells.

Expression What it is Evaluates to (one value)
7 a literal value 7
price a variable
price * quantity an operator applied to two values
5 + 2 * 4 operators, with order of operations

Watch out — “The Order of Statements Doesn't Matter”

Myth: As long as all the right statements are present, the order you write them in doesn't matter — the program will sort it out.

Explain why this is wrong:

Stop and think

  1. Explain what 'sequencing' means, then give a two-line example where swapping the order of the statements changes or breaks the result.
  2. For each, state whether it is an expression and, if so, the single value it evaluates to: (a) 9, (b) score (score holds 20), (c) 4 + 3 * 2.
  3. In one or two sentences, explain why clarity and readability are worth the effort even though the computer runs messy, poorly named code just fine.

Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.3 page.

Today in one box

  • An algorithm is a finite set of steps for a specific task; it can be expressed in natural language, diagrams, or pseudocode
  • Every algorithm is built by combining sequencing, selection, and iteration
  • Statements execute in the order they are written; reordering dependent steps changes the result
  • An expression — a value, variable, operator, or returning procedure call — is evaluated to a single value using a set order of operations

Before next class: Before tomorrow, predict it: you and 4 friends order a pizza cut into 17 slices and split them equally. How many WHOLE slices does each person get, and how many are LEFT OVER? Write both numbers — tomorrow you meet the two operators that compute them.

Day 2: Arithmetic and the MOD Operator

Today’s objectives

  • Evaluate expressions using +, -, *, and /, knowing that / gives the exact value, so 17 / 5 evaluates to 3.4 (LO AAP-2.C)
  • Evaluate a MOD b as the remainder when a is divided by b, so 17 MOD 5 evaluates to 2 (LO AAP-2.C)
  • Apply the order of operations to mixed expressions, remembering MOD shares the precedence of * and / (LO AAP-2.C)

Bell ringer

You and 4 friends (5 people total) order a pizza cut into 17 slices and split them as equally as possible. Answer with a partner: How many WHOLE slices does each person get? How many slices are LEFT OVER on the table?

Now write the two arithmetic facts you just used: 17 shared among 5 is 'about ___ each,' and the number left over is ___. Which of those two numbers is a remainder? Keep both — they name today's two key operators.

01. The Arithmetic Operators

Five Operators, and Division Keeps the Decimal

  • Besides add, subtract, and multiply, the fourth familiar AP arithmetic operator is .
  • The surprising behavior of the / operator is that a division like 17 / 5 evaluates to , not a rounded whole number.
  • The / operator keeps the fractional part, so on its own it never the result.

The Four Familiar Operators

Add, subtract, multiply, and divide in exam pseudocode and Python — note 17 / 5 gives 3.4.

AP Pseudocode (what the exam tests)

DISPLAY(8 + 3)
DISPLAY(8 - 3)
DISPLAY(4 * 5)
DISPLAY(17 / 5)

Python (the runnable version)

print(8 + 3)
print(8 - 3)
print(4 * 5)
print(17 / 5)

Output

11 5 20 3.4

Run and edit this yourself in the coding exercises for this topic.

Exact Division vs the 'Integer Division' You Might Expect

AP reference sheet: /

What some languages also offer

  • The single-slash / operator on the AP reference sheet reports a division as .
  • Getting 3 from 17 / 5 is wrong on the AP exam because the reference sheet's division does not .

AP TIP: A single / on the exam always gives the exact value. If a question wants the amount left over, that is MOD — never a rounded division.

Stop and think

  1. Evaluate each to a single value: (a) 9 + 4, (b) 6 * 7, (c) 20 / 8. For (c), explain in one sentence why the answer is not 2.
  2. A student writes that 17 / 5 = 3. Explain what the / operator actually produces and give the correct value.
  3. Name all five arithmetic operators on the AP reference sheet and, in a short phrase, say what each one does.

Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.3 page.

02. MOD and Order of Operations

The MOD Operator and Where It Ranks

  • The value of a MOD b is .
  • For a MOD b to be defined on the exam, a must be an integer that is and b must be greater than 0.
  • When *, /, and MOD appear together with equal precedence, they are evaluated .

The Remainder Operator

MOD returns the remainder; 17 MOD 5 leaves 2. In Python the operator is written %.

AP Pseudocode (what the exam tests)

DISPLAY(17 MOD 5)
DISPLAY(20 MOD 4)
DISPLAY(9 MOD 2)

Python (the runnable version)

print(17 % 5)
print(20 % 4)
print(9 % 2)

Output

2 0 1

Run and edit this yourself in the coding exercises for this topic.

Evaluate with the Order of Operations

Apply the order of operations. Remember MOD ties with * and /, so among those you go left to right. Fill in the single value each expression produces.

Complete the empty cells.

Expression Which operator goes first Evaluates to
3 + 4 * 5 * before + 23
17 MOD 5 + 1 MOD before +
2 * 6 MOD 4 left to right: * then MOD
17 / 5 single operator
(3 + 1) * 2 parentheses first 8

Watch out — “/ Gives 3 and MOD Gives the Same 3”

Myth: Dividing 17 by 5 gives 3 (you just drop the .4), and MOD gives that same 3 — they both 'do the division.'

Explain why this is wrong:

Stop and think

  1. Evaluate: (a) 23 MOD 4, (b) 4 + 10 MOD 3, (c) 2 * 9 MOD 5. For (b) and (c), show which operator you apply first.
  2. A pizza is cut into 20 slices and shared equally among 6 friends. Write the expression that gives the LEFTOVER slices, and evaluate it.
  3. In one sentence, explain the difference between what 20 / 6 gives and what 20 MOD 6 gives.

Show every step. Then check yourself with the matching CFUs on the Topic 3.3 page.

Common AP Traps

Three ways Topic 3.3 loses points on the exam — one minute now, real points in May.

The slash is EXACT division — in your own words:

MOD is the remainder, and it ties with * and / — in your own words:

Quotient vs remainder are different values — in your own words:

Mathematical Expressions, in One Slide

  • An algorithm is a finite set of steps for a specific task, expressible in natural language, diagrams, or pseudocode, and built from sequencing, selection, and iteration.
  • Sequential statements run in the order written; an expression — a value, variable, operator, or returning procedure call — evaluates to a single value using a set order of operations.
  • The AP arithmetic operators are +, -, *, /, and MOD; the / operator gives the exact value, so 17 / 5 = 3.4.
  • A MOD b is the remainder (17 MOD 5 = 2) with a ≥ 0 and b > 0; MOD shares the precedence of * and /, evaluated left to right.

Exit check — I can…

  • ☐  express an algorithm in natural language or pseudocode and identify its sequencing, selection, and iteration (LO AAP-2.A)
  • ☐  represent a process as sequential statements and state what each expression evaluates to (LO AAP-2.B)
  • ☐  evaluate arithmetic expressions with +, -, *, and /, knowing 17 / 5 = 3.4 (LO AAP-2.C)
  • ☐  evaluate MOD as the remainder (17 MOD 5 = 2) and apply the order of operations with MOD's precedence (LO AAP-2.C)

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.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]