← Complete program

Chapter 2 · Course 4 c02-m04

What is Python?

Your goal Recognize Python as a programming language and understand, character by character, a first line that displays a message.

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.

Avant de commencer le code : comprendre l’ordinateur, le binaire, la mémoire et le système d’exploitation.

01

Story · optional context

The story so far

You are the new data team member at Aster Motors. Mara Sol is teaching you to prepare trustworthy information for a test of Noctis 01. Noor has written a short instruction on paper to show a message on screen. Mara opens the coding workspace: “We will write it in Python. Today our only goal is to understand one very simple line.”

You can start here without earlier courses. A program is a set of instructions a computer follows; Python is one language for writing them.

02

Before the lesson

Purpose of this course

Recognize Python as a programming language and understand, character by character, a first line that displays a message.

Topics covered

Explain programming language, syntax, and the Python interpreter.; Read print("Hello") without confusing code with the displayed message.; Predict the output of two simple instructions run in order.; Spot and fix a basic punctuation mistake calmly.

What you will learn

  • Explain programming language, syntax, and the Python interpreter.
  • Read print("Hello") without confusing code with the displayed message.
  • Predict the output of two simple instructions run in order.
  • Spot and fix a basic punctuation mistake calmly.

PART 1 · THE LESSON

Understand step by step

1

Lesson · explanation

A program is an instruction; Python is a language for writing it

Imagine asking a friend to make a sign for the workshop. 'Make something good' is too vague. 'Write Aster Motors on the first line' is an instruction your friend can follow. A program is also a set of instructions, but for a computer. You must describe actions clearly because the machine cannot guess the result you had in mind.

A programming language provides words and rules for writing those instructions. Python is one such language. Its name does not mean the keyboard or the screen: it describes a way to write instructions that Python software can read. Later you will use it to count and check data. Displaying one sentence is enough to begin.

The written instructions are called source code. When Noor types print("Aster Motors"), she writes source code. This text may be kept in a file, much like a recipe in a notebook. Until someone asks the program to run, it does not produce a new sentence on screen. Writing, saving, and running are three different actions.

You are not expected to know all of Python. Learn one instruction, then look at what the computer produces. Connect each new word to an action: code is the written instruction, running is when the computer follows it, and output is the visible result.

Pause and think

A sheet of paper says print("Hello"), but nobody runs the program. Must a new message appear on screen?

See the explanation

No. The sheet contains source code. Python must be asked to run it before it produces output.

2

Lesson · explanation

Who reads the code when you press Run?

A recipe does not bake a cake by itself. Somebody must read it and follow its steps. In this first exercise, the Python interpreter is the software that reads Python instructions when you press Run. It also checks whether a line follows the writing rules it understands.

A coding workspace shows two different things. In one area you write code; in another you look at the output or an error message after running it. If Noor types a new line but does not press Run, she must not treat the old output still on screen as the result of the new line.

Think of three moments. First you write or change an instruction. Next you run the program and the interpreter reads it. Last you inspect the output. If you change the code after that run, the old output does not necessarily change. Run the code again and read the new result.

A message displayed by Python comes from an executed instruction, not from an observation in the workshop. If a line says 'check complete', it does not prove a person really checked Noctis 01. The computer could show that sentence even if no inspection took place. This difference will matter in your mission report.

Pause and think

Noor changes 'Hello' to 'Hi' in her code but does not run it again. Does the old 'Hello' output prove the new code ran?

See the explanation

No. It is still the output from the earlier run. Run the changed program and inspect its result.

3

Lesson · explanation

Read print("Hello") one character at a time

Look at print("Hello"). The word print is a Python name that asks to display something. It is not part of the final message. You can read it as 'show this to me'. Python treats upper- and lowercase letters differently: Print is not the same name.

The opening parenthesis ( begins what you give to print; the closing one ) ends it. Think of two hands holding a card. In this line, the card contains the message. One hand is missing if you write print("Hello". Python reports an error rather than guessing where you meant to end the instruction.

Quotation marks surround the characters of the message: "Hello". They tell Python 'this is text to show'. They are not printed on screen in this example. Without them, Hello is read as a name to look up in the program. If you have not defined such a name, the line fails. You will learn about names later.

The expected output is simply Hello. You do not see print, parentheses, or quotation marks. To check your understanding, give each part of the code a color in your mind: one action, two parentheses, two quotation marks, and the text to show. Only the message text appears in the output.

Pause and think

What exact text does print("Noctis 01") display? Do the quotation marks appear?

See the explanation

The output is Noctis 01. Quotation marks identify text in the code, but are not displayed here.

4

Lesson · explanation

Two instructions run in order

Write print("Start") on the first line and print("End") on the second. When Python runs them in that order, it displays Start and then End, each on its own line. Pretend to be the interpreter: point to the first line, say its message, move down, and say the next one.

If you swap the code lines, you swap the visible lines. Order is therefore part of the instruction. In the mission, Noor wants the company name first and an invitation to check evidence second. A response containing both phrases in reverse order does not quite do what she asked.

Each print displays what it receives. Two lines of code can produce two lines of output, but code and output do not have to look alike. print("Aster Motors") is an instruction; Aster Motors is the visible text after running it. When asked 'what will appear on screen?', write the visible text, not the entire instruction.

For now, these messages are fixed in advance. The program does not look at the number of parts or the result of an inspection. Later you will learn to read values and choose what to display from them. Today you are learning to predict and check the order of simple output.

Pause and think

What appears when a program runs print("One") and then print("Two")?

See the explanation

It shows One on the first line and Two on the second, without showing the word print.

5

Lesson · explanation

A punctuation error is a clue, not a failure

Python follows a syntax: rules for writing. In a postal address, forgetting the house number can stop a parcel from arriving. In Python, forgetting a parenthesis can stop the interpreter from knowing where an instruction ends. An error message helps you locate the problem. It does not judge your ability.

Compare the correct print("Hello") with print("Hello". The second has an opening ( but no closing ). Look at the end, add ), and run again. A calm method is to compare the beginning and end before changing several characters at once.

Another counterexample is Print("Hello"), with a capital letter. Python does not read it as the same name as print. Change the letter to lowercase. If an error remains, reread from left to right: name, opening parenthesis, opening quote, text, closing quote, closing parenthesis.

Do not handle an error by inventing an output. Before the line is valid and run, you cannot say it displayed the message you wanted. In the mission, Noor has forgotten exactly the last ). You can repair that character on paper and then predict what will appear when the complete program runs.

Pause and think

What is missing from print("Check the evidence"? What should Noor do next?

See the explanation

The closing parenthesis ) is missing. Add it, then run the two lines again to check the output.

6

Lesson · explanation

A screen message is not proof about the car

A sign can say 'door closed' while the door is open. The sentence tells you what somebody wrote; it does not measure the door. In the same way, print("Check the evidence") displays an invitation. It does not inspect a single part of the prototype. Telling a message from an observed fact is essential when working with data.

In Mara's example, print("Noctis 01: check in progress") produces that phrase if the line is correct and run. We can say the program displayed it. We cannot say the check really started. That claim needs an independent source, such as a workshop record or a verified observation.

For the mission, separate four questions. Which character is missing from Noor's line? What do print, the quotes, and parentheses mean? Which two lines will be visible, and in what order? What do they actually prove? The first three questions concern the program. The last concerns facts in the real world.

You can now read a small Python instruction without blindly trusting its output. Later you will write code to calculate from data. Even then, a nice-looking message will never replace reliable facts or proof of a completed inspection. For today, understanding one line is a good first step.

Pause and think

The program displays 'check complete'. Can you claim that Noctis 01 was inspected?

See the explanation

No. You can only say the program displayed that sentence. An independent record must confirm the inspection.

PART 2 · WATCH IT WORK

A complete worked example

Follow each step, then the result

Worked example: the first message

Mara writes print("Noctis 01: check in progress") in the workspace and presses Run.

  1. Before running, this text is source code. The name print describes the action: display.
  2. The brackets surround the requested message. Quotation marks show where its text begins and ends.
  3. The interpreter reads the line when Mara presses Run.
  4. The expected output is Noctis 01: check in progress. The quotes, brackets, and print are not part of it.
  5. This message does not mean a real check has happened. It only says what the program displayed.
What this shows

Displaying a sentence is a first code exercise, not proof about a real car.

How this helps with your mission

Mara's worked example shows how print, parentheses, and quotation marks turn into only the visible message after running the code. In Noor's mission, apply the same reading to two lines: add the missing ), predict Aster Motors and then Check the evidence, and explain that the display proves no actual inspection of the prototype.

PART 3 · YOUR TURN

Use the lesson to solve the mission

Story scene · practical task

Mission: fix Noor's announcement

The team prepares a welcome screen for the first Noctis 01 test. Noor wants two lines, first “Aster Motors,” then “Check the evidence.” Her first line is correct: print("Aster Motors"). Her second line is print("Check the evidence"; the last bracket is missing. Mara asks you to fix it before Noor runs the code.

Your task

  1. Copy the second instruction with its missing character.
  2. Say what print does and what the quotes and brackets are for.
  3. Write the two lines the screen will show after running, in order.
  4. Explain why these messages do not prove the prototype was really checked.

How to know you have succeeded

  • You write print("Check the evidence").
  • You link print to display, quotes to message text, and brackets to what the instruction receives.
  • You show “Aster Motors” and then “Check the evidence,” without the surrounding code.
  • You separate a program's message from a real observation or check.
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. Which line fixes Noor's incomplete instruction?
2. In `print("Hello")`, what do `print`, quotation marks, and parentheses do?
3. After Noor's two lines are fixed and run, what appears in order?
4. What do these two displayed messages prove about Noctis 01?
See the worked answer
  1. The fixed line is print("Check the evidence"): add ) after the final quotation mark.
  2. print requests display; quotes mark the text; brackets surround what is given to the instruction.
  3. First visible line: Aster Motors. Second: Check the evidence.
  4. A program can display any message its author wrote. We need separate evidence to say a real check took place.

You have read your first Python instruction. Next, you will learn where to write code, how to run it, and how to read an error.

Before you leave

Remember this

  • Python is a programming language. Source code is the written instruction; running is when the interpreter follows it.
  • In print("Hello"), print requests display, quotes mark the text, and parentheses surround what is given to the instruction.
  • This line outputs Hello without the surrounding code; two lines appear in the order they are run.
  • A missing parenthesis stops Python reading the line correctly: fix it and run again.
  • A displayed sentence does not prove that a real-world inspection took place.
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.

Python
A language for writing instructions a computer can run with Python.
Programming language
Words and precise writing rules for giving instructions to a machine.
Syntax
A language's writing rules. Missing punctuation can make an instruction impossible to read.
Interpreter
The Python software that reads your code and follows its instructions when you run it.
Instruction
One action requested by a program, such as displaying a message.
Output
What the program produces, here the text visible below the Run button.