COMP9001 — Intro to Programming
Chapter 1: Introduction to Programming
A lecture-based study guide covering what a program is, why sequence and precision matter, how source code reaches machine code, and the workflow for writing and running a first Python program.
Built directly from the Lecture 1 PDF rather than a generic scaffold summary
What Is a Program?
Lecture definition: a program is a set of instructions for a computer to execute in sequence to perform a certain task.
What a programmer does
A programmer writes the instructions that become computer programs. The lecture also emphasizes that code should be readable and understandable by other people, not just by the machine.
Why this matters early
Before syntax, the course wants you to think operationally: what should happen, in what order, and with enough clarity that another person or computer could follow it.
Why Sequence Matters
The lecture uses everyday activities, such as joining class online, to show that instructions are only useful when their order makes sense.
Sequence Challenge
Click the shuffled steps to rebuild a sensible “join the lecture online” process from the lecture example.
Understanding Computers
Precision and logic
The lecture describes computers as precise and logical. They are very good at repetitive tasks, but only if the instructions are clear and correct.
Source code
A program or source code file is a text file containing commands to be executed by the computer, and those commands must follow the syntax of the language.
Compiler vs Interpreter
| Tool | What it does | Lecture emphasis |
|---|---|---|
| Compiler | Transforms high-level code into machine code before the program runs | Cannot fix your mistakes for you; invalid syntax stops compilation |
| Interpreter | Converts each statement one by one while the program is running | Immediate execution and feedback while translating |
Compiler
The lecture describes a compiler as translating the full source program into the machine-level form the processor understands.
Interpreter
The interpreter converts and executes statements as the program runs, which is why it is so useful for quick experimentation.
Learning to Program
Knowledge
- Programming concepts
- Python language ideas
- Input, output, conditionals, repetition
Actions and habits
- Write, execute, debug, test
- Use tools such as editors and terminals
- Explain your code clearly to others
Your First Python Program
Three-step workflow from the lecture
- Create a
.pyfile using a GUI or CLI - Write code into the file
- Run the file
It gives you a full end-to-end loop: file creation, code writing, execution, and observing output.
It shows that output is a visible consequence of source code, which is important before moving on to variables and control flow.
CLI Basics
The command line has a learning curve, but the lecture introduces it early because it is powerful for navigating directories and working with files.
| Command | Purpose | Lecture use |
|---|---|---|
pwd | Show current directory | “Where am I?” |
ls | View contents | See files and folders |
mkdir name | Create directory | Make a folder |
cd path | Change directory | Move to a location |
touch file | Create file | Make hello.py |
mv | Move file | Reorganize files |
cp | Copy file | Duplicate files |
Also introduced: VIM workflow
Open the file, enter insert mode, type the content, then save with :w and quit with :q.
print() and the Python Interpreter
print()
The lecture introduces print() as a built-in function for text output. It is one of the earliest ways to see a visible result from your program.
Python shell
Typing python3 opens the interpreter so you can execute code immediately and see the result in the terminal. This is useful for quick experiments and checks.
Output Prediction
Try predicting the output before revealing it.
Lecture Summary
Programs are instructions
A program is a sequence of instructions written for a machine to perform a task.
Order and precision matter
Incorrectly ordered or vague steps cause failure long before “advanced” programming topics appear.
Programming is workflow
Create files, write code, run programs, troubleshoot output, and learn to use the terminal and interpreter.