01 / Specify
Known drinks only; whole positive quantities; prices in cents; unknown or invalid orders receive a clear message.
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.
This is the unchanged starter output; edits may intentionally change it.
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.
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.
Known drinks only; whole positive quantities; prices in cents; unknown or invalid orders receive a clear message.
Start from the receipt example. Extract a calculation function, add validation, then save and reload the order as CSV or JSON.
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.
The same cafe story connects requirements, responsibilities and Python objects. The class starter is deliberately small; quantity validation is a follow-up exercise.
Name the drinks, prices, quantities and output. Decide how an empty order and an invalid quantity should behave before choosing classes.
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.
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.
name · price_centslines[] · 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.