Data
What this unit covers
The topics below follow the published CS Principles course framework for Unit 2. This unit is worth 17–22% of the exam, so budget your time against that rather than against how long the unit takes to teach.
Lessons in this unit
- Binary & Number Representation13 min · 3 objectivesExplain why computers represent all data using bits (binary) · Convert numbers between binary and decimal · Relate the number of bits to the range of values that can be represented
- Data Compression13 min · 3 objectivesDistinguish lossless from lossy compression and their trade-offs · Explain why compression reduces storage and transmission costs · Compute and interpret a compression ratio
- Extracting Information from Data13 min · 3 objectivesExplain how patterns and correlations are found in large data sets · Distinguish correlation from causation · Describe the roles of metadata, cleaning, and filtering in analysis
- Bias in Data Collection12 min · 3 objectivesExplain how the way data is collected can introduce bias · Describe how a non-representative sample skews conclusions · Recognize privacy and consent issues in gathering data
Formulas in Unit 2
Every term in Unit 2
All 36 terms we publish for Data, with definitions. Reading them through is the fastest way to find the ones you cannot define — then drill those in cram mode until you can produce them without the prompt.
- Data abstraction
- Using a name to represent a collection of data — a list rather than many separate variables. It lets a program work with any number of items using the same code.
- Bit
- A single binary digit, 0 or 1. The smallest unit of digital data.
- Byte
- Eight bits. Enough to represent 256 distinct values.
- Binary number system
- Base 2, using only 0 and 1. Place values are 1, 2, 4, 8, 16, 32, 64, 128 reading right to left.
- Converting binary to decimal
- Add the place values wherever there is a 1. So 1011 is 8 + 0 + 2 + 1 = 11.
- Converting decimal to binary
- Repeatedly subtract the largest power of 2 that fits, writing 1 for each one used and 0 otherwise. Or divide by 2 repeatedly and read the remainders bottom to top.
- Number of values in n bits
- 2 to the power n. Four bits give 16 values, eight bits give 256 — and this is the calculation behind almost every "how many bits do you need" question.
- Why digital data is discrete
- Computers store finite sequences of bits, so they can only represent a finite set of values. Continuous real-world quantities must be approximated.
- Analog vs digital data
- Analog data varies continuously — sound pressure, light intensity. Digital data is discrete. Converting analog to digital always involves sampling and therefore approximation.
- Sampling
- Measuring an analog signal at regular intervals to make it digital. More frequent samples and more bits per sample give a closer approximation and a larger file.
- Round-off error
- Error from storing a number with limited precision. It accumulates over repeated calculations, which is why floating-point sums can drift.
- Overflow vs round-off
- Overflow is a number too large to store at all. Round-off is a number stored with insufficient precision. Different failures, and the exam distinguishes them.
- Abstraction
- Removing detail to manage complexity, and the central idea of the whole course. A variable name, a procedure, and a high-level language are all abstractions.
- Lossless compression
- Reducing file size with no information lost; the original is exactly recoverable. Used where every bit matters — text, code, archives.
- Lossy compression
- Reducing file size by discarding information, so the original cannot be exactly recovered. Achieves far smaller files, and is acceptable where human perception will not notice.
- Choosing lossy or lossless
- Lossy when the file is large, perception-limited and will not be edited further — streaming video, photographs. Lossless when exactness is required or the file will be re-edited.
- Metadata
- Data about data — file size, creation date, author, image dimensions, location. It can reveal more than the file itself, which is why it is a privacy topic as well as a data topic.
- Information vs data
- Data is raw values. Information is what those values mean once they are collected, cleaned and interpreted. The exam asks what can and cannot be concluded.
- Data cleaning
- Removing errors, duplicates and inconsistencies before analysis — standardizing formats, handling missing values. Skipping it produces confident wrong conclusions.
- Filtering data
- Selecting a subset that meets a condition. Reduces the data to what a question actually needs.
- Data visualization
- Presenting data graphically to reveal patterns. A well-chosen chart makes a trend visible; a poorly chosen one can imply a relationship that is not there.
- Correlation vs causation
- Two things moving together does not mean one causes the other. A standard exam trap on the data-analysis questions.
- Bias in data collection
- When a dataset systematically misrepresents the population — a survey reaching only smartphone users, a sensor only in wealthy neighborhoods. The conclusions inherit the bias.
- Bias in a program
- Bias can enter from the data used, from the assumptions built into the algorithm, or from who was in the room when it was designed. All three are examinable.
- Scalability
- Whether an approach still works as the data grows. Something manageable for a hundred records may be impossible for a hundred million.
- Cleaning vs filtering
- Cleaning fixes bad data. Filtering removes data you do not need. Cleaning improves quality; filtering narrows scope.
- Why large datasets need programs
- Volume beyond human reading. Programs can search, sort, filter and summarize at a scale a person cannot, which is exactly why bias in those programs is consequential.
- Open data
- Data made freely available for anyone to use. Enables collaboration and verification, and raises questions about consent and privacy for the people in it.
- Personally identifiable information (PII)
- Data that can identify a specific individual — name, address, biometrics, and combinations that become identifying together. Location plus timestamp is often PII even when neither is alone.
- Aggregating data
- Combining records to produce a summary such as a count, average or total. Aggregation can protect privacy — or fail to, when the group is small enough to identify.
- Text as binary
- Characters are stored as numbers under an encoding such as ASCII or Unicode, and those numbers are stored as bits. There is no text at the hardware level.
- Images as binary
- An image is a grid of pixels, each stored as numbers for its color components. More bits per pixel means more distinguishable colors and a larger file.
- Sound as binary
- Sound is sampled at intervals, each sample stored as a number. Sample rate and bit depth together determine fidelity and file size.
- Why the same bits can mean different things
- A sequence of bits has no meaning without a convention for reading it. The same byte can be a number, a character or part of a color depending on the program.
- Data compression ratio
- Compressed size divided by original size. A smaller ratio means more compression; the exam usually asks you to compare two schemes rather than compute one.
- Extracting information from data
- Using filtering, sorting, aggregating and visualizing to answer a question the raw data does not answer directly. Name the operation, not just the conclusion.
What examiners penalize here
- Watch for **overflow**: with a fixed number of bits, the representable range is 0 to 2ⁿ − 1. A value past the top cannot be stored, so the exam expects you to say it overflows — not that it rounds or is stored fine.
- Remember the trade-off in one line: **lossless = exact but larger; lossy = smaller but permanent loss.** For a compression ratio, divide original by compressed — a bigger ratio means a smaller file.
- A correlation in data never by itself proves causation. On the exam, the safe reading of "X and Y rise together" is that they are *associated* — a possible hidden variable or reversed direction must be ruled out before claiming cause.
- When a scenario describes collecting data, scan for two things: is the **sample representative**, and was there **consent/privacy** protection? Those are the two questions the exam repeatedly rewards you for asking.
Practice CS Principles
Our practice bank is drawn from across the whole course rather than filtered to one unit, which is closer to how the exam asks anyway — it will not tell you which unit a question is testing.
Questions about this unit
How much of the AP Computer Science Principles exam is Unit 2?
Unit 2, Data, is worth 17–22% of the CS Principles multiple-choice section according to the published course framework. Across all 5 units that makes it one of the heaviest units on the exam, and worth front-loading.
What topics are covered in CS Principles Unit 2?
Data covers Binary, Data compression, Extracting information and Bias. We publish 36 terms with definitions for this unit, all of them on this page.
How should I study CS Principles Unit 2?
Read the 4 lessons below first — about 50 minutes — then drill the 36 terms in cram mode until you can produce each definition from memory rather than just recognize it. Recognition is what makes a unit feel finished when it is not. Finish with practice questions and read the explanation for every one you get right by elimination as well as the ones you miss.
All 5 units of AP Computer Science Principles
Unit names, topics and exam weights follow the published College Board course framework for AP Computer Science Principles. AP® is a trademark registered by the College Board, which does not endorse this site.