← Complete program

Chapter 2 · Course 3 c02-m03

What is a program?

Your goal Understand the difference between a method, a written program, and a program actually run.

The lesson, the vocabulary, the worked example and the mission are separate blocks. You can follow them in order or return to the one you need.

Video explanation

This English explanation has English subtitles. Its examples may use a separate practice dataset; use the data stated in the written mission for your answers.

01

Story · optional context

The story so far

You have joined the data team at Aster Motors. Before a Noctis 01 test, Mara Sol wants to count checked parts cards. She has a method on paper, but Noor needs to repeat the count each morning. Mara shows you a code file: “We can ask a computer to follow the method if we write instructions it understands.”

This page starts from the beginning. You can read it without earlier courses or knowledge of any programming language.

02

Before the lesson

Purpose of this course

Understand the difference between a method, a written program, and a program actually run.

Topics covered

Explain what a program is and what its source code is for.; Separate writing instructions, saving them, and running them.; Explain how a program processes input by rules and produces output.; Understand that output can be wrong if the rules or input are wrong.

What you will learn

  • Explain what a program is and what its source code is for.
  • Separate writing instructions, saving them, and running them.
  • Explain how a program processes input by rules and produces output.
  • Understand that output can be wrong if the rules or input are wrong.

PART 1 · THE LESSON

Understand step by step

1

Lesson · explanation

A program gives a method to the computer

A method written for a person might say: read each card and count those marked checked. To let a computer follow it, we write instructions in a language that software can process. The instructions together form a program. The text written by the person is called source code. You can understand these ideas without knowing any programming language yet.

Think of a musical score. The score exists before a concert and tells the musicians what to play. Until someone performs it, we hear nothing. Source code is similar: it describes the work, but a result appears only when someone runs the program with information to process.

A program can be tiny. One instruction that displays Hello is already a program. Another program may read millions of rows. The size changes, but the idea stays the same: precise instructions receive data and produce an effect or a result.

The computer does not understand the human meaning of car ready. If its instructions count received cards while Mara wants checked cards, it may obey perfectly and answer the wrong question. Before writing or using code, say the goal in plain words.

Pause and think

A code file is in a folder, but nobody has run it today. Has it calculated today's total?

See the explanation

No. Written code describes instructions; it must be run with today's data to produce a new result.

2

Lesson · explanation

Separate source code, input, and output

Source code holds the rules. Input is the information supplied while the program works, such as Monday's check cards. Output is what the program produces, here the number of cards confirmed as checked. Keep these three things separate in your mind even when they appear on one screen.

Imagine a machine that stamps cards. A label on the machine says stamp red cards. The cards placed in front of it are inputs. The stack of stamped cards is output. Change the cards while keeping the rule and the output can change. Change the rule while keeping the cards and the output can also change.

In the example, the rule is count checked cards. On Monday A and C are checked and B is only received, so the output is two. On Tuesday Noor adds D, also checked. With the new input, the expected output becomes three. The code need not change between the two days.

A number displayed on a screen is not a new check card. It is a result calculated from cards. To explain it, ask which code ran, which inputs it read, and when it ran. Without those details, an old output can be mistaken for today's information.

Pause and think

The code stayed the same, but one checked card was added. Can the result change from two to three?

See the explanation

Yes. The same program can produce a different output when its input changes.

3

Lesson · explanation

Writing, saving, and running are different actions

Writing code means stating the instructions. Saving a file keeps that text so it can be found later. Running the program asks the computer to follow the instructions now. Someone can perform the first two actions without performing the third.

Think of a shopping list. Writing it and putting it in your bag will not fill the fridge. You still need to go to the shop and use the list. Likewise, saving a counting program does not automatically refresh the number on the screen. It has to be run, or there must be an explicit rule that runs it at a scheduled time.

In the mission, Noor wrote and saved the program yesterday. The screen shows two checked parts with yesterday's date. Nothing in the story says that the program ran today. Card E arriving today does not reach backward in time and change yesterday's output. Voss treats an old number as if it described today.

A program can be set to run automatically, but do not imagine such a setting without evidence in this mission. Ask whether a new run really happened and which cards it read. If there is no proof, yesterday's number remains yesterday's output, not an updated count.

Pause and think

Noor clicked Save yesterday. Does that prove that card E, which arrived today, was counted?

See the explanation

No. Saving keeps the code. Check that it ran today with E included among its inputs.

4

Lesson · explanation

A fresh run can read fresh data

Each run is a new pass through the program. If you count three cards by hand and someone adds a fourth, the old total does not change by itself. You count again using the new pile. A program follows the same idea: run it again with current inputs, or arrange an automatic run whose execution can be checked.

In the example, D adds one confirmed check. The program must receive A, B, C, and D, follow its rule, and produce three. If D is not passed to it, the program may still show two even after a recent run. Check both the time of the run and the actual list of inputs.

In the mission, E is marked checked. If the previous two checks remain valid and E is a new, distinct card, the expected total is three. Those conditions matter. If E is a copy of an older card, adding it would inflate the count. The program needs a duplicate rule, or the team must check E before publishing.

A useful result note could say that the program ran Tuesday at 09:00 on cards A, B, C, and E, producing three pending confirmation of E's identifier. The date, inputs, and caution explain the number. A screen showing only three would tell Mara much less.

Pause and think

If the program runs today but reads only the old A, B, and C cards, can it count E?

See the explanation

No. A new run must also receive E as an input to include it in the result.

5

Lesson · explanation

A program can run successfully and still be wrong

A computer can finish without an error message and still produce the wrong answer. Code that counts received instead of checked follows a rule unrelated to the question. If the input includes a copy, code that ignores identifiers may count it twice. A number on a screen is therefore not absolute proof.

Imagine typing the wrong operation into a calculator. Two plus three gives five while two times three gives six. The calculator cannot guess which operation you meant. In a data report, a wrong rule may be harder to notice because its number can still look reasonable.

To check a counting program, try a small pile whose answer you already know. With A checked, B received, and C checked, the answer should be two. If the program shows three, inspect its rule. Then try a copied card to see whether it avoids counting the same event twice. Small tests can reveal mistakes before a large file is processed.

Human responsibility remains essential. Mara and Noor define the question, inspect the inputs, and interpret the output. Code helps repeat work quickly; it does not replace an inspection in the workshop or the safety decision. When a result surprises you, trace where the method and reality parted.

Pause and think

The program displays four after reading A, B, C, and E. Must that be right because no technical error appeared?

See the explanation

No. B was only received and E might be a copy. Check the rule and the inputs before publishing.

6

Lesson · explanation

Tell Mara what the screen really proves

Before the meeting, separate facts from Voss's claim. Certain facts: the code file exists, Noor saved it, and the screen shows output dated yesterday. Another fact: a new card E marked checked arrived today. The screen does not prove that the program ran today, that it read E, or that there are still only two checks.

The next action is clear. Inspect E and its identifier, add it to today's inputs, run the program, and read the output together with its date. If the two old checks remain valid and E is distinct, expect three. If the program shows another value, inspect the code and cards rather than changing the number by hand without explanation.

You can tell Mara that two is yesterday's result, that a new run is not confirmed, and that the expected count with E is three if E is not a copy. Ask the team to rerun and verify. This answer makes sense even to someone who has never seen the code.

The same reasoning will help when you meet Python. You will write instructions, save a file, and run it. More importantly, you will connect every output to its code, input, and time. That makes a program a trustworthy team tool instead of a mysterious number on a screen.

Pause and think

What evidence is missing before we can say that two checked parts is still today's total?

See the explanation

We need a run from today with all current cards, including E, and confirmation that counted cards are distinct and checked.

PART 2 · WATCH IT WORK

A complete worked example

Follow each step, then the result

Worked example: the morning rule

Mara writes a rule to count cards marked “checked.” Monday's input is A “checked,” B “received,” and C “checked.” On Tuesday, Noor adds D “checked” and runs the same program again.

  1. The paper rule states the goal. The source code contains a computer-ready version of that rule.
  2. Saving the code Monday does not calculate anything. When Mara runs it with A, B, and C, the expected output is 2.
  3. On Tuesday the same code reads A, B, C, and D. Noor runs it again; expected output is 3.
  4. If it shows 4, we look for a wrong rule or duplicate input. We do not assume the computer must be right.
What this shows

Code may stay the same while runs produce different results from different inputs.

How this helps with your mission

The example runs the same code on A, B, C on Monday and on A, B, C, D on Tuesday: output moves from two to three when input changes. In the mission, the screen still shows yesterday's output. It may never have read E. Reject Voss's claim, request a fresh run including E, and announce three only if E is a new checked card and the previous two checks remain valid.

PART 3 · YOUR TURN

Use the lesson to solve the mission

Story scene · practical task

Mission: the button nobody pressed

A Noctis 01 meeting starts soon in the story. Noor wrote and saved a counting program yesterday. A screen still says “2 parts checked” with yesterday's date. Today a new card E “checked” arrived. Voss claims the screen proves there are still only 2. Mara asks you to separate what was written, what was run, and what the screen really proves.

Your task

  1. Identify the source code and yesterday's result.
  2. Explain why saving the program yesterday does not update today's result.
  3. Say what new input must be read and what action must be taken today.
  4. Give the expected result if old cards were correct and E is new, then name a check to make.

How to know you have succeeded

  • You distinguish the instruction file from the displayed number.
  • You recognize yesterday's output stays old until a new run uses today's data.
  • You add E to the input and request a fresh run.
  • You give 3 under the stated conditions and check that E is not a copy.
Open this mission in the browser workspace

Try code or SQL and keep a local draft. The mission questions are checked separately below.

Check the facts in your mission

Answer each factual question, then write your report in your own words. The program checks the choices; compare the report with the worked answer below.

1. What do Noor's written file and the number '2' on screen represent?
2. What did Noor do by saving the program yesterday?
3. What action calculates today's total?
4. What total is expected if the two older checks remain valid and E is distinct?
See the worked answer
  1. Noor's written file is source code. “2 parts checked” is the output of yesterday's run.
  2. Saving keeps instructions; it does not run them today. The date tells us when that output was produced.
  3. Include E among the cards, then run the program on today's input.
  4. If the previous two checks are valid and E is a distinct checked card, expect 3. Before publishing, check E's source and identifier.

You now know why a program must be written and then run. Next, you will meet a language for writing the code: Python.

Before you leave

Remember this

  • Source code is the written instructions; input is the data received; output is the result produced.
  • Writing, saving, and running a program are three different actions.
  • The same code can produce different outputs when its inputs change.
  • Yesterday's result does not prove today's total; check when the program ran and which cards it read.
  • A program can finish normally yet answer the wrong question if its rule or input is wrong.
A–Z

Part of the lesson · keep nearby

New words, explained

These are the names of ideas used in the lesson above. Return here whenever a word feels unfamiliar.

Program
Instructions written for a computer to perform a task.
Source code
The text of instructions written by a person in a programming language.
Run
Start the program so the computer follows its instructions.
Input
Information given to the program, such as today's cards.
Output
The result it produces, such as a count on a screen.