1.2 Program Function and Purpose
Every program is written to do something for someone. This topic covers how to describe a program's purpose, function, and its inputs and outputs — vocabulary that comes straight back in the Create Task.
What you need to know
- A program (or software) is a collection of statements executed by a computer to complete a task.
- Programs are written to solve problems, express creativity, satisfy personal curiosity, or generate new knowledge. The CED distinguishes the program's purpose (what problem/need it addresses) from its function (what it actually does when it runs).
- Inputs are data the program receives — from a user (tactile, audio, visual, text), from a file, from a sensor, or from another program. Outputs are what it produces: text, graphics, audio, or data sent elsewhere.
- An event is an action (mouse click, key press, sensor reading) that triggers a specific program response. Event-driven programs run code in response to events rather than in a fixed sequence.
- Program behavior is defined by how it responds to inputs; the same program can produce different outputs given different inputs.
- A code segment is a portion of a larger program. A code statement is one complete instruction. The exam uses both terms.
Worked example
A weather program's purpose is to help someone decide what to wear. Its function is: take a ZIP code as input, request a forecast from a weather service, and display the high, low, and chance of rain. The user typing a ZIP code is an input; the displayed forecast is an output; pressing "refresh" is an event that triggers a new request. On the Create Task you must describe your own program in exactly these terms.
Going deeper
The nuance, edge cases, and connections that turn a 3 into a 5.
- The CED distinguishes input types you should be able to name: tactile (keyboard, touchscreen), audio (microphone), visual (camera), and text. A sensor reading — temperature, GPS — is also input. Output can be tactile too (a phone vibrating).
- Event-driven programming is a distinct model from sequential: the program sets up handlers and then waits. Nothing happens until a click, key press, timer, or message arrives. Most apps you use are event-driven; most exam pseudocode is sequential. Know both.
- A program's purpose can be for the developer alone — to learn, to satisfy curiosity, to create art. The exam explicitly says a program "can be developed for creative expression" or "to satisfy personal curiosity," and those are as legitimate as solving a business problem.
- "Programs can generate new knowledge" means the output teaches the programmer something they didn't know. Running a simulation of a coin flip 10,000 times and seeing the ratio converge is new knowledge even though you wrote the program.
- A code statement is a single instruction (
x ← 5). A code segment is several statements together. An expression is something that evaluates to a value (x + 1) and isn't a complete statement on its own. The exam uses all three terms precisely.
Mistakes that cost points
- Swapping purpose and function on the Create Task. Purpose = why the program exists (the problem or need). Function = what it does when it runs (inputs → processing → outputs). Writing "the purpose is to display a menu" describes function, not purpose.
- Calling an output an event. An event is something that happens to the program (user clicks). The display that results is output. In a question about a button that shows a quote, the click is the event and the quote is the output — not the reverse.
- Assuming every program must have user input. A program can take input from a file or sensor with no human involved, or take no input at all and still produce output.
Practice questions
Written in the style of the real exam. Try each one before revealing the answer.
Show answer
Answer: C. A user action that causes the program to respond is an event. The quote displayed is the output; the click is the trigger.
Show answer
Answer: B. This is the CED's definition and the exact distinction the Create Task asks you to write about.
Key vocabulary
- Program
- a collection of statements a computer executes to accomplish a task
- Input
- data a program receives from a user, file, sensor, or another program
- Output
- data or behavior a program produces, such as text, graphics, or audio
- Event
- an action, such as a click or key press, that triggers a program response
- Code segment
- a portion of a program's code