INITIAL CODELAB / TEACH

Teach Python

Prepared input / stdin

Enter answers before running. Input is not echoed. Missing lines produce EOFError. Reset restores the example inputs.

Ctrl / ⌘ + Enter to run. Tab inserts four spaces; Esc leaves the editor. Every run starts with fresh Python variables and a temporary folder.

OUTPUT
Predict first · reveal original output

This is the unchanged starter output; edits may intentionally change it.

Quick self-check

Reveal explanation

Practice marks are your own checklist, saved in this browser. Code and prepared input are not saved with the marks.

Python loads on the first run (about 14 MB) and executes in this tab. Runs have a 10-second execution limit. Files are temporary browser files, not files on your computer. Download code to keep it.

Cafe project brief & object design
PRACTISE INDEPENDENTLY

Your next build: the Latte Cafe order desk.

Combine the ideas in your own version. The lab runs each example independently; combine the required pieces explicitly instead of relying on variables or files from earlier runs.

01 / Specify

Known drinks only; whole positive quantities; prices in cents; unknown or invalid orders receive a clear message.

02 / Build in small steps

Start from the receipt example. Extract a calculation function, add validation, then save and reload the order as CSV or JSON.

03 / Review the evidence

Check two lattes plus one tea total 1200 cents, an empty order totals zero, and invalid quantities are rejected. Explain why each check exists.

In one-to-one online sessions, we can review your trace, debugging decisions and explanation, then choose the next exercise. These are studio-authored examples; UOW’s public subject descriptions inform topic coverage, not university affiliation or official assessment preparation.

OOA → OOD → OOP

Design the cafe before adding classes.

The same cafe story connects requirements, responsibilities and Python objects. The class starter is deliberately small; quantity validation is a follow-up exercise.

OOA

Understand the order

Name the drinks, prices, quantities and output. Decide how an empty order and an invalid quantity should behave before choosing classes.

OOD

Assign responsibilities

MenuItem owns its name and unit price. Order owns its lines and total. An order contains menu items through composition, rather than inheriting from an item.

OOP

Implement and check

Run “Model a cafe order”. Create separate orders, inspect their state and add validation. Check two lattes total 900 cents and an empty order totals zero.

MenuItemname · price_cents
Orderlines[] · add(item, quantity)
total_cents()

self refers to an instance. Each Order creates its own lines list in __init__; a mutable class-level list would be shared across orders.

Website privacy

This page has no enquiry form, analytics service, or third-party font requests. Your language, appearance, and motion preferences are stored locally in this browser when storage is available.

If the site is hosted, the hosting provider may process standard request logs. Any future contact service will need its own information handling details.