APrep Open the app

AP Computer Science Principles · Unit 1: Creative Development

1.2 Program Function and Purpose

Programs solve problems and express creativity

Programs are written to accomplish tasks, express creativity, satisfy personal curiosity, or create new knowledge. A single program can have multiple purposes at once — for example, an app that entertains users while also collecting useful data. Understanding a program's purpose helps guide its design and function.

Correct vs. incorrect behavior

A program's function is what it actually does when run. Program correctness means the program behaves as intended for all expected inputs. Testing with different input values helps determine if a program runs correctly or produces unexpected/incorrect results, revealing bugs that need fixing.

Documentation matters

Programmers use comments and other documentation to explain a program's purpose and how pieces of code work. Good documentation helps others (and your future self) understand, use, and collaborate on the program, especially in collaborative development where multiple people work on the same code.

Key terms

Purpose of programs
Programs can be written to solve problems, express creativity, satisfy curiosity, or create new knowledge — sometimes serving multiple purposes at once.
Program function
What a program actually does when it is run.
Program correctness
Whether a program behaves as intended across all expected inputs.
Documentation
Comments and notes that explain a program's purpose and how its code works, aiding understanding and collaboration.
Collaborative development
A process where multiple programmers work together on the same program, often relying on documentation to coordinate.

Try an AP-style question

What is an event-driven program?

  1. One that only runs at a scheduled time
  2. One that never accepts user input
  3. One that runs code in response to events like clicks
  4. One that runs all code once from top to bottom
Show the answer

C. Event handlers.

Practice 8 AP-style questions with instant explanations, flashcards and spaced review.

Study 1.2 free in APrep