University of Melbourne · S2 2026 · FACULTY OF COMPUTER SCIENCE

COMP90059 Introduction to Programming

- one subject, every graph, every model, every mark
9 Chapters39-page Bible
Our own words - no uploaded lecturer files
Built to mirror S2 2026 · updated this semester
The Complete Exam Bible · S2 2026

COMP90059 Overview

Introduction to Programming
— trace the state, explain the choice, test the edge
  • University of Melbourne
  • Semester 2, 2026
  • Postgraduate introductory programming
  • Python 3 and Jupyter
  • Exam hurdle applies

COMP90059 Introduction to Programming is a University of Melbourne subject that teaches Python while developing computational thinking. It assumes no prior programming experience.

  • Core method Trace values, types and state before execution
  • Assessment focus Practise explanation, code reading and construction
  • Boundary habit Test emptiness, thresholds and missing data
COMP90059 · University of Melbourne
An independent, AskSia-authored study guide. AskSia is not affiliated with, endorsed by, or sponsored by University of Melbourne; the course code and name are used for identification only.
Assessment

How COMP90059 is assessed

ComponentWeightFormat
Mid-Semester Test10%LMS Quiz in the Week 7 lecture slot; the current Week 7 notice describes a one-hour, in-person, closed-book test covering Weeks 1 to 6
Assignment 110%Released in Week 5; follow the current task instructions for submission requirements
Assignment 215%Released in Week 9; follow the current task instructions for submission requirements
Weekly Ed Exercises5%Ten homework modules are available and the best five contribute to this component
End-of-Semester Examination · hurdle60%Written exam covering class content unless marked non-assessable; three hours plus fifteen minutes reading time; a score of 30 out of 60 is required
Contents · every chapter, one map

What COMP90059 covers

Follow Python programs from values and expressions through control flow, functions, collections, files and recursion. Each chapter connects a language rule to a complete trace and a boundary test.

01

Programming Foundations

Jupyter notebooks, Python execution, statements, expressions and the first complete program.

This chapter establishes the execution model used throughout the subject. A Jupyter notebook contains markdown cells for explanation and code cells for Python.

  • Code cells execute Python and can change notebook state
  • Markdown cells record reasoning, units, assumptions and headings
  • Python 3 is the language environment used in the subject
  • Expressions evaluate to values while statements perform actions
  • Assignment evaluates the right side before binding the left name
  • Input text requires explicit conversion before numeric operations
02

Values, Variables and Expressions

Types, conversion, operators, precedence, formatting and floating point comparison.

Python operators obtain their meaning from operand types. Addition combines numbers but concatenates strings; multiplication combines numbers but can repeat a string when paired with an integer.

  • Strings and numeric values support different operations
  • Variables are names bound to values rather than declared storage boxes
  • Int, float, str and bool perform explicit conversions
  • Precedence chooses which operator binds before another
  • Associativity resolves operators at the same precedence level
  • Floor division rounds toward negative infinity
03

Boolean Logic and Conditionals

Truth values, logical operators, short circuit evaluation, comparisons and branch boundaries.

A conditional evaluates a truth-valued expression and selects one suite of statements.

  • Boolean literals represent true and false directly
  • Comparison operators produce Boolean results
  • Chained comparisons express bounded intervals
  • If, elif and else select the first matching branch
  • And, or and not combine or negate conditions
  • Short-circuit evaluation can protect a risky expression
04

Strings and Sequence Operations

Indexing, slicing, methods, immutable updates, nested access and sequence errors.

Strings and lists share the sequence model: ordered items have positions, positive indices begin at zero and negative indices count from the end. Indexing retrieves one required item, while slicing retrieves a half-open region whose stop is excluded.

  • Positive indices count from zero
  • Negative indices count backward from the final item
  • Indexing requires a valid single position
  • Slicing includes the start and excludes the stop
  • A step controls spacing and traversal direction
  • String methods return new immutable strings
05

Functions, Return Values and Scope

Parameters, arguments, returns, local namespaces, composition, defaults and direct testing.

A function packages one coherent operation behind a name and an input-output contract. Parameters are placeholders in the definition, while arguments are the values supplied by a call.

  • Def creates a function object without running its body
  • Parameters receive argument values for one call
  • Return ends a call and hands a value to the caller
  • Print displays output but normally returns None
  • Each call owns a separate local namespace
  • A helper should own one coherent rule
06

Iteration and List Processing

For and while loops, accumulators, stopping rules, loop control and nested traversal.

Iteration becomes predictable when four obligations are explicit: initialise state, decide whether another pass is needed, process the current item and update state toward termination.

  • For loops visit items supplied by an iterable
  • While loops repeat while a condition remains true
  • Range follows a half-open start and stop convention
  • Accumulators begin with the identity for their update
  • Loop invariants describe state after each completed pass
  • Continue skips the remainder of one iteration
07

Tuples, Mutability and Debugging

Records, aliases, copying, sort keys, mutation contracts and systematic diagnosis.

Tuples group ordered fields into records whose slots cannot be replaced, while lists remain mutable. Assignment does not automatically copy an object: two names may become aliases for the same list, so a mutation through either route is visible through both.

  • Tuples preserve field order while preventing slot replacement
  • Packing creates a tuple and unpacking binds its fields
  • Aliases are multiple names for one object
  • Rebinding changes a name while mutation changes an object
  • Shallow copies may share nested mutable objects
  • Sorted returns a new list while sort mutates in place
08

Dictionaries, Sets and 2D Data

Key lookup, uniqueness, frequency tables, ordered deduplication and grid processing.

Collection choice follows required behaviour. Lists preserve order and allow indexed change, tuples represent stable records, sets provide distinct membership and algebra, and dictionaries map unique keys to values.

  • Sets store distinct values without positional indexing
  • Union, intersection and difference compare memberships
  • Set difference is directional rather than commutative
  • Dictionaries map unique keys to values
  • Get can provide a default for expected absence
  • Frequency tables update one key per observed item
09

Files and Recursive Functions

File modes, validation boundaries, base cases, recursive progress and code reading.

Files introduce an external data boundary. Read mode observes existing content, write mode replaces content and append mode adds at the end, so the mode expresses a material effect rather than a cosmetic option.

  • Read mode observes existing file content
  • Write mode replaces content and requires deliberate use
  • Append mode adds content without discarding earlier records
  • Context managers close files reliably
  • Parsing should finish before state is updated
  • A recursive base case ends the call chain

The learning path begins with Jupyter notebooks, expressions, values and types, then adds conditionals, strings, functions and iteration before moving into tuples, mutability, debugging, dictionaries, sets, two dimensional data, files and recursive functions.

The central study habit is to predict before running code.

A dependable trace records each value and type, follows assignments in execution order, identifies the selected branch, tracks every loop update and separates a function's returned value from its printed output.

Boundary cases matter throughout: empty collections, missing keys, zero denominators, exact thresholds, invalid indices and recursive inputs outside the stated precondition.

The subject combines coursework with secure assessments. The published assessment weights total the full grade, and the end-of-semester written examination has a separate hurdle.

This guide uses newly authored worked examples and practice tasks so you can rehearse the non-copyrightable programming methods without reproducing assessment stems.

Each chapter connects four views of the same skill: the language rule, a complete worked trace, the state or object model behind that trace, and a fresh practice variation. Read across all four.

Syntax becomes easier to remember when you can explain why Python selects that operation and which input would make the method fail.

Worked example · free

Trace a filtered mean without losing the invariant

Q [5 marks]. A program receives [4.0, -1.0, 6.0, 2.0]. It must ignore negative values and return the mean of the remaining values. Trace the accumulator state and explain the empty-input guard. The mark allocation used here is an author-designed study aid, not an official university marking scheme.
Two cell types support one learning cycle.Two cell types support one learning cycle. The course asks students to explain in markdown and annotate code with comments. MARKDOWN CELLreasoning, units, headings CODE CELLPython, output, state explain → run → inspect → revise
Two cell types support one learning cycle. The course asks students to explain in markdown and annotate code with comments.
  • 1Initialise total to zero and count to zero so the invariant describes an empty processed prefix.
  • 2Accept 4.0, 6.0 and 2.0 while skipping -1.0. The final total is 12.0 and the final count is 3.
  • 1Divide only after checking that count is nonzero. The mean is 12.0 divided by 3, which equals 4.0.
  • 1The guard handles a list with no accepted values and prevents division by zero.
The accepted values sum to 12.0 across 3 items, so the mean is 4.0. The program must test count before division because every value may be rejected.
Sia tip — Write total and count after every accepted item. If one changes without the other, the filtered-mean invariant has been broken.
Glossary

Key terms

Argument
A value supplied to a function call and bound to the corresponding parameter for that call.
Boolean condition
An expression interpreted as true or false to control a branch or loop.
Dictionary
A mutable mapping from unique keys to values, designed for key-based lookup and update.
Expression
Code that evaluates to a value, possibly by combining literals, names, calls and operators.
Floating point
A finite binary approximation used to represent many non-integer numbers in Python.
Immutable object
An object whose stored value cannot be changed after creation, such as a string or tuple.
Loop invariant
A statement about program state that remains true after every completed iteration.
Mutation
A change to an existing object that can be observed through every name referring to it.
Return value
The value a function hands back to the expression that called it.
Short circuit evaluation
Left-to-right Boolean evaluation that skips an operand once the final truth value is known.
FAQ

COMP90059 FAQ

Do I need programming experience before starting?

No prior programming experience is assumed. Begin by learning the notebook workflow, then practise small traces that separate values, types, statements and output before combining them into longer programs.

What is the most important revision habit?

Predict a result before running the cell, record intermediate state, and then test a boundary variation. This turns execution into evidence and exposes whether your mental model matches Python.

How is the subject assessed?

The published structure includes a mid-semester test, two assignments, weekly Ed exercises and an end-of-semester written examination. The numeric weights total the complete subject grade.

Does the final examination have a hurdle?

Yes. The subject information states a hurdle of 30 out of 60 on the end-of-semester written examination, so revision must prepare for both the component weight and the minimum exam result.

Which Python environment should I use?

The teaching materials use Python 3 in Jupyter notebooks. A clean restart and run-all check is valuable because it reveals hidden dependencies between cells and stale values left in the kernel.

How should I debug unfamiliar code?

Reproduce the smallest failing case, classify the error, inspect values and types at the named line, change one cause, and rerun both the failing case and a case that already worked.

Chapter questions

Questions students ask in each COMP90059 chapter

Why can a notebook work in the wrong order?
The kernel remembers cells that ran earlier, even when they appear later on the page. Restarting and running from top to bottom reveals any value that was being borrowed from stale state and confirms whether the notebook is reproducible. Chapter 01 · Programming Foundations
Why does adding two quoted numbers not add them?
Quoted values are strings, so plus concatenates their characters. Convert the strings to an appropriate numeric type before applying numeric addition, and handle any conversion failure at the input boundary. Chapter 02 · Values, Variables and Expressions
Why does branch order matter?
An if and elif chain stops at the first true condition. A broad earlier condition can capture values intended for a narrower later condition before that specific test is reached. Chapter 03 · Boolean Logic and Conditionals
Why is the stop index excluded?
Half-open slices make the slice length equal stop minus start and let adjacent slices join without duplicating the boundary item, which simplifies both reasoning and loop boundaries. Chapter 04 · Strings and Sequence Operations
What is the difference between print and return?
Print sends a representation to output. Return sends a value to the caller so the surrounding program can store, test or combine it in later expressions. Chapter 05 · Functions, Return Values and Scope
When should I use a for loop?
Use a for loop when the program should visit items from a known iterable such as a list, string or range and does not need manual control of the iteration state. Chapter 06 · Iteration and List Processing
Does tuple immutability make every nested object immutable?
No. The tuple slots cannot be replaced, but a slot may refer to a mutable object that can still change through another reference and remain visible through the tuple. Chapter 07 · Tuples, Mutability and Debugging
Why not use only a set for ordered deduplication?
A set answers whether a value has appeared but does not by itself express the required first-seen sequence. A separate result list records that order while the set supports fast membership checks. Chapter 08 · Dictionaries, Sets and 2D Data
Why is write mode dangerous for an existing log?
Write mode replaces existing content. If the intention is to retain earlier records and add a new one, append mode expresses that effect, but the program should still validate the target path. Chapter 09 · Files and Recursive Functions
Study strategy

How to study for the exam

Move through three revision passes. First, trace small expressions, conditions and sequence operations until types and boundaries are automatic. Second, rebuild functions and loops from contracts: inputs, returned values, invariants, state updates and termination. Third, combine collections, files and recursion in mixed code-reading and construction tasks. Keep an error ledger organised by the broken assumption, not by week.

In timed practice, state the decisive rule beside every result and test at least one boundary. For the final examination, use the current LMS notice for section structure, permitted materials and logistics because the available current source publishes duration, coverage and the hurdle but not those operational details.

Study COMP90059 with AI

Your AI Computer Science tutor for COMP90059

Stuck on a hard COMP90059 question? Sia is AskSia’s AI Computer Science tutor — ask any COMP90059 Introduction to Programming question and get a clear, step-by-step explanation grounded in how the course is actually taught and assessed. Read this whole study guide free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 177 of your University of Melbourne subjects - and 1,000+ Bibles across every Australian university.
Sia - your COMP90059 tutor, unlimited, worked the way the exam marks it
The full 39-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works