1
Home
Tirsvad edited this page 2026-11-15 11:37:29 +01:00

English · Dansk · Bahasa Melayu

Coffee Machine

A console coffee machine: order a drink, pay with US coins and get your coffee, a refund or change.

What is it?

Day 15 of the Udemy course 100 Days of Code: The Complete Python Pro Bootcamp. A virtual coffee machine serves espresso, latte and cappuccino. It checks its water, milk and coffee before it serves, asks how many quarters, dimes, nickels and pennies you insert, refunds you if you pay too little and gives change if you pay too much. Type report to see the resources and the money in the machine, and off to switch it off.

What the exercise teaches

  • Splitting a program into small functions that keep the assignment's names
  • Storing the menu, coins and starting resources in constants and dictionaries
  • Counting money in whole cents so that change is never off by a rounding error
  • Writing automated pytest tests, and running a linter, a formatter and a type checker

What it does

  • Espresso, latte and cappuccino with their own ingredients and prices
  • A check of water, milk and coffee before a drink is served
  • Payment with quarters, dimes, nickels and pennies, with a refund or change
  • report shows the resources and the money earned; off switches the machine off

Next