1. What a computer program does
A program is a stored set of precise instructions that a computer can execute.
At a Qubix Superstore checkout, a cashier scans a product. The screen finds its price, multiplies by the quantity, adds the result to the basket and displays a new total. Nobody performs those steps by hand for every scan. A computer program carries them out.
A computer program is a set of instructions written in a form that a computer system can execute. A person decides what the system should accomplish and expresses the necessary rules. The computer performs the implemented steps. Speed does not give it judgment, intention or common sense.
Input, processing and output
Many programs can first be understood with three questions: what enters, what steps happen, and what comes out? The answer need not be a number. A click may enter and a window may open. A sensor reading may enter and an alarm may sound.
| Program | Input | Processing | Output or action |
|---|---|---|---|
| checkout | product code and quantity | find price and calculate | updated basket total |
| stock alert | recorded stock count | compare with threshold | alert or no alert |
| daily report | sale records | group and total | branch summary |
| door controller | valid access signal | check permission | unlock or remain locked |
A checkout receives product P-1042 and quantity 2. It finds a price of £1.50 per item. Identify the input, processing and output.
- The input is the product code and quantity.
- The program looks up £1.50 and multiplies it by 2.
- The output contributed to the basket is £3.00.
Answer. Input: P-1042 and 2. Processing: price lookup and multiplication. Output: £3.00.
The stored price is data. The instructions that retrieve and use it belong to the program.
answer
Input: 3 and 5. Processing: compare count with threshold. Output: the reorder alert.Order matters
Instructions form a sequence. “Find the price, multiply by quantity, then add to the basket” is meaningful. “Add to the basket, then find the price” asks the system to use a value it does not yet have. Computers follow execution order, not the order a person probably intended.
| Step | Instruction | Available afterward |
|---|---|---|
| 1 | read product code | P-1042 |
| 2 | look up price | £1.50 |
| 3 | read quantity | 2 |
| 4 | multiply price by quantity | £3.00 |
| 5 | add line amount to basket | new basket total |
A report must load today’s sales, remove cancelled transactions, then calculate revenue. Why should calculation come last?
- Revenue depends on which records are included.
- Cancelled transactions must be identified before the total is calculated.
- Calculating first would include values that should not contribute.
Answer. Calculation comes last because it must operate on the checked set of valid sales.
A wrong order can produce a plausible number, which makes the error more dangerous.
answer
Read basket lines, calculate basket total, display receipt.Programs make choices and repeat steps
A useful program rarely follows only one straight path. A condition chooses a path: if stock is below the threshold, create an alert; otherwise continue. A repetition applies instructions again: for each sale line, calculate its amount.
- Sequence: perform steps in an order.
- Selection: choose a path using a condition.
- Repetition: apply steps again while a rule says to continue or for each item in a collection.
A program examines four basket lines and calculates an amount for each. What is repeating, and what changes?
- The instruction “price multiplied by quantity” repeats once per line.
- The current product, price and quantity change from line to line.
- The running basket total changes after each result is added.
Answer. The calculation repeats; the current line data and running total change.
| Line | Price × quantity | Running total |
|---|---|---|
| 1 | £2 × 1 | £2 |
| 2 | £1 × 3 | £5 |
| 3 | £4 × 1 | £9 |
| 4 | £2 × 2 | £13 |
The value a program retains while it runs is part of its state.
answer
The same missing-date check repeats for each branch file; the current file and result change.Code, program, data and state
Source code is the written expression of instructions in a programming language. A running program is those instructions being executed by a computer system. Data is what the program reads, creates or changes. State is the data the running program currently remembers, such as the basket lines and current total.
A checkout program uses a price table. Which is code and which is data?
- The instruction “look up the scanned product in the price table” is code.
- The product codes and prices in the table are data.
- Changing a price changes the result without changing the lookup instruction.
Answer. The lookup rule is code; the price table is data.
| Thing | Role |
|---|---|
| look up product code | instruction / code |
| P-1042 → £1.50 | data |
| current basket total | running state |
Keeping changing business values out of the instruction itself makes the system easier to maintain and audit.
answer
The instructions that read and summarise are the program; the sales records in the CSV file are data.A computer can execute a mistake perfectly
A program does what its implemented instructions specify under the conditions it encounters. That is not always what its author wanted. A missing rule, incorrect comparison, wrong unit or misunderstood business definition can produce an incorrect result at great speed.
- A syntax error breaks the language’s writing rules.
- A runtime error occurs while instructions execute.
- A logic error allows execution but produces the wrong behaviour.
- A bad input may make correct instructions produce an unusable result.
Reference and provenance record
Terminology was cross-checked against the NIST Computer Security Resource Center glossary entry for software and its cited source publications, and against the Python Software Foundation’s Python 3.14 tutorial and language documentation (accessed 21 August 2026). These are reference checks; no wording, examples or diagrams were copied. Stable records: https://csrc.nist.gov/glossary/term/software and https://docs.python.org/3/tutorial/
The Qubix Superstore checkout, stock alert, report flow, values and questions are original synthetic teaching material. No production retailer program, source code or data was used.
- Corethe standard set
-
In one sentence, what is a computer program?Recall
show solution
A computer program is a stored set of precise instructions that a computer system can execute.
-
A scanner supplies product P-1042. Is that value an instruction or input data?Recognise
show solution
It is input data supplied to the checkout program.
-
A screen shows £3.00 after a scan. Is that an input or output?Recognise
show solution
It is an output produced by the program’s processing.
-
Name the three parts of the simplest program description used here.Recall
show solution
Input, processing or instructions, and output or action.
-
Why does instruction order matter?Explain
show solution
A later instruction may depend on a value created by an earlier one, and changing the order can change or prevent the result.
-
Put these in order: add amount to basket, look up price, read product code.Apply
show solution
Read product code, look up price, add the calculated amount to the basket.
-
What does a condition allow a program to do?Recall
show solution
It allows the program to choose between paths based on whether a stated test is satisfied.
-
What does repetition allow a program to do?Recall
show solution
It allows instructions to be applied again, such as once for every sale line or branch file.
-
A program checks “stock below 5”. What output should stock 3 produce?Apply
show solution
It should follow the below-threshold path, such as producing a reorder alert.
-
What is source code?Recall
show solution
It is the written expression of program instructions in a programming language.
-
What is program state?Explain
show solution
It is the data the running program currently remembers, such as the present basket and running total.
-
A price changes from £2 to £2.20 while the lookup rule stays the same. What changed?Apply
show solution
The price data changed; the lookup instruction did not.
-
Can a fast program still be wrong?Explain
show solution
Yes. It can execute an incorrect rule or use bad input very quickly.
-
What kind of error executes successfully but gives the wrong result?Recall
show solution
A logic error.
-
Why test a program with a known answer?Explain
show solution
A known answer lets you compare the program’s output with an independently established result.
-
Why test missing input?Explain
show solution
Real data can be absent, and the program needs defined safe behaviour instead of crashing or inventing a value.
-
Does a computer understand the business goal merely because it runs the program?Decide
show solution
No. It executes implemented instructions; human designers remain responsible for expressing and checking the goal.
-
Give one Superstore example of input, processing and output.Reconstruct
show solution
Example: stock count and threshold enter; the program compares them; a reorder alert is produced when the count is lower.
-
What is the difference between code and data in the price-table example?Explain
show solution
Code tells the system to perform a lookup; data supplies the product codes and prices being looked up.
- Stretchthese need a decision, not just a method
-
A program totals cancelled sales because it filters them after calculating. Identify the fault.Decide
show solution
The instruction sequence is wrong. Cancelled records must be excluded before the revenue calculation.
Answers, shown
Every practice item is answered here, with the reasoning that produces it and, wherever a picture says it better than a sentence, the picture. 0 of 20 are drawn so far. A book that answers only the odd numbers teaches its reader to guess.
1. What a computer program does
In one sentence, what is a computer program?
A computer program is a stored set of precise instructions that a computer system can execute.
A scanner supplies product P-1042. Is that value an instruction or input data?
It is input data supplied to the checkout program.
A screen shows £3.00 after a scan. Is that an input or output?
It is an output produced by the program’s processing.
Name the three parts of the simplest program description used here.
Input, processing or instructions, and output or action.
Why does instruction order matter?
A later instruction may depend on a value created by an earlier one, and changing the order can change or prevent the result.
Put these in order: add amount to basket, look up price, read product code.
Read product code, look up price, add the calculated amount to the basket.
What does a condition allow a program to do?
It allows the program to choose between paths based on whether a stated test is satisfied.
What does repetition allow a program to do?
It allows instructions to be applied again, such as once for every sale line or branch file.
A program checks “stock below 5”. What output should stock 3 produce?
It should follow the below-threshold path, such as producing a reorder alert.
What is source code?
It is the written expression of program instructions in a programming language.
What is program state?
It is the data the running program currently remembers, such as the present basket and running total.
A price changes from £2 to £2.20 while the lookup rule stays the same. What changed?
The price data changed; the lookup instruction did not.
Can a fast program still be wrong?
Yes. It can execute an incorrect rule or use bad input very quickly.
What kind of error executes successfully but gives the wrong result?
A logic error.
Why test a program with a known answer?
A known answer lets you compare the program’s output with an independently established result.
Why test missing input?
Real data can be absent, and the program needs defined safe behaviour instead of crashing or inventing a value.
Does a computer understand the business goal merely because it runs the program?
No. It executes implemented instructions; human designers remain responsible for expressing and checking the goal.
Give one Superstore example of input, processing and output.
Example: stock count and threshold enter; the program compares them; a reorder alert is produced when the count is lower.
What is the difference between code and data in the price-table example?
Code tells the system to perform a lookup; data supplies the product codes and prices being looked up.
A program totals cancelled sales because it filters them after calculating. Identify the fault.
The instruction sequence is wrong. Cancelled records must be excluded before the revenue calculation.
What this book still owes its reader
A chapter passes when it carries at least 4 worked examples, each followed by a parallel one the reader does; at least 4 figures; an illustrated or operable answer on every worked example; at least 20 practice items with an answer for every one; a named misconception; and a link back to earlier work. This table is counted from the source at build time, so it cannot flatter the book.
| Chapter | Requirements met | Labs | Figures | Practice | |
|---|---|---|---|---|---|
| 1What a computer program does | 8 of 8 | — | 14 | 20 | passes |
1 of 1 chapters meet the gate. 20 practice items, every one with a solution you can open; 4 worked examples carrying 4 parallel exercises and 4 illustrated answers; 0 interactive labs; and 14 figures, every one computed at build time from the formula printed beside it.