← thereisaneasierway.com

Computer Science I Study Guide Plain-language notes, practice and a glossary for students and families

This guide follows the units we cover in class: how computers represent information, how the Internet works, designing apps, the building blocks of programming, and preparing for your PBM project. Each topic explains the idea, shows an example, and ends with a quick question so you can check yourself.

Students

Read a topic, try the “Check yourself” question before opening it, then tick “I’ve got this.” Your progress is saved in this browser.

Families

No computer science background needed. Each unit ends with questions you can ask at dinner. Explaining an idea out loud is one of the best ways to learn it.

Before a test

Take the practice quiz at the end of each unit, then review the key terms for anything you missed.

The course and the PBM

What are we learning, and how is it measured?

Computer Science I (course code CS20) is a North Carolina Career and Technical Education (CTE) course in the Computer Science Principles pathway. It is a broad introduction to computing. It covers programming, but also data, networks, and how computing affects people and society. It counts toward North Carolina’s computer science graduation requirement.

What is a PBM?

Every CTE course ends with a Proof of Learning. Some courses use a multiple-choice state test. Computer Science I uses a Performance-Based Measurement (PBM) instead: rather than answering test questions, you show what you can do by completing a real task, such as designing, building, testing and explaining a program of your own.

That means the skills that matter most are practical ones: planning a program, writing code that works, finding and fixing errors, and explaining clearly how your code works and why you made the choices you did. Unit 8 walks through how to prepare.

Your teacher will give you the PBM task, the rubric and the due dates. The task sheet and rubric are the final word on what’s required, so keep them handy and check your work against them.

The five course standards

The state organizes Computer Science I into five essential standards. The percentages show roughly how much of the course each one covers.

StandardWhat it coversShare of courseUnits here
1.00 Creative developmentComputing innovations, input and output, finding errors, designing user interfaces20%3, 8
2.00 DataBinary numbers and how computers store information15%1
3.00 Algorithms and programmingVariables and lists, expressions, conditionals, procedures30%4, 8
4.00 Computing systems and networksNetwork structures, how the Internet works, how data is sent20%2
5.00 Impacts of computingBenefits and harms, legal and ethical issues, privacy15%1, 2

Official source: NC CTE course page for CS20 Computer Science I · CS20 course standards

1

Digital Information

How can numbers, words, pictures and sound all be stored as 1s and 0s?

Everything on a computer, from a text message to a movie, is stored as long strings of bits. This unit is about how we agree on what those bits mean, what gets lost when real-world information becomes digital, and who owns digital work once it is easy to copy.

Bits and representing information

A bit (short for binary digit) is the smallest piece of information a computer stores: a single 0 or 1. Physically it might be a high or low voltage, a magnetized or unmagnetized spot, or light on or off. Eight bits make a byte.

A bit pattern means nothing by itself. It only means something because the sender and receiver agree on a system. The pattern 01000001 is the number 65 if a program treats it as a number, and the letter “A” if the program treats it as text. That idea, that the same bits can represent different things depending on how they are interpreted, comes up again and again on tests.

The number of different patterns grows fast as you add bits. Each new bit doubles the possibilities, so n bits can represent 2n different values. One bit gives 2 patterns, 3 bits give 8, 8 bits give 256.

Hiding the bits behind something easier to work with, like “a letter” or “a color,” is called abstraction. Abstraction is one of the most important ideas in the course: it lets people manage complexity by ignoring details they don’t need right now.

Check yourself: how many bits do you need to give each of 50 students a different code?

6 bits. 5 bits give 25 = 32 patterns, which is not enough. 6 bits give 26 = 64, which covers all 50 with some left over.

Read more: Bit · Byte · Abstraction (computer science)

Binary numbers

We normally count in decimal (base 10). Each place is worth 10 times the place to its right: ones, tens, hundreds. Binary (base 2) works the same way, except each place is worth 2 times the place to its right: 1, 2, 4, 8, 16, 32, 64, 128.

Binary to decimal: add up the place values wherever there is a 1. For 1011: 8 + 0 + 2 + 1 = 11.

Decimal to binary: start from the biggest place value that fits and work down. For 13: 8 fits (5 left), 4 fits (1 left), 2 doesn’t fit, 1 fits. So 13 is 1101.

Try it: click the bits below to switch them on and off, or type a number from 0 to 255.

Check yourself: what is 10010 in decimal, and what is the largest number 8 bits can hold?

10010 = 16 + 2 = 18. The largest 8-bit number is 11111111 = 255. That’s one less than 256 because one of the 256 patterns is used for zero.

Read more: Binary number · Positional notation

Overflow and roundoff errors

Computers store numbers using a fixed number of bits, and that causes two kinds of errors.

An overflow error happens when a number is too big for the bits available. Picture a car odometer that only has six digits: after 999,999 miles it rolls back to 000,000. With 4 bits, the biggest number is 15, so 15 + 1 “rolls over” to 0.

A roundoff error happens because some fractions can’t be stored exactly in binary, just as 1/3 can’t be written exactly in decimal (0.3333…). The computer stores the closest value it can. In JavaScript, 0.1 + 0.2 gives 0.30000000000000004. Tiny errors like this can add up over many calculations.

JavaScriptconsole.log(0.1 + 0.2);          // 0.30000000000000004
console.log(0.1 + 0.2 === 0.3);  // false
Check yourself: a game stores scores in 8 bits. A player’s score is 250 and they earn 10 more points. What goes wrong?

An overflow error. 260 is bigger than 255, the largest 8-bit number, so the score can’t be stored correctly. It wraps around to a small number instead.

Read more: Integer overflow · Round-off error · Floating-point arithmetic

Representing text

To store text, every character gets a number, and the number is stored in binary. ASCII is an early standard that uses 7 bits for 128 characters: English letters, digits, punctuation and some control codes. In ASCII, “A” is 65 and “a” is 97.

128 characters is nowhere near enough for the world’s languages, so modern systems use Unicode, which has codes for well over 100,000 characters, including Chinese, Arabic, Cherokee and emoji. The most common way to store Unicode, UTF-8, uses 1 to 4 bytes per character and matches ASCII for the first 128 characters.

Check yourself: why can’t a system that uses only 7 bits per character display emoji?

7 bits allow only 27 = 128 different codes, and those are already used for English letters, digits and symbols. There are no patterns left for anything else.

Read more: ASCII · Unicode · UTF-8

Images, sound and analog data

A digital image is a grid of pixels (picture elements). In a black-and-white image, each pixel can be one bit: 0 for black, 1 for white. Color images usually use the RGB model, where each pixel stores how much red, green and blue light to mix. With 8 bits per color, each pixel uses 24 bits, which allows 224 (about 16.7 million) colors.

The file size of an uncompressed image is width × height × bits per pixel. Files also contain metadata: data about the data, such as the image size, the date it was taken or the camera’s location.

The real world is analog: sound waves and light change smoothly and continuously. To make it digital, a device takes samples, measuring the value at regular intervals and storing each measurement in bits. More samples and more bits per sample get closer to the original, but a digital copy is always an approximation, and it takes more storage the more accurate it is.

Check yourself: how many bytes does an uncompressed 100 × 100 pixel image use with 24-bit color?

100 × 100 = 10,000 pixels. 10,000 × 24 bits = 240,000 bits. Divide by 8 to get 30,000 bytes (about 30 KB).

Read more: Pixel · RGB color model · Sampling · Metadata

Compression: lossless and lossy

Compression reduces the number of bits needed to store or send data. There are two kinds, and choosing between them is a common test question.

Lossless compression lets you rebuild the original exactly. It works by finding patterns and repetition. A simple version is run-length encoding: WWWWWWBBB becomes 6W3B. ZIP files and PNG images are lossless. Use it when every bit matters: documents, code, spreadsheets, medical scans.

Lossy compression throws away details people are unlikely to notice, so files get much smaller, but the original can’t be fully restored. JPEG photos, MP3 music and streaming video are lossy. Use it when small size matters more than perfect quality.

How much a file shrinks depends on the data. Data with lots of repetition compresses well; random-looking data barely compresses at all.

Check yourself: a hospital sends X-ray images to a specialist. Lossy or lossless, and why?

Lossless. A doctor needs every detail, and lossy compression could remove something that matters for a diagnosis. Smaller file size isn’t worth the risk.

Read more: Data compression · Lossless compression · Lossy compression · Run-length encoding

Intellectual property and sharing

Digital files can be copied perfectly and instantly, which makes questions about ownership more important. Intellectual property is creative work that belongs to whoever made it: writing, music, art, photos, code.

Copyright protects a work automatically as soon as it is created; you don’t have to register anything. Others need permission to copy or share it, with some exceptions such as fair use, which in the United States allows limited use for purposes like commentary, criticism and teaching.

Creators can choose to share more openly. Creative Commons licenses let a creator pick the rules: for example, “use it if you credit me” (BY), “not for commercial use” (NC), or “share your version under the same terms” (SA). Open-source software publishes its code so anyone can use and improve it. Works in the public domain have no copyright at all, usually because it has expired.

Check yourself: you find a photo licensed CC BY-NC. Can you use it on a poster for a school club event?

Yes, as long as you credit the photographer (BY) and the poster isn’t for a commercial purpose (NC). A free school club event is not commercial.

Read more: Copyright · Creative Commons license · Open-source software · Public domain

Impacts of digital information

Turning everything into data has big benefits: information can be searched, shared and preserved cheaply, and people anywhere can learn and create. It also creates new problems. Digital information can be permanent and hard to delete, copied without permission, collected without people realizing it, or altered convincingly, as with edited photos and deepfakes.

Impact questions usually ask you to identify a benefit and a harm of a computing innovation, or to notice that the same technology can help some people while harming others. There is rarely a single “right” side; the skill is reasoning about who is affected and how.

Check yourself: name one benefit and one harm of phone photos automatically including location metadata.

Benefit: you can sort and find photos by place, or remember where something was taken. Harm: sharing a photo online can reveal where you live or where you are right now.

For families: ask your student

  • “What’s 13 in binary? How did you figure it out?”
  • “Why does a photo from your phone look worse after you send it through some apps?” (lossy compression)
  • “Can you use any picture you find online for a project? What would you check first?”
2

The Internet

How does a message get from your phone to a server across the world, even when parts of the network fail?

The Internet isn’t one thing owned by one company. It is millions of separate networks that agree to follow the same rules. This unit covers those rules, how data actually travels, and who does and doesn’t have access.

Networks, paths and bandwidth

A computing device is any physical thing that can run a program: a laptop, phone, server, router or smart sensor. A computing system is a group of devices and programs working together. A computer network is a group of connected devices that can send and receive data.

A path is the sequence of directly connected devices that data travels through from sender to receiver. Routing is the process of finding that path.

Bandwidth is the maximum amount of data a connection can send in a fixed amount of time, usually measured in bits per second (for example, 100 megabits per second). Latency is the delay between sending data and it arriving. A connection can have high bandwidth but still feel slow if latency is high.

Check yourself: what’s the difference between bandwidth and latency? Use a highway as an analogy.

Bandwidth is how many lanes the highway has: how much traffic can move at once. Latency is how long one car takes to get from one end to the other.

Read more: Computer network · Bandwidth (computing) · Latency

The Internet, protocols and IP addresses

The Internet is a network of networks. Its parts are owned by different companies, schools and governments, but they can all communicate because they follow the same protocols: agreed-upon rules for how data is formatted and sent. Internet protocols are open, meaning anyone can read them and build devices that follow them without paying anyone. That openness is a big reason the Internet grew so quickly.

Every device on the Internet needs an IP address so data can be delivered to it, like a mailing address. IPv4 addresses are 32 bits long, which allows about 4.3 billion addresses. That turned out to be too few for every phone, laptop and smart device, so IPv6 uses 128 bits, which allows about 3.4 × 1038 addresses: effectively unlimited.

Check yourself: why does it matter that Internet protocols are open?

Anyone can build hardware or software that connects to the Internet without permission or fees. That lets the network keep growing, and devices from different manufacturers all work together.

Read more: Internet · Communication protocol · IP address · IPv6

Routing, redundancy and fault tolerance

Routers pass data along toward its destination. There usually isn’t one fixed path; each router chooses where to send data next based on current conditions, so two messages between the same devices may take different routes.

The Internet was designed with redundancy: extra connections, so there is more than one path between devices. That makes it fault tolerant: if a router fails or a cable is cut, data can be routed around the problem. Redundancy costs more, but it makes the system much more reliable.

Test questions often show a small network diagram and ask how many connections could fail before two devices can no longer communicate. Look for every possible path between them, then find the connections that all paths depend on.

DiagramA ── B ── D
│         │
└── C ────┘

A can reach D through B or through C.
If the B–D connection fails, A still reaches D through C.
The network is fault tolerant for that single failure.
Check yourself: in the diagram, what is the smallest number of connections that could fail and leave A unable to reach D?

Two. One on each path, for example A–B and C–D. Any single failure still leaves the other path working.

Read more: Routing · Router · Fault tolerance

Packets, TCP and UDP

Large pieces of data aren’t sent all at once. They are split into small chunks called packets. Each packet carries part of the data plus a header with information like where it came from, where it’s going, and its place in the sequence. Packets travel independently, so they can take different paths and arrive out of order, or occasionally not at all.

TCP (Transmission Control Protocol) handles this: the receiver uses the sequence numbers to put packets back in order and asks the sender to resend any that went missing. TCP is used when everything must arrive correctly: web pages, email, file downloads.

UDP (User Datagram Protocol) sends packets without checking that they arrived or putting them in order. It’s faster, and it’s used when speed matters more than perfection: video calls, live streams, online games. A lost packet might cause a brief glitch, but waiting for a resend would be worse.

Check yourself: why might a video call use UDP instead of TCP?

In a live conversation, a late packet is useless; the moment has passed. It’s better to skip it and keep going than to pause everything while it’s resent.

Read more: Network packet · Packet switching · TCP · UDP

DNS, HTTP and the World Wide Web

The Internet and the World Wide Web are not the same thing. The Internet is the network itself: the devices, connections and protocols. The Web is one service that runs on the Internet: a system of linked pages and apps you reach with a browser. Email, video calls and online games also use the Internet without being part of the Web.

People use names like example.com, but computers need IP addresses. The Domain Name System (DNS) is like the Internet’s phone book: it translates domain names into IP addresses. DNS is spread across many servers in a hierarchy, so no single server has to know every address.

Once your browser knows the address, it uses HTTP (Hypertext Transfer Protocol) to request a page, and the server sends a response back. HTTPS is the same thing with encryption, so people in between can’t read or change the data.

Check yourself: put these in order for visiting a website: HTTP request, DNS lookup, page displayed.

DNS lookup (find the IP address) → HTTP request (ask that server for the page) → page displayed (browser shows the response).

Read more: World Wide Web · Domain Name System · HTTP · HTTPS

Scalability and the digital divide

Scalability is a system’s ability to keep working well as it grows. The Internet’s open protocols and lack of central control let it scale from a few research computers to billions of devices.

The digital divide is the gap between people who have reliable access to computing and the Internet and people who don’t. It can depend on where someone lives (rural areas often have fewer options), income, age, disability, or the country they live in. It affects access to school, jobs, healthcare and government services. Individuals, organizations and governments can all make it smaller or larger, for example by funding broadband, providing devices, or designing accessible websites.

Related debates include net neutrality (whether Internet providers should treat all traffic equally) and censorship (governments restricting what people can access).

Check yourself: a school moves all homework online. Who might this disadvantage, and what could reduce the harm?

Students without home Internet or a personal device. Options include lending laptops or hotspots, keeping the library or computer lab open after school, or allowing work to be downloaded and done offline.

Read more: Scalability · Digital divide · Net neutrality

For families: ask your student

  • “What actually happens between typing a website name and seeing the page?”
  • “If a cable under the ocean gets cut, why doesn’t the whole Internet go down?”
  • “Who in our town might not have good Internet access? What could help?”
3

Intro to App Design

How do teams design and build apps that people actually want to use?

Before writing much code, good developers figure out who they’re building for and test ideas quickly. This unit introduces the design process, user interfaces, event-driven programming and the habits of working on a team.

The design process

Software is rarely built right the first time. Developers use a cycle: investigate what users need, design a solution, build a prototype, test it with real people, and reflect on what to change, then go around again. Repeating that cycle to improve the product is called iterative development. Building and testing the program in small working pieces, one at a time, is incremental development. Most real projects use both.

User-centered design means making decisions based on the people who will actually use the app. Developers learn about users through surveys, interviews, observation and testing. A prototype is an early, rough version (even a paper sketch) used to test ideas before spending time on code.

Check yourself: during testing, three users can’t find the “Save” button. What should the team do next?

Go back to the design step: change where the button is or how it looks, then test again with users to see if the change worked. That loop is iterative development.

Read more: Iterative design · User-centered design · Software prototyping

User interfaces and event-driven programming

The user interface (UI) is everything the user sees and interacts with: buttons, text boxes, labels, dropdowns, images and screens. In App Lab, each UI element has an ID, a unique name the code uses to refer to it.

Most apps are event-driven. Instead of running from top to bottom and stopping, the program waits for events (a click, a key press, text being typed) and runs a specific piece of code, an event handler, when each one happens.

JavaScript (App Lab)onEvent("greetButton", "click", function() {
  var name = getText("nameInput");
  setText("messageLabel", "Hello, " + name + "!");
});

Here, nothing happens until the user clicks the element with the ID greetButton. Then the program reads the text box, builds a message, and shows it in a label.

Check yourself: the code above runs, but clicking the button does nothing. The button’s ID in Design mode is greetBtn. What’s wrong?

The ID in the code ("greetButton") doesn’t match the element’s actual ID (greetBtn), so the event handler is attached to nothing. IDs must match exactly, including capitalization.

Read more: Event-driven programming · User interface design

Inputs and outputs

Input is data sent to a program: text a user types, a click, a sensor reading, a file, or data from another program. Output is anything a program produces: text on screen, an image, a sound, a vibration, or data sent somewhere else.

A program’s behavior is how it responds to different inputs. Describing a program usually means describing what goes in, what happens, and what comes out. You’ll need exactly this skill for your PBM project, where you describe what your program takes in and gives back.

Check yourself: name the input and output of a step-counter app.

Input: motion readings from the phone’s accelerometer (a sensor). Output: the step count shown on screen, and possibly a notification when you hit a goal.

Collaboration and pair programming

In pair programming, two people share one computer. The driver types the code; the navigator reviews each line, thinks ahead and catches mistakes. They switch roles often.

Teams with different backgrounds and perspectives build better software: people notice different problems and think of different users, which helps avoid bias in the final product. Good collaboration takes communication, giving and receiving useful feedback, and resolving disagreements respectfully.

Check yourself: why might a team that includes people of different ages catch problems a team of only teenagers would miss?

Different people have different needs and habits. An older user might struggle with tiny text or unclear icons that a teenager wouldn’t notice. Diverse teams spot these problems before users do.

Read more: Pair programming

Debugging and testing

Finding and fixing errors is called debugging. Know these three kinds of errors:

A syntax error breaks the rules of the language, like a missing parenthesis or misspelled command, so the program won’t run. A runtime error happens while the program is running, like trying to use an element that doesn’t exist. A logic error is the sneakiest: the program runs but gives the wrong result, like averaging by dividing by the wrong number.

Useful strategies: read the error message carefully; add console.log() to see what values your variables actually hold; trace the code by hand; explain your code line by line to someone else (or a rubber duck); and change one thing at a time.

Testing means running the program with chosen inputs and comparing the actual output to the expected output. Good tests include normal values, edge cases (like 0, empty text, or the largest allowed value), and invalid input.

Check yourself: a grade calculator runs without errors but shows 85 for test scores of 80 and 90 and 100. What kind of error is this?

A logic error. The correct average is 90; the program runs but calculates the wrong answer (perhaps dividing by the wrong count or adding the wrong values).

Read more: Debugging · Software bug · Rubber duck debugging

Comments and documentation

Comments are notes in code that the computer ignores. They explain what a section of code does and why, which helps teammates and your future self. In JavaScript, a line starting with // is a comment.

Documentation also means giving credit. If you use code, images or ideas from someone else, including code from an AI tool, say so in a comment with where it came from. This matters for your PBM project, where uncredited code counts as plagiarism.

JavaScript// Shows a greeting using the name the user typed
onEvent("greetButton", "click", function() {
  setText("messageLabel", "Hello, " + getText("nameInput") + "!");
});

// Background image: "Sunset" by J. Rivera, CC BY 4.0

For families: ask your student

  • “Show me an app you’re building. What did you change after someone else tried it?”
  • “What’s the difference between a bug that crashes the app and one that gives the wrong answer?”
  • “In pair programming, which role do you prefer, and why?”
4

Variables, Conditionals, and Functions

How do programs remember things, make decisions and stay organized?

These are the core building blocks of every program. In class you write them in JavaScript in App Lab. Tests, worksheets and the Code.org reference sheet often show code in a simple pseudocode instead, so every example here is shown both ways.

Reading pseudocode: ← means “store this value in the variable.” = means “is equal to” (a comparison, not storing). DISPLAY() shows output. Lists start at index 1 in pseudocode, but at 0 in JavaScript.

Variables and assignment

A variable is a named place to store a value so the program can use it later. Giving a variable a value is called assignment. A variable holds only one value at a time, and it always holds the most recent value assigned to it.

Values have data types: numbers (42), strings of text ("hello"), Booleans (true or false), and later, lists. Use names that say what the value means, like score or userName, not x.

Pseudocodea ← 1
b ← a
a ← 2
DISPLAY(b)
JavaScriptvar a = 1;
var b = a;
a = 2;
console.log(b);
Check yourself: what does the code above display?

1. When b ← a runs, b gets a copy of the value 1. Changing a afterwards doesn’t change b. Students often guess 2, and this exact trick appears on tests.

Read more: Variable (computer science) · Assignment · Data type

Expressions, MOD and strings

An expression is anything that produces a value, like price * 2 or score + 10. The usual order of operations applies: multiplication and division before addition and subtraction, and parentheses first.

MOD gives the remainder after division. 17 MOD 5 is 2, because 17 ÷ 5 is 3 with 2 left over. In JavaScript it’s written %. MOD is handy for checking if a number is even (n MOD 2 = 0) or for wrapping around, like hours on a clock. MOD has the same precedence as * and /.

Joining strings is called concatenation. In JavaScript you use +. Watch out: + adds numbers but joins strings, so "5" + 3 is "53", not 8. That’s why App Lab has both getText() (returns a string) and getNumber() (returns a number).

JavaScriptconsole.log(17 % 5);        // 2
console.log("5" + 3);       // "53"  (string joined)
console.log(5 + 3);         // 8     (numbers added)
var name = "Ava";
console.log("Hi, " + name); // "Hi, Ava"
Check yourself: what is (4 + 8) MOD 5 * 2?

Parentheses first: 12. Then MOD and * have the same precedence, so go left to right: 12 MOD 5 = 2, then 2 * 2 = 4.

Read more: Modulo · Concatenation · String

Booleans and logic

A Boolean expression evaluates to true or false. Relational operators compare values: =, ≠, >, <, ≥, ≤ in pseudocode (in JavaScript: ==, !=, >, <, >=, <=).

Logical operators combine Booleans. AND is true only if both sides are true. OR is true if at least one side is true. NOT flips true and false. In JavaScript they’re written &&, || and !.

ABA AND BA OR BNOT A
truetruetruetruefalse
truefalsefalsetruefalse
falsetruefalsetruetrue
falsefalsefalsefalsetrue
Check yourself: write a condition that is true when age is a teenager (13 through 19).

(age ≥ 13) AND (age ≤ 19). Both must be true. Using OR would be true for every age, since every number is either at least 13 or at most 19.

Read more: Boolean data type · Relational operator · Truth table

Conditionals: making decisions

Programs normally run one statement after another; that’s sequencing. A conditional (if-statement) changes that flow: it runs different code depending on whether a Boolean expression is true or false. This is called selection.

PseudocodeIF (score ≥ 90)
{
   DISPLAY("A")
}
ELSE
{
   IF (score ≥ 80)
   {
      DISPLAY("B")
   }
   ELSE
   {
      DISPLAY("Keep going")
   }
}
JavaScriptif (score >= 90) {
  console.log("A");
} else if (score >= 80) {
  console.log("B");
} else {
  console.log("Keep going");
}

A conditional inside another conditional is a nested conditional. Order matters: the program checks conditions from the top and runs the first one that is true, then skips the rest.

Check yourself: if the first condition were score ≥ 80 and the second were score ≥ 90, what would a score of 95 display?

“B”. 95 ≥ 80 is true, so the first branch runs and the rest are skipped. The “A” branch can never be reached. That’s a logic error caused by ordering.

Read more: Conditional (computer programming) · Control flow

Functions and procedural abstraction

A function (pseudocode calls it a procedure) is a named group of instructions. You define it once, then call it by name whenever you need it. Functions remove repeated code, make programs easier to read, and let you fix a bug in one place instead of many.

Using a function without needing to know how it works inside is called procedural abstraction. You call setText() constantly without knowing how App Lab draws text on the screen.

PseudocodePROCEDURE resetGame()
{
   score ← 0
   lives ← 3
   DISPLAY("New game!")
}

resetGame()
JavaScriptfunction resetGame() {
  score = 0;
  lives = 3;
  setText("statusLabel", "New game!");
}

onEvent("restartButton", "click", function() {
  resetGame();
});

Later you’ll give functions parameters: inputs that change what the function does each time it’s called (like greet("Ava") versus greet("Leo")). A procedure with a parameter makes a strong PBM project, so it’s worth getting comfortable with them early.

Check yourself: a game resets the score and lives in four different places in the code. Why put that in a function?

If the starting values change (say, 5 lives instead of 3), you change one line instead of four, and you can’t accidentally miss one. The code is also shorter and easier to read.

Read more: Function (computer programming) · Parameter

Tracing code by hand

Many test questions show code and ask what it displays. The reliable method is a trace table: write each variable as a column and update it line by line, exactly as the computer would. Don’t guess from what the code looks like it should do.

Pseudocodex ← 5
y ← x * 2
IF (y MOD 3 = 1)
{
   x ← x + y
}
y ← y - x
DISPLAY(x)
DISPLAY(y)
LinexyNote
x ← 55–
y ← x * 2510
IF (y MOD 3 = 1)51010 MOD 3 is 1, so true
x ← x + y1510
y ← y - x15−5
Check yourself: what would display if the first line were x ← 4?

y becomes 8. 8 MOD 3 is 2, so the IF is false and x stays 4. Then y ← 8 − 4 = 4. It displays 4 and 4.

For families: ask your student

  • “If I set a = 1, then b = a, then change a to 2, what is b? Why do people get that wrong?”
  • “Show me an if-statement in your app. What decision is it making?”
  • “What’s a function, and why not just copy and paste the code instead?”
8

PBM Project Prep

How do you plan, build and explain a program that is entirely your own?

Your PBM (Performance-Based Measurement) is your chance to show everything you’ve learned by building something you care about. Most of the credit comes from meeting the requirements and being able to explain your own code, not from making something fancy. A simple program that meets every requirement beats an impressive one that misses some.

Understanding the task

Before writing any code, read the PBM task sheet and rubric your teacher gives you. Highlight every place it says “must,” “include,” or “explain.” Those are your requirements. Then turn them into a checklist you can tick off as you go.

Ask yourself three questions: What do I have to build? What do I have to turn in? (code, screenshots, a video, written answers, a presentation?) How will it be scored?

The task sheet and rubric are the final word. This page gives general advice that fits most programming projects. If anything here differs from what your teacher hands out, follow the task sheet.

What a strong program shows

A PBM project is a chance to show the course standards in action. A program that includes everything below demonstrates most of the programming skills in Computer Science I. Use it alongside your rubric.

SkillWhat it looks like in your programStandard
A clear user interfaceScreens, buttons and labels that a new user can figure out without help.1.04
Input and outputThe user types, clicks or chooses something, and the program responds with text, images or sound based on that input.1.02
Variables and a listVariables that store changing values, and a list (array) that holds several values your program actually uses.3.01
ExpressionsCalculations, comparisons or joined strings that produce new values.3.03
ConditionalsAt least one if / else that makes the program behave differently in different situations.3.04
A procedure you wroteA function with a name and a parameter, called from somewhere in your program.3.05
Testing and debuggingEvidence that you tried different inputs, found bugs and fixed them.1.03

Here is a small example that uses a list, a loop, a conditional and a procedure with a parameter. It’s only an illustration; your program should be your own idea.

Pseudocodescores ← [88, 72, 95, 61, 79]

PROCEDURE countAtOrAbove(cutoff)
{
   count ← 0
   FOR EACH score IN scores
   {
      IF (score ≥ cutoff)
      {
         count ← count + 1
      }
   }
   RETURN(count)
}

cutoff ← INPUT()
DISPLAY(countAtOrAbove(cutoff))
JavaScript (App Lab)var scores = [88, 72, 95, 61, 79];

function countAtOrAbove(cutoff) {
  var count = 0;
  for (var i = 0; i < scores.length; i++) {
    if (scores[i] >= cutoff) {
      count = count + 1;
    }
  }
  return count;
}

onEvent("checkButton", "click", function() {
  var cutoff = getNumber("cutoffInput");
  setText("resultLabel", countAtOrAbove(cutoff) + " scores at or above " + cutoff);
});
Check yourself: point to the sequencing, selection and iteration in countAtOrAbove.

Sequencing: set count to 0, then loop, then return, in that order. Selection: the IF (score ≥ cutoff). Iteration: the FOR EACH loop through the list. The parameter cutoff changes the result each time the procedure is called.

Explaining your code

Being able to explain your program in your own words is just as important as building it. Whether your PBM asks for written answers, a presentation or a conversation with your teacher, be ready to explain:

TopicBe ready to explain
PurposeWho your program is for, what problem it solves, and what its inputs and outputs are.
How it worksStep by step, what your procedure does, including what its conditions and loops do.
TestingInputs you tested with, what output you expected, and a bug you found and how you fixed it.
Design choicesWhat your list stores and why it helps, and how your procedure makes the program easier to build or change.

Practice questions like these with your own code (written out, without looking at your program):

Describe two different calls to your procedure with different arguments that would make different parts of the code run. What would happen in each case?

Explain in enough detail that a classmate could recreate it how the loop in your procedure works and when it stops.

Pick one condition in your program. Describe an input where it is true, one where it is false, and the result of each.

How would your program be written differently if you couldn’t use a list? Why would that be harder?

If someone removed a specific line from your procedure, what would go wrong, and how would you find it?

Check yourself: using the example above, how does the scores list make the program simpler?

Without a list, each score would need its own variable (score1, score2…) and its own if-statement. Adding a score would mean writing more code. With a list, one loop handles any number of scores, and adding a score just means adding an item.

Collaboration, credit and AI

Your teacher will tell you what parts of the PBM, if any, you may work on with a partner. Anything you explain or write about your program must be in your own words.

Credit any code, images or media you didn’t create in a comment in your program code. That includes code generated by AI tools. Follow your teacher’s rules on AI, and only include code you fully understand: you’ll need to explain it yourself.

Planning tips

Pick something small that you care about. A quiz, a calculator, a tracker, a simple game or a recommendation tool all work. Interest keeps you going; small scope means you finish.

Plan your data and procedure first. Decide what your list holds and what your procedure will do with it before designing screens.

Choose code you can explain easily. A clear loop with one if-statement is easier to explain than something clever and complicated.

Test as you go. Keep notes on bugs you found and fixed. They make great material when you explain your testing.

Check the rubric before you turn it in. Go line by line and point to where your project meets each item.

For families: ask your student

  • “What is your PBM project going to do, and who is it for?”
  • “Where’s your list? What would happen if you didn’t have it?”
  • “Explain your procedure to me as if I were the computer. What happens step by step?”
  • “Can I see the rubric? Which parts have you finished?”

Glossary

Every key term in one place.

More free practice

Khan Academy: Computer Science Principles has free videos and practice questions on the same topics (it’s written for the AP course, but the ideas are the same). Python Tutor lets you step through JavaScript or Python one line at a time and watch variables change. App Lab is where you can keep building outside class.