CS I · Mon Oct 26 · 13.1 · We Do

Before the bell

You are responsible for all of this before the end of class.

  1. The discussion form in the I Do deck. All three sections. If you are here, this should be done.
  2. Your classwork. This form on the right. Section 1 before the exit ticket pops up; Section 2 past the floor.
  3. Today's Bench Basics activity: Store It. It opens later in class and lives on slide 4 of this deck.
  4. The exit ticket. It opens 15 minutes before the bell and lives on the last slide of this deck.
Classwork

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

Store It: What = Means to a Computer

This reading explains what the symbol = means in a computer program and then works through one trace table, one row at a time.

Storing a Value

In mathematics class, the equation x = x + 1 can never be true, because no number is equal to one more than itself. In a computer program, the same symbol is an instruction to store a value. The computer first calculates the right side, and then it places the result in the box named on the left, replacing the previous value. A box can hold only one value at a time.

Before Java, this course writes a store step with an arrow, as in x ← 4, because the arrow points from the value toward the box that receives it. The AP Computer Science Principles reference sheet uses the same arrow and explains that the step evaluates the expression and then stores a copy of the result. Java writes the same step with =, and Oracle's Java tutorial explains that = places the value from its right side into the variable on its left. In the Java example below, line 2 stores 5 in x.

1int x = 4;
2x = x + 1;
3System.out.println(x);
5

One Trace Table, Row by Row

A trace table has one row for each step and one column for each box.

11  x ← 4
22  y ← x + 1
33  x ← x + y
44  y ← y * 2
Line   x   y
1      4   -
2      4   5
3      9   5
4      9   10

Row 1 stores 4 in x, and y is still empty, so its cell shows a dash. Row 2 calculates x + 1, which is 4 + 1, and stores 5 in y. Row 3 calculates x + y, which is 4 + 5, and stores 9 in x, so the previous value of x is gone. Row 4 multiplies y by 2 and stores 10 in y. The final values are 9 in x and 10 in y.

Two Mistakes Bench Basics Catches

The first mistake is using an old value after it was replaced, such as still using 4 for x after row 3. A student who keeps the old value of x in a later step will get every row that uses x wrong after that, even when each calculation is done correctly. The second mistake is reading = as "is equal to." A student who reads row 3 as a claim that x equals x + y will decide that the step is impossible, when it actually tells the computer to calculate a value and store it.

Sources: College Board, AP Computer Science Principles Exam Reference Information (2025); Oracle, Assignment, Arithmetic, and Unary Operators (n.d.); Code.org, CS Principles 2020–2021 Unit 4 Standards (n.d.).

Input, Processing and Output

This section reviews what the class has learned about AI and then explains how a model is packaged into a tool that people can use.

What the Class Has Learned About AI

This semester, the class has spent a lot of time understanding AI. First, the class learned that a language model is two files: a large parameter file of numbers and a smaller program called a runtime. Next, the class learned that a model generates new text one token at a time and does not retrieve a stored answer. After that, the class learned that the models in this course run on a server, not on the Chromebook, because the class models need far more memory than a Chromebook has. Last week, the class listed the parts it takes to turn a model into a tool: an interface, a request, a server, a system prompt, the model and a response. This lesson turns to how AI gets packaged and made available to people.

Three Parts of Every Tool

Every computer tool can be described in three parts. Input is the data that goes into a tool. For example, when a person presses the keys for 12 + 30 on a calculator, the numbers and the plus sign are the input. Processing is the work done on the input. In a calculator, the processing is the arithmetic that adds 12 and 30. Output is what comes out of the tool after the processing, and in the calculator the output is 42 on the display. An OpenStax computer science textbook describes the same pattern in a computer. Input devices take input from a user, the processor carries out the program's instructions, and output devices turn the results into a form such as a picture on the screen.

Input, Processing and Output in an AI Tool

A tool that uses a model has the same three parts, and its input is the text the user types. The directions printed on a tool's page are not input, because input is what the user gives the tool. The processing is done by the model, and in this course's tools the model runs on a server. The model predicts the answer one token at a time from its parameters, and the output is the generated text that the page displays.

The Name That Element page of MuggsAI is one example from this class. A student types a description of something on a screen, such as a box that pops up over a page, and presses the button labeled Name it. That description is the input. Next, the class site's server places a system prompt before the student's text and sends both to a Mistral model. The system prompt does not count as input, because the builder writes it ahead of time and the server sends it with the input on every request. Then the model does the processing, and the element name it generates is the output. The page that shows the answer does not do the processing, since it only displays what came back. The description the student typed is not output either, even though it stays on the screen. Figure 1 shows the three parts in order, with the system prompt and the input traveling together into the model.

The Programs Around the Model

Apart from the model and the system prompt, every part of the tool is an ordinary program. These programs include the page in the browser, the server code that receives the request, adds the system prompt and calls the model, and the code that carries the answer back to the page. Mistral's documentation describes what the server code has to build. Each request names the model to use and carries a list of messages, and each message has a role, such as system or user. The response carries the generated message, which the server code reads and passes back to the page.

People write these programs in programming languages. A programmer writes the instructions as source code in plain text files, and the computer runs the finished program. Packaging AI is mostly this work. The model does the processing, while programs written by people carry the input in and the output out. Two tools can use the same model and still behave differently, because each tool has its own system prompt.

Java is one of the programming languages used to write programs that run on servers. The rest of this week is about Java: where it came from, why it is used, where it runs and why it matters for AP Computer Science A.

Summary

Every tool has input, processing and output. In a tool that uses a model, the user's text is the input, the model does the processing on a server, and the generated text is the output. The page and the server code around the model are ordinary programs that people write in a programming language, and Java is one of those languages.

Sources: Franchitti, Introduction to Computer Science, OpenStax (2024); Mistral AI, Chat completions and API reference (n.d.); Oracle, About the Java Technology (n.d.); Oracle, The Java EE Tutorial (2014); Week 12 passages and MuggsAI request path, class site (2026).

Classwork · Section 1 — Reading 2

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

MC 1. A person opens a map app, types the address of a library and taps Go. The app draws a route on the map. Which part is the input?

  • the library address the person typed
  • the route that the app draws on the map
  • the directions printed above the typing box
  • the program that works out the shortest route

MC 2. A student uses an AI helper on the class site. Which part does the work of producing the answer?

  • the page in the browser, which shows the answer
  • the model, which runs on a server
  • the system prompt, which travels with the question
  • the Chromebook, which the student types on

MC 3. A student types "What is a runtime?" into an AI tool, and an answer appears underneath. Which part of the screen is the output?

  • the question, because it is still showing on the screen
  • the button labeled Ask that the student pressed
  • the answer the model generated under the question
  • the system prompt that the builder wrote ahead of time

MC 4. Which part of an AI tool is an ordinary program that people write in a programming language?

  • the server code that adds the system prompt and calls the model
  • the parameter file, with the numbers training set
  • the generated answer that appears on the page
  • the question the student enters on the page

MC 5. What does the step n ← 7 do?

  • It checks whether n is equal to 7.
  • It stores 7 in the box named n.
  • It adds 7 to the value already in n.
  • It shows the number 7 on the screen.

MC 6. After these three steps run, what is stored in a?

11  a ← 2
22  a ← a + 6
33  a ← a * 3
  • 8
  • 6
  • 12
  • 24

MC 7. After these three steps run, what is stored in q?

11  p ← 5
22  q ← p
33  p ← 10
  • 5
  • 10
  • 15
  • nothing, because p changed

MC 8. A student traced these four steps. Which row of the student's trace table is wrong?

11  m ← 3
22  k ← m + 2
33  m ← k * 2
44  k ← m - 1
5
6Student's trace table
7Line   m    k
81      3    -
92      3    5
103      10   5
114      10   2
  • Row 1, because k should be 0
  • Row 2, because k should be 3
  • Row 3, because m should still be 3
  • Row 4, because k should be 9

MC 9. Why is the step x ← x + 1 not an equation?

  • It is an equation with no answer, so the computer skips it.
  • It makes x equal to 1 from then on.
  • It is an instruction to work out x + 1 and store the result in x.
  • It stores the words x + 1 in x, to be worked out later.

MC 10. In the worked trace table in Reading 2, what is stored in y after row 3?

  • 10
  • 5
  • 9
  • 4

CR 1. Trace these four steps. For each line, write one sentence that says what is worked out and what is stored. Then give the final values of a and b.

11  a ← 6
22  b ← a - 2
33  a ← a + b
44  b ← a * 2

Write your answer in your lab notebook, labeled CR 1.

CR 2. In two sentences, explain why a box can hold only one value at a time. Use one row of the worked trace table in Reading 2 as your evidence.

Write your answer in your lab notebook, labeled CR 2.

Figure 1. In a tool that uses a model, programs written by people carry the input in and the output out, and the model on a server does the processing.

The big picture so far (newest on top)

Big picture 4 of 5. Walls you can't see. Around the chain from Big picture 3 sit three walls: sources behind a login that the search can't open, a training gap shaped by crawler blocks and licensing deals, and policy rules that can look like missing information.
Big picture 3 of 5. Generation and retrieval. In Google's AI Mode, Lens reads the image, Search fetches pages from the open web (retrieval), and Gemini writes the answer from its squeezed chunk (generation), with links back to the pages.
Big picture 2 of 5. The song ladder. On each rung the gaps get bigger and less is really known, but the model sings every rung in the same confident voice. On rung 4 a word gets "picked anyway," which people call a hallucination.
Big picture 1 of 5 (from 12.2). Training squeezes one chunk of the internet into a much smaller parameters file and loses details; probability fills the gaps when the model is used.
Classwork · Section 2 — Past the floor

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

CR 3. Trace these five steps, which use three boxes. Give the final values of r, s and t. Then name one step where a value was replaced, and say which value was lost.

11  r ← 2
22  s ← r + 3
33  t ← s * r
44  r ← t - s
55  s ← r + t

Write your answer in your lab notebook, labeled CR 3.

CR 4. Choose an AI app or site you use. Name its input, its processing and its output, and name one program in it that people wrote. Write three or four sentences, and use one fact from the passage.

Write your answer in your lab notebook, labeled CR 4.

Bench Basics

Store It

Open the bench, do its six jobs, then paste your credit code into the credit-code form. You can turn in up to three codes per bench; your best score is your grade.

Bench Basics opens during your class period.

Classwork

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

Exit Ticket

This opens during your class period.