📚

All Subjects

 > 

⌨️ 

AP Comp Sci P

 > 

🕹

Big Idea 1: Creative Development

Program Function and Purpose

3 min readnovember 16, 2020

minnachow

Minna Chow

caroline49234295

Caroline Koffke


AP Computer Science Principles ⌨️

Bookmarked 2.3k • 69 resources
See Units

Programs and Code Segments... with Cake

program is a collection of instructions that a computing device executes, or carries out. It's like a recipe that a computer follows. Programs run on inputs and outputs and exhibit specific behaviors.
Within a program, you have code segments. A code segment is a smaller collection of statements that are part of a program. It's like the part of a cake recipe that tells you how to make the frosting.
Each code segment is made up of statements, or individual instructions. It's like a line in your recipe that says, "Crack three eggs into the bowl."
So, a computer program is made up of code segments, which are made up of statements.
Programs are also known as software or applications.

Describing Programs

A program can be described in a broad sense by what it does.
My adding program lets the user add two numbers of their choice.
You can also go more in depth by describing how the program's statements accomplish this goal.
My adding program asks the user to input two numbers, then adds them together and displays the final sum.

Program Inputs

Programs run on inputs, which are pieces of data that a computer takes in and processes. These inputs can be directly submitted by the user or they can come from other programs.
Inputs can be...
  • Auditory, such as spoken words or music notes
  • Visual, such as photos or videos
  • Tactile, such as strokes of a keyboard
  • Text, such as words or numbers
Program Events
In order for a program to receive inputs, an event needs to happen. An event is simply an action that gives a program data to respond to.
For example, pressing the left arrow causes a video game's program to make an avatar go left when before this it was running right. Pressing the key is the event in this case.
Events cause programs to change how they're running. In the previous example, pressing the left key caused a change. If the arrow hadn't been pressed, the avatar would've kept running right.
Examples of common events:
  • clicking a button
  • moving a mouse
  • starting a program
  • pressing a key
  • running down a timer
A lot of modern software is event-driven, which means that it's designed to respond to events in order to run. Let's go back to our adding machine example. You start the program, an event, and press the enter key to input numbers into the program, another event. The program is designed to respond based on these events, so it's considered event driven.
On a larger scale, your phone's software is event-driven as a whole because it responds primarily to your taps, clicks and swipes.

Program Outputs

If program inputs are data that a computer takes in, program outputs are the data that the computer returns. They can be in any of the formats that inputs can be. In the adding machine example, the program output is the final sum that the program returns.

Program Behavior

When you run a program, you expect it to perform in a certain way. This is known as a program's behavior. Usually, program behaviors are defined by how a program will respond to a user interacting with it.
It's important to think of what behavior you want your program to have before you code it. In order to figure that out, you'll need to know what the purpose of your program is.

Computing Innovations and Purpose

The purpose of a computing innovation is what it's designed to do.
Solving problems is one of the major purposes of computing innovations. For example, text messaging and video-chat platforms solve the problem of needing to communicate quickly over long distances. A computing innovation can also be a form of creative expression, such as making a video game.
Having a clear purpose for the computing innovation you want to make is like having a good thesis for an essay. It focuses your work and establishes what your goals are. In short, it strengthens your ability to develop your creation.
So, how do you develop a clear purpose for your program? The answer to that lies in the development process.

Was this guide helpful?

Join us on Discord
Thousands of students are studying with us for the AP Computer Science Principles exam.
join now
Hours Logo
Studying with Hours = the ultimate focus mode
Start a free study session
🔍 Are you ready for college apps?
Take this quiz and find out!
Start Quiz
Browse Study Guides By Unit
🕹Big Idea 1: Creative Development
⚙️Big Idea 2: Data
📱Big Idea 3: Algorithms and Programming
🖥Big Idea 4: Computer Systems and Networks
⌨️Big Idea 5: Impact of Computing
✏️Blogs
📝Exam Prep
Join us on Discord
Thousands of students are studying with us for the AP Computer Science Principles exam.
join now
💪🏽 Are you ready for the AP CSP exam?
Take this quiz for a progress check on what you’ve learned this year and get a personalized study plan to grab that 5!
START QUIZ
Play this on HyperTyper
Practice your typing skills while reading Program Function and Purpose
Start Game