Using Programs
with Data
Learn how programs collect, transform, and visualize data to discover patterns and solve real-world problems.
What is Data?
Data is a collection of facts, statistics, or values stored in a structured format. Programs process data to extract meaningful information and generate knowledge.
How Programs Use Data
Data Abstraction and Storage
Data abstraction lets us manage complexity by organizing data into structures. Instead of tracking hundreds of individual variables, we group related values together.
The ETQ Pattern
Filtering vs. Sorting
| Filtering | Sorting | |
|---|---|---|
| Purpose | Remove rows that don't match a condition | Reorder rows by a column's values |
| Data size | Shrinks (fewer rows) | Same (same rows, new order) |
| Example | Show only scores \( > 80 \) | Arrange scores highest to lowest |
| AP Pseudocode | IF condition, APPEND to new list | Compare and swap elements |
Step-by-Step: Working with Data
Example 1: Computing the Average
Given a list of test scores, compute the average.
Example 2: Filtering a List
From the same scores, keep only those above 85.
Example 3: Finding the Maximum
Find the highest score in a dataset using a linear scan.
Visualizing Data
Visualization turns processed data into visual representations that make patterns easier to identify.
Why Cleaning Data Matters
Real-world data is messy. Before processing, you must handle missing values, duplicates, and incorrect formats. Dirty data leads to wrong conclusions.
Metadata and Privacy
Metadata is data about data. A photo's metadata includes the date, location, and camera model. Understanding metadata is critical for both analysis and privacy.
Iterating with Loops
Programs use loops to process every element in a dataset. Two key patterns appear on the AP exam:
Common Mistakes
Summary of Key Concepts
| Concept | What It Does | Example |
|---|---|---|
| Data Abstraction | Groups related values into structures | List of scores |
| Filtering | Keeps only matching items | Scores \( > 85 \) |
| Sorting | Reorders without removing | Highest to lowest |
| Aggregation | Computes a single summary value | Average, max, min |
| Visualization | Displays data as charts/graphs | Bar chart |
| Metadata | Describes data about data | File date, GPS tag |
Question 1 of 5
A program uses a list of 100 temperatures. It loops through the list and keeps only values above 80. What operation is this?
Question 2 of 5
In AP pseudocode, what is the index of the first element in a list?
Question 3 of 5
Code segment:
nums ← [4, 7, 2, 9, 1]
result ← nums[1]
FOR EACH val IN nums
{
IF (val < result)
{
result ← val
}
}
DISPLAY(result)
What value does this program display?
Question 4 of 5
A school collects student names, grades, and home addresses. Which of the following is metadata about this dataset?
Question 5 of 5
Code segment:
data ← [10, 20, 30, 40, 50]
total ← 0
count ← 0
FOR EACH d IN data
{
IF (d > 15)
{
total ← total + d
count ← count + 1
}
}
DISPLAY(total / count)
What value does this program display?