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.

📖 Program Definition
🧭 Sequence and Logic
Compiler vs Interpreter
💻 First Python Workflow
📐 Foundations → 🗺 Mind Map →

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.

Key mindset: programming is not only “typing code.” It starts with understanding the task and expressing a correct process.

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.

    Programming takeaway: if you cannot explain the process in a clear sequence in human language, turning it into code is much harder.

    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.

    Human idea / task
    Source code
    Compiler / Interpreter
    Machine execution
    Why can a program fail even before it runs?
    Because its instructions may not follow the language syntax
    Because computers refuse to follow instructions in general

    Compiler vs Interpreter

    ToolWhat it doesLecture emphasis
    CompilerTransforms high-level code into machine code before the program runsCannot fix your mistakes for you; invalid syntax stops compilation
    InterpreterConverts each statement one by one while the program is runningImmediate execution and feedback while translating

    Compiler

    Whole Program First

    The lecture describes a compiler as translating the full source program into the machine-level form the processor understands.

    Interpreter

    Line by Line

    The interpreter converts and executes statements as the program runs, which is why it is so useful for quick experimentation.

    Which option matches the lecture’s description of an interpreter?
    It converts the entire source code before the program runs
    It converts statements one by one while the program runs
    It avoids translation entirely

    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
    Big idea: the lecture frames programming as conceptual understanding plus practical workflow, not just memorizing syntax rules.

    Your First Python Program

    Three-step workflow from the lecture

    1. Create a .py file using a GUI or CLI
    2. Write code into the file
    3. Run the file
    create write run
    print("Hello, World!")
    1

    It gives you a full end-to-end loop: file creation, code writing, execution, and observing output.

    2

    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.

    CommandPurposeLecture use
    pwdShow current directory“Where am I?”
    lsView contentsSee files and folders
    mkdir nameCreate directoryMake a folder
    cd pathChange directoryMove to a location
    touch fileCreate fileMake hello.py
    mvMove fileReorganize files
    cpCopy fileDuplicate 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.

    print("#") print("$$")
    # $$

    Lecture Summary

    Programs are instructions

    A program is a sequence of instructions written for a machine to perform a task.

    Core definition

    Order and precision matter

    Incorrectly ordered or vague steps cause failure long before “advanced” programming topics appear.

    Execution mindset

    Programming is workflow

    Create files, write code, run programs, troubleshoot output, and learn to use the terminal and interpreter.

    Practical skill
    Next: use the Foundations page to self-check the core terminology and workflow from this first lecture.