Program Function
and Purpose
Understand what programs do, why they exist, and how to describe a program's behavior, inputs, outputs, and intended purpose.
What Is a Program?
A program is a collection of statements (instructions) that a computer executes to accomplish a specific task. Programs are written in programming languages and can range from a single line to millions of lines of code.
Function vs. Purpose
The AP exam draws a clear distinction between these two terms. Understanding the difference is essential for the Create Performance Task and multiple-choice questions.
The Input-Process-Output Model
Key Definitions for the AP Exam
How to Describe a Program
When asked to describe a program on the AP exam or in your Create Task, always address these four dimensions:
Function vs. Purpose: Side by Side
| Function | Purpose | |
|---|---|---|
| Question answered | What does it do? | Why was it made? |
| Perspective | Technical / observable | Human / motivational |
| Example (calculator) | Takes two numbers, applies an operation, returns result | To help students solve math problems quickly |
| Example (weather app) | Fetches API data, parses JSON, displays forecast | To help people plan daily activities around weather |
The same forecast data becomes a decision on a park bench
A weather app’s purpose is to help people plan. Its functions receive location and forecast data, process a response and display information or an alert.Separate the purpose from the executed steps
The person wants to plan an outdoor activity. The app receives location and a weather-service response, parses the data and checks severeWeather before displaying an alert. The service’s output is an input to the app.Step-by-Step: Identifying Function and Purpose
Example 1: Tip Calculator
Example 2: Password Checker
Example 3: Event-Driven Program
Program Documentation
Documentation is a written description of a program's function, purpose, and behavior. It helps others (and your future self) understand what the code does and why.
Types of Program Inputs
Types of Program Outputs
Common Mistakes to Avoid
Summary: Key Concepts
| Concept | Definition | Example |
|---|---|---|
| Program | Collection of instructions | A weather app |
| Function | What it does (behavior) | Fetches and displays forecast |
| Purpose | Why it was created | Help people plan for weather |
| Input | Data the program receives | ZIP code, GPS coordinates |
| Output | Results the program produces | Temperature, rain forecast |
| Event | Action triggering code | User taps "Refresh" |
Question 1 of 5
A fitness app tracks a user's daily steps using a phone's accelerometer and displays a bar chart of weekly activity. Which of the following best describes the purpose of this program?
Question 2 of 5
Which of the following is an example of a program input that does NOT come directly from a user?
Question 3 of 5
A program accepts a list of student names and test scores, then displays the class average and the name of the highest scorer. Which of the following best describes the function of this program?
Question 4 of 5
In an event-driven program, which of the following best describes what happens when no events have occurred?
Question 5 of 5
A developer writes comments in their code explaining that a function calculates shipping costs based on package weight and destination. This is an example of: