Read complete course notes

All guides

AP Computer Science Principles

Twelve lessons across the five big ideas, from binary and data to algorithms, networks, security and impact, with the Create task and written responses explained.

A study guide to AP Computer Science Principles, not a full course. Big idea weights and exam format follow the College Board pages. Practice values in the labs are invented. The Create task must be your own work.

['Basic algebra']

Course outline

  1. Creative development, the Create task and how the exam scores it

    Know what the exam and the Create performance task reward.

  2. Binary numbers, bits and overflow

    Convert between binary and decimal and reason about limits.

  3. Data compression

    Choose lossless or lossy compression and compute sizes.

  4. Extracting information from data

    Tell data from information, spot bias and read correlation carefully.

  5. Variables, expressions and the exam pseudocode

    Trace assignments, arithmetic and strings in AP pseudocode.

  6. Boolean logic and conditionals

    Evaluate AND, OR, NOT and nested selection.

  7. Iteration and lists

    Trace loops and list traversals, including 1-based indexing.

  8. Procedures, abstraction and libraries

    Use parameters and return values and explain why abstraction helps.

  9. Algorithms and efficiency

    Compare algorithm run time and recognize reasonable and unreasonable time.

  10. Simulations, parallel and distributed computing

    Explain what simulations abstract away and compute parallel speedup.

  11. The Internet, protocols and fault tolerance

    Explain packets, IP addresses, DNS and redundancy.

  12. Cybersecurity and the impact of computing

    Explain encryption, phishing, bias and the digital divide.

Sources and curriculum note

Reviewed October 8, 2026. Exam format: 70 multiple-choice questions plus Create task and written response. Confirm dates on AP Central.

Complete course reading notes

Read every lesson below. The interactive reader above contains the same explanations, with visual tools and quizzes.

1. Creative development, the Create task and how the exam scores it

Learning goal: Know what the exam and the Create performance task reward.

AP Computer Science Principles has two parts: a Create performance task you complete during class time, and an end-of-course exam. The exam is 70 multiple-choice questions in 120 minutes (70% of the score). The performance task and its two written-response questions make up the other 30%.

The Create task asks you to build a program of your choice, record a short video of it running, and submit a Personalized Project Reference with your code. On the exam day you get that reference back and answer written questions about your own code. So the code you submit must be code you understand line by line.

Creative development is about process. A program has a purpose, takes inputs (clicks, text, sensor data) and produces outputs (display, sound, a returned value). Good development is iterative: build a small piece, test it, change it. Working with others brings in different perspectives and catches errors you do not see.

Documentation matters because comments and clear names let another person explain what a code segment does without running it. Many exam questions are exactly that: explain what this segment does, or find the error in it.

Worked example

Describe a quiz program for the exam.

  1. State the purpose: help a student review
  2. Inputs: the student's typed answers
  3. Process: compare each answer to the stored answer
  4. Output: a score displayed at the end
Practice problem and solution

The multiple-choice section has 70 questions and counts for 70% of the score. What percent of the score is left for the Create task and its written responses?

100 - 70 = 30 percent.

Mental model: Know your own code: purpose, inputs, process, outputs.

Common trap: Submitting code you cannot explain.

2. Binary numbers, bits and overflow

Learning goal: Convert between binary and decimal and reason about limits.

A bit is a 0 or a 1. A binary number uses powers of two as place values. In 8 bits the place values from left to right are 128, 64, 32, 16, 8, 4, 2 and 1. The binary number 10110 equals 16 + 4 + 2 = 22.

With n bits you can represent 2 to the n different values, from 0 to 2 to the n minus 1. Eight bits (a byte) gives 256 values, 0 through 255. Adding one more bit doubles the number of values.

Digital data of every kind (numbers, text, color, sound) is stored as bits. The same bits can mean different things depending on the interpretation, so a file needs a known format.

Overflow happens when a result is too large for the bits set aside for it. Real numbers stored with a fixed number of bits can also lose precision, which is why 0.1 + 0.2 may not equal exactly 0.3 in some programs. These are round-off errors, a limit of representation.

Worked example

Convert 10110 to decimal.

  1. Write place values 16 8 4 2 1
  2. Mark the ones: 16, 4, 2
  3. Add 16 + 4 + 2
  4. The result is 22
Practice problem and solution

How many different values can 6 bits represent? Enter a number.

2 to the 6th is 64.

Mental model: n bits give 2 to the n values.

Common trap: Forgetting that 0 counts, so the largest value is one less.

3. Data compression

Learning goal: Choose lossless or lossy compression and compute sizes.

Compression makes data smaller so it takes less storage and less time to send. Lossless compression lets you rebuild the original exactly. Lossy compression discards some information for a smaller file, and the original cannot be fully restored.

Choose by purpose. A legal document, a program or a spreadsheet needs lossless. A photo or a song for streaming can often use lossy, because small losses are hard to notice. Lossy gives smaller files but lower quality, and heavier compression loses more.

A simple lossless idea is run-length encoding: AAAABBB becomes 4A3B. It saves space when values repeat and can even grow the data when they do not.

Size arithmetic is common on the exam. A 1000 by 1000 pixel image with 24 bits per pixel has 24,000,000 bits, or 3,000,000 bytes before compression.

Worked example

Choose compression for a contract PDF.

  1. Ask whether any loss is acceptable
  2. A contract must stay exact
  3. Pick lossless
Practice problem and solution

A file of 800,000 bits is compressed to 25% of its size. How many bits remain? Enter a number.

25 percent of 800,000 is 200,000.

Mental model: Lossless restores exactly, lossy trades detail for size.

Common trap: Using lossy compression on data that must stay exact.

4. Extracting information from data

Learning goal: Tell data from information, spot bias and read correlation carefully.

Data are values; information is what you can learn from them. Metadata is data about data, such as the time and location a photo was taken. Metadata can be changed without changing the data it describes, and it helps find and organize files.

Large datasets help find patterns, but correlation is not causation. Two things moving together may share a third cause or be a coincidence. Data can also be incomplete or biased, for example if a survey reaches only people who already use an app.

Cleaning data means fixing or removing records that are missing, duplicated or malformed. Different cleaning choices can change the result, so a good analysis states what was removed.

Programs process data using filtering, combining, grouping and transforming. Scale matters: a method that works on 100 rows may be too slow on a billion, which leads into algorithm efficiency.

Worked example

Evaluate a claim that ice cream sales cause sunburn.

  1. Both rise in summer
  2. A shared cause is warm weather
  3. So the data show correlation only
Practice problem and solution

A dataset has 5000 records and 12% have a missing value. How many records have a missing value? Enter a number.

12 percent of 5000 is 600.

Mental model: Information comes from data; check source, bias and cause.

Common trap: Reading correlation as proof of cause.

5. Variables, expressions and the exam pseudocode

Learning goal: Trace assignments, arithmetic and strings in AP pseudocode.

The exam uses its own pseudocode, not a real language. Assignment is written a ← expression: the value of the expression on the right is stored in the variable on the left. A variable holds one value at a time, and a new assignment replaces the old value.

Arithmetic uses +, -, *, / and MOD. a MOD b is the remainder when a is divided by b, so 17 MOD 5 is 2. MOD is how programs test even numbers (n MOD 2 = 0) and wrap around, such as clock arithmetic.

Strings are sequences of characters. Concatenation joins strings. Substring and length operations pick out parts. Many mistakes are off by one, so always trace by hand with a small example.

Tracing means writing each variable's value after every line. It is the main skill for code questions: do not guess the answer, compute it.

Worked example

Trace x ← 17 MOD 5 then y ← x * 3.

  1. 17 MOD 5 is 2
  2. x is 2
  3. y is 2 times 3
  4. y is 6
Practice problem and solution

x ← 17 MOD 5 and then y ← x * 3. What is y? Enter a number.

17 MOD 5 is 2, and 2 times 3 is 6.

Mental model: Assignment stores, MOD is remainder, trace by hand.

Common trap: Confusing = comparison with ← assignment.

6. Boolean logic and conditionals

Learning goal: Evaluate AND, OR, NOT and nested selection.

A Boolean value is true or false. Relational operators (=, ≠, >, <, ≥, ≤) compare values and give a Boolean. Logic operators combine them: NOT flips, AND is true only if both sides are true, OR is true if at least one side is true.

A conditional runs code only if its condition is true. IF with an ELSE chooses between two paths. A chain of ELSE IF tests conditions in order and runs only the first true branch, so the order of tests matters.

Put the most specific test first. If a score of 95 is tested against ≥70 before ≥90, it takes the lower branch, which is a common bug.

De Morgan thinking helps: NOT (A AND B) is the same as (NOT A) OR (NOT B). Test boundaries, such as exactly 90, to catch off-by-one logic.

Worked example

Evaluate (x>10 AND x<20) for x=12.

  1. x>10 is true
  2. x<20 is true
  3. true AND true is true
  4. The condition holds
Practice problem and solution

x ← 12. IF (x>10 AND x<20) result ← 1 ELSE result ← 0. What is result? Enter a number.

Both comparisons are true, so result is 1.

Mental model: AND both, OR either, order of tests matters.

Common trap: Putting a broad test before a specific one.

7. Iteration and lists

Learning goal: Trace loops and list traversals, including 1-based indexing.

Iteration repeats code. REPEAT n TIMES runs a block n times; REPEAT UNTIL runs until a condition becomes true; FOR EACH item IN list visits every element. If the condition of REPEAT UNTIL never becomes true, the loop never stops.

Lists in the exam pseudocode start at index 1, not 0. LENGTH(list) gives the number of elements. APPEND adds to the end, INSERT puts a value at an index and shifts later items, and REMOVE deletes one and shifts items back.

Typical traversal patterns: accumulate a sum, count items that pass a test, find the maximum, or search for a value. Each uses a variable set before the loop and updated inside it.

A list is data abstraction. Instead of ten separate variables you keep one list, which manages complexity and works for any length. The Create task requires a list for exactly this reason.

Worked example

Trace a count of even items in [4, 8, 15, 16].

  1. count ← 0
  2. 4 is even: count 1
  3. 8 is even: count 2
  4. 15 is odd
  5. 16 is even: count 3
Practice problem and solution

list is [4, 8, 15, 16]. count ← 0. FOR EACH item: IF item MOD 2 = 0 then count ← count + 1. What is count? Enter a number.

4, 8 and 16 are even.

Mental model: Initialize, visit each item, update.

Common trap: Using 0-based thinking on a 1-based list.

8. Procedures, abstraction and libraries

Learning goal: Use parameters and return values and explain why abstraction helps.

A procedure is a named block of code you can call with different arguments. Parameters are the inputs a procedure declares; RETURN sends a value back. Procedural abstraction means you can use a procedure knowing what it does without knowing how.

Abstraction manages complexity: it hides detail so you think at a higher level. Reusing a procedure reduces repeated code and makes changes in one place. Modularity splits a large program into pieces that can be built and tested separately.

Libraries and APIs provide procedures others wrote. Using them saves time, but you must read the documentation to know the inputs and result, and cite the source.

RANDOM(a, b) returns a random integer from a to b inclusive, so each run can differ. Programs using random values need many tests, and the same input may not always give the same output.

Worked example

Trace f(f(3)) where f(x) returns x*2+1.

  1. Compute inner f(3) = 7
  2. Use 7 as the new argument
  3. f(7) = 15
Practice problem and solution

PROCEDURE f(x) returns x*2+1. What is f(f(3))? Enter a number.

f(3) is 7 and f(7) is 15.

Mental model: Procedures hide detail and return values.

Common trap: Forgetting that RETURN ends the procedure.

9. Algorithms and efficiency

Learning goal: Compare algorithm run time and recognize reasonable and unreasonable time.

Every algorithm is built from sequencing, selection and iteration. Different algorithms can solve the same problem with different efficiency. Efficiency is usually judged by how the number of steps grows as the input grows.

Linear search checks items one by one, so in the worst case it checks all n items. Binary search needs a sorted list and halves the remaining items each step, so about log2 n steps. For 1000 items, binary search needs at most 10 comparisons because 2 to the 10th is 1024.

An algorithm runs in reasonable time if the steps grow as a polynomial of the input size (n, n squared, n cubed), and unreasonable time if they grow exponentially. Unreasonable algorithms cannot finish for large inputs.

When no efficient exact method is known, a heuristic gives a good-enough answer quickly, with no guarantee of the best. Some problems are undecidable: no algorithm can solve every instance.

Worked example

Count binary search comparisons for 1000 items.

  1. Each step halves the remaining items
  2. 1000, 500, 250, 125, 63, 32, 16, 8, 4, 2, 1
  3. About 10 halvings
Practice problem and solution

A sorted list has 1000 items. What is the largest number of comparisons binary search needs? Enter a number.

2 to the 10th is 1024, which covers 1000 items.

Mental model: Binary halves, linear checks all, exponential is unreasonable.

Common trap: Using binary search on an unsorted list.

10. Simulations, parallel and distributed computing

Learning goal: Explain what simulations abstract away and compute parallel speedup.

A simulation is a program that models a real system so you can experiment without the real cost or risk. Every simulation simplifies reality, so it may leave out details that matter. Results are only as good as the model and its data. Simulations can also use random numbers to model chance.

Sequential computing runs one operation after another. Parallel computing breaks a task into parts that run at the same time on different processors. Distributed computing uses multiple devices working on a task together.

Speedup is sequential time divided by parallel time. The parallel time is set by the slowest independent part, plus any steps that must still run in order. Tasks that depend on each other cannot all run at once, so adding processors has diminishing returns.

The benefit of parallel and distributed computing is solving larger problems or solving them faster. The costs are the effort of dividing the work and the part that cannot be split.

Worked example

Find the parallel time for independent tasks of 40 and 25 seconds.

  1. Both start together
  2. Parallel time is the longer task
  3. 40 seconds
Practice problem and solution

Two independent tasks take 40 s and 25 s. What is the parallel time in seconds? Enter a number.

The longer task sets the time.

Mental model: Speedup is sequential over parallel time.

Common trap: Adding the times for work that runs in parallel.

11. The Internet, protocols and fault tolerance

Learning goal: Explain packets, IP addresses, DNS and redundancy.

The Internet is a network of networks that follows open protocols. A protocol is an agreed set of rules. IP gives each device an address; TCP breaks messages into packets and reassembles them; DNS turns names like example.com into IP addresses.

Data is split into packets, each with a header and a chunk of data. Packets may take different routes and arrive out of order, so they are numbered and reassembled. A message of 1,200 bytes sent in 400-byte packets takes 3 packets.

The Internet is fault tolerant because there are many paths between two points. If a router fails, packets use another route. Redundancy adds capacity and reliability at the cost of more equipment.

Bandwidth is the maximum data per second; latency is the delay. Streaming a video needs bandwidth, while a live game needs low latency.

Worked example

Count the packets for a 1,200 byte message in 400 byte packets.

  1. 1,200 divided by 400 is 3
  2. No remainder
  3. 3 packets
Practice problem and solution

A 1,200 byte message is sent in packets with a 400 byte payload each. How many packets? Enter a number.

1200 divided by 400 is 3.

Mental model: Packets, routes and redundancy keep the Internet working.

Common trap: Thinking packets always arrive in order.

12. Cybersecurity and the impact of computing

Learning goal: Explain encryption, phishing, bias and the digital divide.

Symmetric encryption uses one shared key. Public-key encryption uses a public key to encrypt and a private key to decrypt, so strangers can send secrets without first sharing a key. Multifactor authentication needs two or more kinds of proof, which stops most stolen-password attacks.

Phishing tricks people into giving up information, usually by a fake message. Keylogging software records keystrokes, and malware is software that harms. Strong, unique passwords and updates reduce risk, and people are often the weakest link.

Computing has benefits and harms. Bias can enter through training data or design choices. The digital divide is the gap in access to computers and the Internet, shaped by income and location. Crowdsourcing gathers input from many people, and citizen science uses it for research.

Intellectual property is covered by copyright, and licenses such as Creative Commons say how work can be reused. Legal and ethical questions arise with every computing innovation, so exam answers should name a specific benefit and a specific harm.

Worked example

Name a benefit and a harm of a ride-sharing app.

  1. Benefit: cheaper, easier travel
  2. Harm: location data can be misused
  3. State both explicitly
Practice problem and solution

In a survey of 400 people, 30% lack home broadband. How many people is that? Enter a number.

30 percent of 400 is 120.

Mental model: Encryption protects data; people and access shape impact.

Common trap: Giving a vague benefit or harm without naming it.