Fiveable

⌨️AP Computer Science Principles Unit 1 Review

QR code for AP Computer Science Principles practice questions

1.2 Program Function and Purpose

1.2 Program Function and Purpose

Written by the Fiveable Content Team • Last updated June 2026
Verified for the 2027 exam
Verified for the 2027 examWritten by the Fiveable Content Team • Last updated June 2026
⌨️AP Computer Science Principles
Unit & Topic Study Guides

AP Computer Science Principles Exam

Pep mascot

TLDR

Every computing innovation exists to solve a problem or to support creative expression, and every program runs by taking in inputs, processing them, and producing outputs. This topic gives you the vocabulary to describe what a program does, how it behaves, and how events and inputs drive that behavior.

Why This Matters for the AP Computer Science Principles Exam

The terms in this topic show up across the exam because they are how you talk about any program clearly. On multiple-choice questions, you may need to identify a program's purpose, trace how inputs lead to outputs, or recognize event-driven behavior. The same vocabulary carries into the Create performance task, where you describe your program's purpose, its inputs, and its outputs in your written responses. Getting comfortable with these words now makes both parts of the exam easier later.

Key Takeaways

  • A computing innovation's purpose is either to solve a problem or to allow creative expression, and a clear purpose makes the program easier to build.
  • A program is a collection of statements that performs a task, and a code segment is a smaller piece of a program.
  • Inputs are data a program takes in; outputs are data a program sends out. Both can be tactile, audio, visual, or text.
  • Inputs usually affect outputs, and outputs often depend on input or on the program's prior internal state.
  • An event is an action that supplies input and can change how a program runs. Event-driven programs respond to events instead of running straight through in order.
  • A program's behavior is how it functions while running, often described by how a user interacts with it. A program needs to work for many different inputs and situations.

Quick Reference

purpose of computing innovationscreative expression
solving problemsimportance of a clear purpose
program inputsprogram behaviors
------
program outputscode segments
program event
---
event-driven software## Computing Innovations and Their Purposes The purpose of a computing innovation is what it is designed to do. Every computing innovation includes a program as a core part of how it works, and that program exists for one of two reasons: - Solving problems. Text messaging and video-chat platforms solve the problem of communicating quickly over long distances. The problem does not have to be huge. A simple adding program solves the "problem" of needing to add two numbers together. - Creative expression. Making a video game or writing a program that draws shapes on a screen are examples of building something as a form of creative expression. Understanding the purpose of a computing innovation gives developers a better ability to build it. Having a clear purpose is like having a strong thesis for an essay: it focuses the work and sets the goals for what you are making. ## Programs and Code Segments A program is a collection of program statements that performs a specific task when run by a computer. Programs are also called software. - Think of a program like a recipe. Just as you bake a cake by following each step, a computer runs by following each step in the program. Within a program, you have code segments. - A code segment is a smaller collection of statements that is part of a program. It is like the part of a recipe that explains how to make the frosting. - There is no strict rule for where one code segment ends and another begins, so a code segment can be almost any group of related statements. Each code segment is made up of individual statements, the single instructions the computer carries out. A statement is like one recipe line that says, "Crack three eggs into the bowl." In short, a program is made up of code segments, which are made up of statements. ## Describing Programs You can describe a program broadly by what it does: > My adding program lets the user add two numbers of their choice. You can also describe it in more detail by explaining both what it does and how the statements accomplish it: > My adding program asks the user to input two numbers, then adds them together and displays the final sum. Knowing both levels of description is useful. On the exam, some questions want a broad summary of what a program does, while others want you to explain how specific statements produce a result. ## Program Inputs Inputs are data sent to a computer for processing by a program. In an adding program, the two numbers you enter are the inputs. Inputs can come from a user or from other programs, and they usually affect the output the program produces. ### Types of Inputs - Tactile (keystrokes, swipes on a touchscreen) - Audio (spoken words or music sent into a sound processor) - Visual (photos loaded into a photo editor) - Text (words entered into a translation program, numbers typed into a calculator) ## Program Outputs Outputs are any data sent from a program to a device. In the adding program, the output is the final sum the program returns. Output is usually based on the program's input or its prior state, meaning internal values the program is already holding. ### Types of Outputs Outputs can take the same forms as inputs. - Tactile (a game controller vibrating in response to in-game movement) - Audio (music that plays when you press a play button) - Visual (an edited photo from a photo editor) - Text (translated text from a translation program) ## Program Events For a program to receive certain inputs, an event often needs to happen. An event is an action that is associated with input data and can change the flow of how a program runs. For example, pressing the left arrow key tells a video game's program to move an avatar left. Pressing the key is the event. If you had not pressed it, the avatar would have kept doing what it was doing before. ### Common Events - clicking a button - moving or clicking a mouse - starting a program - pressing a key - a timer reaching zero ### Event-Driven Programming A lot of modern software is event-driven, which means its statements run when they are triggered by an event rather than running straight through in sequential order. Go back to the adding program. Starting the program is an event. Typing in the two numbers is another event. The program responds based on those events, so it behaves in an event-driven way. On a larger scale, your phone's software is event-driven because it mainly responds to your taps, clicks, and swipes. ## Program Behavior A program's behavior is how it functions during execution, and it is often described by how a user interacts with it. When you run a program, you expect it to act a certain way. It helps to plan a program's behavior before you code it. To do that, you need to know the program's purpose, how events supply inputs for the program to process, and how the program will produce outputs. A program needs to work for a variety of inputs and situations. Even if a programmer does not define behavior for a certain scenario, the program will still do something, and that something is often a crash. You would not want an adding program to crash or to multiply the numbers instead of adding them. Fully defining behavior can be hard. Imagine building a simple version of Snake, where the snake eats food, its tail grows, and the game ends when the snake hits its own tail. Even that basic game raises questions: Should there be a welcome screen? Should hitting your tail end the game or cost you a life? Should the snake change color when it eats? The adding program has its own edge cases too, like what should happen if the user types letters instead of numbers. You are not expected to define behavior for every possible scenario your program could run into, and you will not be asked to list every behavior of a program on the exam. The point is that programs face many different situations and respond to each one, and those responses are the program's behavior. ## How to Use This on the AP Computer Science Principles Exam ### MCQ - Read short program descriptions and identify the purpose, the inputs, and the outputs separately. Questions often test whether you can keep these three ideas distinct. - Watch for event-driven setups. If a question describes a key press, mouse click, or timer triggering an action, the action runs because of an event, not because of straight-line sequential flow. - Remember that outputs usually depend on inputs or on the program's prior internal state, so trace what the input changes before picking an output. ### Create Performance Task - Use this vocabulary when you describe your program in your written responses. Be ready to state your program's purpose, identify its inputs, and identify its outputs in clear terms. - Describe behavior in terms of how a user interacts with your program, since that is how behavior is usually explained. ### Common Trap - Do not mix up a broad description of what a program does with a detailed explanation of how its statements do it. Some questions want one, some want the other, so match your answer to what is asked. ## Common Misconceptions - "Inputs only come from a user." Inputs can also come from other programs, and they can be tactile, audio, visual, or text, not just typed text. - "Output is always something on the screen." Output is any data sent from a program to a device, including sound, vibration, or visuals. It also often depends on the program's prior state, not only the current input. - "An event and an input are the same thing." An event is the action that occurs, such as a click or key press. The event supplies the input data; they are related but not identical. - "Event-driven means the code runs in order from top to bottom." In event-driven programming, statements run when they are triggered by an event, which is different from straightforward sequential flow. - "A code segment has to be a specific size." A code segment is just a group of statements that is part of a program. There is no fixed rule for where one ends and another begins. - "Purpose is optional detail." Understanding a program's purpose actually improves your ability to build it, which is why describing purpose matters on the exam and in the Create task. ## Related AP Computer Science Principles Guides - 1.4 Identifying and Correcting Errors - 1.1 Collaboration - 1.3 Program Design and Development - Big Idea 1 Overview: Creative Development

Vocabulary

The following words are mentioned explicitly in the College Board Course and Exam Description for this topic.

Term

Definition

audio output

Program output in the form of sound or music produced by a device.

code segment

A portion of a program consisting of one or more lines of code that performs a specific function.

computing innovation

A new or improved computer-based product, service, or concept that includes a program as an integral part of its function, which can be physical, nonphysical software, or a nonphysical concept.

creative expression

The use of computing innovations to create, communicate, or share ideas, art, or other forms of human expression.

event

An action associated with input data that is supplied to a program, such as a key press or mouse click.

event-driven programming

A programming approach where program statements are executed when triggered by events rather than through sequential flow of control.

execution

The process of running a program or code segment on a computer.

program

A collection of program statements that performs a specific task when run by a computer; also referred to as software.

program behavior

How a program functions during execution, often described by how a user interacts with it.

program input

Data in various forms (tactile, audio, visual, or text) that is sent to a program for processing.

program output

Any data sent from a program to a device, which can take various forms such as tactile, audio, visual, or text.

program state

The current values and conditions of a program's internal variables and data at any given time.

program statements

Individual instructions or commands that make up a program or code segment.

purpose

The intended goal or function of a computing innovation, such as solving a problem or enabling creative expression.

tactile output

Program output that can be felt or perceived through touch, such as vibrations or haptic feedback.

text output

Program output in the form of written characters or strings displayed to the user.

visual output

Program output displayed on a screen or device that can be seen, such as images, graphics, or animations.

Frequently Asked Questions

What is AP CSP 1.2 about?

AP Computer Science Principles 1.2 is about program function and purpose. You learn how to describe what a computing innovation is designed to do, how a program or code segment functions, and how inputs, outputs, events, and behavior work together.

What is the difference between program purpose and function?

A program's purpose is why it exists or what problem it solves. A program's function is what it does during execution, including how statements, inputs, outputs, and events produce behavior.

What are program inputs and outputs?

Inputs are data sent to a program for processing, such as text, clicks, images, audio, or data from another program. Outputs are data sent from the program to a device, such as text on a screen, sound, visuals, or tactile feedback.

What is an event in AP Computer Science Principles?

An event is an action associated with input data that affects program execution. Examples include a key press, mouse click, program start, timer, or another defined action that triggers program statements.

What is a code segment?

A code segment is a collection of program statements that is part of a larger program. You can describe a code segment broadly by what it does, or in detail by explaining how its statements accomplish a function.

How does this topic help with the AP CSP Create task?

The Create task asks you to describe your program's purpose, how parts of the program function, and how inputs can affect outputs. Topic 1.2 gives you the exact vocabulary for writing those explanations clearly.

Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly→ and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc
report an error
description

screenshots help us find and fix the issue faster (optional)

add screenshot

2,589 studying →