---
title: "Big Idea 3: Variables, Operators, Strings & Lists | FiveStudy"
description: "Comprehensive study guide for AP Computer Science Principles. Free on FiveStudy."
url: https://fivestudy.com/guides/variables-operators-strings-lists
---

[AP Computer Science Principles](https://fivestudy.com/ap-computer-science-principles) · Study guide

# Big Idea 3: Variables, Operators, Strings & Lists

[Figure: FiveStudy logo]

FiveStudy

Big Idea 3 · Part 1

Big Idea 3 · Algorithms & Programming · Part 1 of 4

# Variables, Operators, Strings & *Lists*

The building blocks of every program: how data is stored, how expressions are evaluated, and how lists organize collections of values.

## §1 What Big Idea 3 Covers

Big Idea 3 (AAP) is the programming and algorithms half of the course — the largest Big Idea at **30–35% of the exam**. Most questions fall into one of these categories:

- **Tracing code** — given a code segment, figure out what it outputs or returns.
- **Fixing bugs** — given code that almost works, identify the change that fixes it.
- **Choosing the right construct** — which loop, condition, or list operation.
- **Algorithms** — linear vs. binary search, efficiency, heuristics.
- **Robot navigation** — moving a robot through a grid.

Part 1 covers variables, operators, strings, and lists. Parts 2–4 cover selection, iteration, procedures, the robot, and algorithms.

Most important skill

The single most valuable skill for BI3 is **hand-tracing code**. Many questions are just "run this code in your head and tell me what happens." Being systematic — writing variable values in a table — beats trying to trace mentally.

## §2 Variables and Data Types

A **variable** is a named storage location that holds a value. The **assignment** operator (←) puts a value into a variable:

a ← 5
b ← a + 3

After these lines: a = 5 and b = 8.

| Type | What it stores | Examples |
| --- | --- | --- |
| **Number** | Integers or decimals | 5, 3.4, -7 |
| **Boolean** | true or false | true, false |
| **String** | Sequence of characters | "hello", "AP CSP" |
| **List** | Ordered collection of values | [3, 7, 11, 2] |

Common pitfall

Do not confuse the **assignment arrow ←** ("store this value") with the **equality operator =** ("does this equal that?"). `a ← 5` stores 5 in a. `a = 5` asks "is a equal to 5?" and returns true or false.

## §3 Arithmetic & MOD

| Operator | Name | Example | Result |
| --- | --- | --- | --- |
| + | Addition | 7 + 3 | 10 |
| - | Subtraction | 7 - 3 | 4 |
| * | Multiplication | 7 * 3 | 21 |
| / | Division | 17 / 5 | 3.4 (always decimal) |
| MOD | Remainder | 17 MOD 5 | 2 |

Definition · AP CSP division

Unlike Java, AP CSP pseudocode division **always produces a decimal**: 17 / 5 = 3.4, not 3. There is no "integer division" on the AP CSP exam. MOD gives you the remainder.

### 3.1 Common Uses of MOD

- **Even / odd:** n MOD 2 = 0 means n is even.
- **Last digit:** n MOD 10 gives the ones digit.
- **Cycle:** i MOD 3 cycles through 0, 1, 2, 0, 1, 2, …
- **Divisibility:** n MOD 5 = 0 means n is divisible by 5.

## §4 Boolean Operators

Relational operators (=, ≠, <, >, ≤, ≥) compare two values and return true or false. Boolean operators (AND, OR, NOT) combine Boolean values:

| A | B | A AND B | A OR B | NOT A |
| --- | --- | --- | --- | --- |
| true | true | true | true | false |
| true | false | false | true | false |
| false | true | false | true | true |
| false | false | false | false | true |

Key idea

**AND** is true only when *both* parts are true. **OR** is true when *at least one* part is true (inclusive — both true also counts). Don't let everyday English mislead you.

### 4.1 De Morgan's Laws

Two patterns appear on the exam often:

- NOT (A AND B) = (NOT A) OR (NOT B)
- NOT (A OR B) = (NOT A) AND (NOT B)

When you push NOT inside parentheses, AND flips to OR and vice versa.

## §5 Strings

A **string** is a sequence of characters in double quotes. The exam uses strings mostly for concatenation, length, and comparison.

Exam tip · Concatenation names vary

The exam does not have one standard name for concatenation. You may see it as `concat(a, b)`, `combine(a, b)`, or described in plain English ("returns a followed by b"). Read the problem's own description — don't assume a name from a previous question.

## §6 Lists

A **list** is an ordered collection of values. The exam uses **1-based indexing**: the first element is at index 1, not 0.

letters[1] is "A"; letters[5] is "E". Accessing letters[0] or letters[6] causes an error.

### 6.1 List Operations

| Operation | What it does |
| --- | --- |
| **LENGTH(list)** | Returns the number of elements. |
| **APPEND(list, value)** | Adds value to the end. Length increases by 1. |
| **INSERT(list, i, value)** | Inserts value at index i. Elements at or after i shift right. |
| **REMOVE(list, i)** | Removes element at index i. Elements after i shift left. Length decreases by 1. |
| **list[i] ← value** | Replaces element at index i. Length unchanged. |
| **FOR EACH x IN list** | Iterates x through every element in order. |

Common pitfall

INSERT and REMOVE *shift* other elements. After REMOVE(list, 2) on [A, B, C, D], the list becomes [A, C, D] — what was at index 3 is now at index 2. Watch out for this in loops that track indexes manually.

### 6.2 FOR EACH vs. Indexed Iteration

**FOR EACH** is simpler when you just need each element's value. Use an **indexed loop** when you need the position or need to compare adjacent elements.

## §7 Key Terms

| Term | Definition |
| --- | --- |
| **Assignment** | Storing a value in a variable (a ← value) |
| **Boolean** | A value that is either true or false |
| **Expression** | A combination of values, variables, and operators that evaluates to a result |
| **Index** | The position of an element in a list (starting at 1 on the exam) |
| **List** | Ordered collection of values, indexed starting at 1 |
| **MOD** | Operator giving the remainder of division |
| **String** | A sequence of characters in quotes |
| **Variable** | A named storage location for a value |

## §8 Self-Check

1. What is the difference between ← and = in AP CSP pseudocode?
2. Evaluate: 17 MOD 4, 20 MOD 5, 3 MOD 7.
3. Given letters = ["P", "Q", "R", "S", "T"], what is letters[3]? What does LENGTH(letters) return? What does the list look like after REMOVE(letters, 2)?
4. Which is equivalent to NOT (a > 5 AND b < 10)? (a) a < 5 AND b > 10, (b) a ≤ 5 OR b ≥ 10, (c) a ≤ 5 AND b ≥ 10, (d) a > 5 OR b < 10

**Show Answers**

1. ← is assignment (stores a value). = is comparison (returns true or false).
2. 17 MOD 4 = 1. 20 MOD 5 = 0. 3 MOD 7 = 3 (dividend smaller than divisor → remainder is the dividend).
3. letters[3] = "R". LENGTH = 5. After REMOVE(letters, 2): ["P", "R", "S", "T"] (length 4).
4. **(b)**. By De Morgan's: NOT(a > 5) OR NOT(b < 10) = a ≤ 5 OR b ≥ 10.

FiveStudy · AP Computer Science Principles · 2025–26

BI3 Part 1 · Variables, Operators, Strings & Lists
