Programs can read data, process it much faster than a person, and present results. This lesson shows how to think about that process.
Input, processing, output
Almost every program that uses data follows the same flow:
- Input: data comes in from a user, a file, a sensor, or the network.
- Processing: the program stores it in variables or lists and applies an algorithm.
- Output: the result is shown, saved, or sent elsewhere.
Imagine a program that reads a list of test scores and reports the highest. The scores are the input, a loop that compares values is the processing, and the printed maximum is the output.
Processing a list of records
Here is the idea in AP CSP-style pseudocode. It counts how many scores are passing (60 or more):
passing <- 0
FOR EACH score IN scores
{
IF (score >= 60)
{
passing <- passing + 1
}
}
DISPLAY(passing)
This pattern, loop through a list and update a result, is the foundation of working with data. Variations include summing values, finding a maximum, or building a new list of only the items that match a condition:
highScores <- []
FOR EACH score IN scores
{
IF (score >= 90)
{
APPEND(highScores, score)
}
}
Why programs handle big data well
- Speed: A computer can check millions of records in seconds.
- Consistency: It applies the same rule to every record without getting tired.
- Scale: Parallel and distributed systems split huge jobs across many computers.
But there are limits. Programs only process what they are given, so incomplete or biased data gives biased results. A program also does exactly what you tell it, so a small logic error can spread across millions of records.
Privacy and responsibility
Data about people can be sensitive. When your program collects data, ask:
- Do I really need this information?
- How will it be stored and protected?
- Could combining datasets identify someone?
Even data with names removed can sometimes be matched back to individuals when combined with other sources.
Check your understanding
1. In the flow input, processing, output, loading scores from a file is:
- Input
- Processing
- Output
- Compression
Answer: Input. It is data coming into the program.
2. What does the loop in the passing-scores example compute?
- The highest score
- The number of scores that are 60 or higher
- The average score
- The lowest score
Answer: The number of scores that are 60 or higher. It adds 1 to the counter for each qualifying score.
3. Why is a program often better than a person for large datasets?
- It never makes logic errors
- It processes many records quickly and consistently
- It understands the data’s meaning
- It needs no input
Answer: It processes many records quickly and consistently. It still depends on correct logic and good data.
4. Which is a privacy concern when programs collect data?
- Combining datasets may identify individuals
- Programs run too fast
- Lists are too long
- Variables are too small
Answer: Combining datasets may identify individuals. Even anonymized data can be re-identified.
