QUBIX UNIVERSITY · DATA SCIENCE FROM ZERO

What a Computer Program Does

Pre-Intern 002 · Digital Foundations

Instructions, input, processing, output and state—before the first line of code.

1
chapters
20
practice items, all answered
14
figures, all computed
EVENTasale happensRECORDfactsare capturedTABLErecordsstay organisedDECISIONevidenceis used
SOURCE-FIRST EBOOK · AI_DRAFTFounder review required. This ebook creates no interactive lesson and grants no curriculum approval.
PRE-INTERN ACADEMY · DIGITAL FOUNDATIONS

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.

INPUTscan1look upprice2calculatetotal3displayscreenPROCESS → RESULT
One checkout path: input enters, ordered instructions process it, and an output appears.

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.

ProgramInputProcessingOutput or action
checkoutproduct code and quantityfind price and calculateupdated basket total
stock alertrecorded stock countcompare with thresholdalert or no alert
daily reportsale recordsgroup and totalbranch summary
door controllervalid access signalcheck permissionunlock or remain locked
Worked example 1

A checkout receives product P-1042 and quantity 2. It finds a price of £1.50 per item. Identify the input, processing and output.

  1. The input is the product code and quantity.
  2. The program looks up £1.50 and multiplies it by 2.
  3. The output contributed to the basket is £3.00.

Answer. Input: P-1042 and 2. Processing: price lookup and multiplication. Output: £3.00.

INPUTP-1042 × 21look up£1.502multiply£3.003returnbasketPROCESS → RESULT

The stored price is data. The instructions that retrieve and use it belong to the program.

Your turn. A stock alert receives count 3 and threshold 5, compares them and shows “reorder”. Name the three parts.
answerInput: 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.

StepInstructionAvailable afterward
1read product codeP-1042
2look up price£1.50
3read quantity2
4multiply price by quantity£3.00
5add line amount to basketnew basket total
Each step supplies something the next step can use. Moving a step can change the result or make execution impossible.
Worked example 2

A report must load today’s sales, remove cancelled transactions, then calculate revenue. Why should calculation come last?

  1. Revenue depends on which records are included.
  2. Cancelled transactions must be identified before the total is calculated.
  3. Calculating first would include values that should not contribute.

Answer. Calculation comes last because it must operate on the checked set of valid sales.

INPUTsales1loadrows2excludecancelledvalid rows3sumrevenuePROCESS → RESULT

A wrong order can produce a plausible number, which makes the error more dangerous.

Your turn. Put these in order: display receipt, calculate basket total, read basket lines.
answerRead 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.

INPUTRESULTstock 3stock 8stock 0alertno alertone condition, two possible paths
The comparison chooses an output for each input. The program does not worry; it evaluates the stated condition.
Worked example 3

A program examines four basket lines and calculates an amount for each. What is repeating, and what changes?

  1. The instruction “price multiplied by quantity” repeats once per line.
  2. The current product, price and quantity change from line to line.
  3. The running basket total changes after each result is added.

Answer. The calculation repeats; the current line data and running total change.

LinePrice × quantityRunning 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.

Your turn. A program checks every branch file for a missing date. What repeats?
answerThe 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.

Worked example 4

A checkout program uses a price table. Which is code and which is data?

  1. The instruction “look up the scanned product in the price table” is code.
  2. The product codes and prices in the table are data.
  3. Changing a price changes the result without changing the lookup instruction.

Answer. The lookup rule is code; the price table is data.

ThingRole
look up product codeinstruction / code
P-1042 → £1.50data
current basket totalrunning state

Keeping changing business values out of the instruction itself makes the system easier to maintain and audit.

Your turn. A report program reads a CSV file of sales. Which is the program and which is the data?
answerThe 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.

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.

Practice20 items · Recall, Recognise, Explain, Apply, Decide, Reconstruct
  1. Corethe standard set
  2. 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.

  3. 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.

  4. 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.

  5. Name the three parts of the simplest program description used here.Recall
    show solution

    Input, processing or instructions, and output or action.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. What is source code?Recall
    show solution

    It is the written expression of program instructions in a programming language.

  12. What is program state?Explain
    show solution

    It is the data the running program currently remembers, such as the present basket and running total.

  13. 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.

  14. Can a fast program still be wrong?Explain
    show solution

    Yes. It can execute an incorrect rule or use bad input very quickly.

  15. What kind of error executes successfully but gives the wrong result?Recall
    show solution

    A logic error.

  16. 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.

  17. 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.

  18. 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.

  19. 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.

  20. 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.

  21. Stretchthese need a decision, not just a method
  22. 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.

ANSWER KEY

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

1

In one sentence, what is a computer program?

A computer program is a stored set of precise instructions that a computer system can execute.

2

A scanner supplies product P-1042. Is that value an instruction or input data?

It is input data supplied to the checkout program.

3

A screen shows £3.00 after a scan. Is that an input or output?

It is an output produced by the program’s processing.

4

Name the three parts of the simplest program description used here.

Input, processing or instructions, and output or action.

5

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.

6

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.

7

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.

8

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.

9

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.

10

What is source code?

It is the written expression of program instructions in a programming language.

11

What is program state?

It is the data the running program currently remembers, such as the present basket and running total.

12

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.

13

Can a fast program still be wrong?

Yes. It can execute an incorrect rule or use bad input very quickly.

14

What kind of error executes successfully but gives the wrong result?

A logic error.

15

Why test a program with a known answer?

A known answer lets you compare the program’s output with an independently established result.

16

Why test missing input?

Real data can be absent, and the program needs defined safe behaviour instead of crashing or inventing a value.

17

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.

18

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.

19

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.

20

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.

COMPLETION

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.

ChapterRequirements metLabsFiguresPractice
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.