AP Computer Science Principles covers the big ideas behind computing, including algorithms, programming, data, the internet, cybersecurity, and the effects of technology on society. This cheat sheet gives students a quick reference for the concepts and rules that appear often on the AP exam. It is useful for reviewing vocabulary, tracing code, comparing algorithms, and checking common formulas.
Students can use it while practicing multiple choice questions, performance task planning, or general programming review.
The most important ideas include how programs store values, make decisions, repeat actions, and organize data in lists. Students should know how to read pseudocode, evaluate Boolean expressions, and describe how procedures use parameters and return values. They should also understand binary representation, metadata, data compression, packets, protocols, and basic cybersecurity practices.
Strong AP CSP answers connect technical details to purpose, efficiency, correctness, and real-world impact.
Key Facts
- A variable stores one value at a time, and assignment updates it, as in score <- score + 1.
- A conditional runs code only when a Boolean expression is true, using the structure IF condition THEN action ELSE other action.
- A loop repeats steps, and a FOR EACH item IN list loop processes every element in a list one at a time.
- List indexing in AP CSP pseudocode starts at 1, so the first element is list[1] and the last element is list[LENGTH(list)].
- A procedure can use parameters as input values, and a RETURN statement sends one result back to the part of the program that called it.
- A binary number with n bits can represent 2^n different values, so 8 bits can represent 256 possible values.
- The internet sends data as packets, and protocols such as IP, TCP, DNS, and HTTP define rules for addressing, routing, reliability, naming, and web communication.
- Lossless compression preserves all original data, while lossy compression removes some data to reduce file size.
Vocabulary
- Algorithm
- A step-by-step process that solves a problem or completes a task.
- Abstraction
- A simplified representation that hides details so a programmer can focus on the important parts of a problem.
- Boolean Expression
- An expression that evaluates to either true or false, often using operators such as AND, OR, and NOT.
- Parameter
- A named input used inside a procedure to let the same code work with different values.
- Metadata
- Data that describes other data, such as a file name, date created, location, author, or image size.
- Protocol
- An agreed set of rules that computers use to communicate over a network.
Common Mistakes to Avoid
- Confusing assignment with comparison is wrong because x <- 5 changes the value of x, while x = 5 checks whether x is equal to 5.
- Starting AP CSP list positions at 0 is wrong because AP CSP pseudocode uses 1-based indexing, so list[1] is the first element.
- Using OR when AND is required gives the wrong logic because OR is true when at least one condition is true, but AND requires both conditions to be true.
- Forgetting to update a loop control variable can create an infinite loop because the stopping condition may never become true.
- Claiming encryption prevents all cyberattacks is wrong because encryption protects data confidentiality, but it does not stop phishing, weak passwords, malware, or social engineering.
Practice Questions
- 1 A binary code uses 6 bits. How many different values can it represent?
- 2 Trace the code: x <- 3, y <- 2, x <- x + y, y <- x * 2. What are the final values of x and y?
- 3 A list contains [4, 7, 2, 9]. What value is stored at list[2] in AP CSP pseudocode, and what is LENGTH(list)?
- 4 Explain why using a procedure with parameters is an example of abstraction, and describe one benefit it gives a programmer.
Understanding AP Computer Science Principles Reference
An algorithm is more than a list of steps that works on one convenient example. It needs to give the intended result for every allowed input. This is why tracing matters.
Make a table of variable values after each line runs. Include ordinary cases, the smallest allowed value, the largest allowed value, an empty list when it is permitted, and repeated items. These cases expose errors such as using the wrong starting position or stopping a loop too early.
Efficiency matters when inputs become large. A method that checks every item may be acceptable for a short class list but slow for millions of records. On the AP exam, describe efficiency in terms of how the number of steps changes as the input size grows.
Programs become manageable through abstraction. A procedure hides detailed steps behind a meaningful name, so the rest of the program can focus on its main job. Good parameters make a procedure reusable because the caller supplies different input values.
A returned value is useful when later code needs the result for a calculation or decision. Be careful to distinguish changing a local variable from changing a list that was passed into a procedure. Lists are especially important because one list can represent many related records, such as daily temperatures or student responses.
When code removes or inserts an item, positions can shift. Trace the list itself after each change rather than assuming its old positions remain valid.
Digital data is represented with patterns of bits, but the meaning of a pattern depends on the chosen encoding. A bit pattern might stand for a whole number, a letter, one pixel color, or part of a sound sample. Images need more data when they have more pixels or more possible colors per pixel.
Sound needs more data when it is sampled more often or each sample stores more detail. Compression reduces the amount of data that must be stored or sent. Lossless methods are needed when every symbol must remain exact, such as program files, passwords, and many text records.
Lossy methods can be reasonable for photos, music, or video when a small quality change is acceptable. Metadata describes data, such as the author, date, location, file type, or camera settings. It can be useful for sorting files, yet it can reveal private information.
Internet systems work because many independent devices follow shared rules. A message is divided into packets so routers can send pieces along available paths. Packets may arrive late, out of order, or not at all.
Reliability systems can detect missing pieces and request them again. Domain name services translate familiar web names into network addresses. This layered design helps the internet keep working when one route fails, though it does not guarantee perfect security.
Encryption protects data by making it unreadable without the proper key. Strong passwords, multi factor authentication, software updates, and careful permission settings reduce risk, but each has limits.
When discussing a computing innovation, name a specific benefit and a specific harm. Support each claim with who is affected, what data is involved, and why the result occurs.