E ExamMaster

Engineering Python · Language Basics

Hello Scripts

In Engineering Python because every later lab starts by running instructions and reading output — print and comments are the first tools.

A program is a list of instructions a machine carries out in order. This opening lesson makes that concrete with `print`, comments, and the difference between a saved script and an interactive session, then runs your first in-browser lab.

  • Engineering Python
  • Easy level
  • 5 concepts

1What a program is

A program is an ordered list of instructions. The machine does not guess intent: it runs the lines you wrote, in order, unless control flow later says otherwise.

Engineering labs treat the program as the contract: if the output is wrong, either the instructions or the inputs are wrong — not the interpreter's mood.

You will spend this course writing small programs, running them, and reading what they print. That loop is the skill.

Figure. A program is an ordered list of instructions. The machine runs the lines you wrote, in order.

A program is best described as:
  1. An ordered list of instructions a machine runs
  2. A single mathematical formula
  3. A folder of images

Programs are sequences of instructions executed by the runtime.

3Comments vs code that runs

A `#` starts a comment: the rest of that line is ignored by the interpreter.

Comments are for humans — why a line exists, what a temporary value means — not for the machine.

A commented-out `print` does nothing. That is a common lab mistake when something 'disappears'.

Figure. A # starts a comment: that line is ignored. A commented-out print does nothing.

Takeaway

  1. IdeaA `#` starts a comment: the rest of that line is ignored by the interpreter.

Comment vs print

# This line does not run.
print("This line does")
How does the Python runtime treat characters following a hash symbol # on a line?
  1. It discards them entirely during tokenisation, treating them as non-executable comments
  2. It executes them with highest arithmetic operator priority
  3. It converts them into compile-time typing assertions
  4. It raises an invalid syntax syntax error exception

Everything following # on a line is ignored by the Python interpreter as a developer comment.

4Script file vs interactive session

A script is a saved file of instructions you run as a unit. An interactive session (REPL) lets you type one expression at a time and see results immediately.

In-browser labs here behave like a notebook: cells are small scripts that share a kernel. Order matters — later cells see names defined earlier.

Neither mode invents missing instructions. If a name is undefined, you have not assigned it yet in this session.

Figure. A script is a saved file of instructions you run as a unit. A REPL lets you type one expression at a time.

Takeaway

  1. IdeaA script is a saved file of instructions you run as a unit. An interactive session (REPL) lets you type one expression at a time and see results immediately.
What is the main operational difference between running a .py script and interacting with a REPL?
  1. A script can only process numeric variables while a REPL accepts strings
  2. A REPL compiles code directly into standalone binary machine executables
  3. A script executes all commands sequentially from top to bottom before exiting, whereas a REPL evaluates expressions interactively step-by-step
  4. A script cannot import external libraries like NumPy or pandas

A script file is executed non-interactively from start to finish, while a REPL (Read-Eval-Print Loop) allows rapid interactive testing.

5Run cells and read stdout

Run cells top to bottom. Read the output panel after each run before editing more.

If a check looks for a word in stdout, print that word. Silent success is rare in beginner labs — print is how you prove the step worked.

Figure. Run cells top to bottom. Read the output panel after each run. If a check looks for a word, print that word.

Takeaway

  1. IdeaRun cells top to bottom. Read the output panel after each run before editing more.

Coding lab. Confirm stdout runs in the app, with checks on your output.

Notes

  • In Engineering Python because every later lab starts by running instructions and reading output — print and comments are the first tools.
  • A program is an ordered list of instructions. The machine does not guess intent: it runs the lines you wrote, in order, unless control flow later says otherwise.
  • `print` sends text to the output panel (stdout). A string literal is text wrapped in quotes.

Exam traps & shortcuts

  • Run one cell at a time and read stdout before changing more lines.
  • Names are labels for values; rebinding a name does not rewrite old prints.

Recap

Before variables: programs run in order, print shows results, comments do not run.

What a program is
A program is an ordered list of instructions. The machine does not guess intent: it runs the lines you wrote, in order, unless control flow later says otherwise.
Printing text with print
`print` sends text to the output panel (stdout). A string literal is text wrapped in quotes.
Comments vs code that runs
A `#` starts a comment: the rest of that line is ignored by the interpreter.
Script file vs interactive session
A script is a saved file of instructions you run as a unit. An interactive session (REPL) lets you type one expression at a time and see results immediately.

Practise Hello Scripts

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • A 2-question practice set that ends the chapter
  • 4 quick checks with worked explanations
  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.