hands-on labIDE in your browserfree

Boss: Opening Morning

Level 1's boss. Doors open at 8:00 and the till has to take every order and print an exact receipt: names typed any way, hidden orders, then a new item and new prices halfway through the morning.

time
35 min
checked steps
3
level
Beginner
setup
None

Freeone of 170+ labs in Pro

free · no account needed to start

The job

8:00. Bean There opens its doors and the queue is already out of the door. Your till has to take each customer's order and print a receipt Sam can hand over without checking it. It starts with one easy order. Then the morning crowd arrives, typing their names however they like, and you can't see their orders, only how many receipts came out right. At 9:00 Sam adds brownies and changes the prices. Win all three phases to beat the level.

3 steps, each checked when you finish it

A check runs your work at the end of every step. Hints and the full solution are there if you get stuck.

  1. 1

    Phase 1: The first customer

    Boss rules.

    read this step below ↓

  2. 2

    Phase 2: The morning crowd

    8:15.

  3. 3

    Phase 3: The price change

    9:00.

The lab, step by step

The free lab’s own text, every step of it. Hints and solutions stay inside the lab.

Step 1: Phase 1: The first customer

Phase 1: The first customer

Boss rules. One file, till.py. Receipts must match exactly, space for space. From Phase 2 on, the check serves customers you can't see and tells you how many receipts came out right, and what the first wrong one looked like. The hint nudges; it won't write the till for you.

The till. Prices are kept in whole pennies, the way tills keep money exact: FLAT_WHITE = 320 means £3.20. Your till asks three questions, in this order: the name, how many flat whites, how many croissants. Then it prints the receipt. For Sam, two flat whites and one croissant:

Bean There, receipt for Sam
2 x Flat white        £6.40
1 x Croissant         £2.45
Total                 £8.85
Thank you, see you tomorrow!

What you need from Level 1:

  • input("Name: ") asks a question and gives back what was typed, always as text. int(input("Flat whites: ")) turns the answer into a whole number.
  • Work out each amount in pennies (quantity times price) and turn pennies into pounds only when you print: f"£{pennies // 100}.{pennies % 100:02d}". The :02d keeps the zero in £3.05.
  • The middle lines line up: the description padded to 20 characters on the left, then the amount right-aligned in 7. In an f-string: f"{description:<20}{amount:>7}".

Press Run to play Sam at the till: customer.py types Sam's three answers for you. To serve someone yourself, type python3 till.py in the terminal and answer the questions. Press Check when the receipt matches. The check serves Sam and one more customer.

till.py, the file you edit6 lines
# Bean There's till. Prices are in whole pennies: 320 means £3.20.
FLAT_WHITE = 320
CROISSANT = 245

# Your till: ask for the customer's name, how many flat whites and how many croissants,
# then print their receipt. The brief on the right shows it exactly.

provided for you:customer.py

Step 2: Phase 2: The morning crowd

Phase 2: The morning crowd

8:15. The queue is out of the door, and customers type their own names on the order screen: priya shah, ALEX KIM, jo. Sam wants every receipt to show the name tidy, with a capital at the start of each word and no stray spaces:

Bean There, receipt for Priya Shah
3 x Flat white        £9.60
2 x Croissant         £4.90
Total                £14.50
Thank you, see you tomorrow!

The check now serves five customers you can't see. Some type numbers with spaces around them, some order a lot, some order nothing of one item. It tells you how many receipts came out right, and shows the first wrong one: what the customer typed, what your till printed and what it should have printed.

till.py starts from Phase 1's till. Press Run to serve Priya, then Check to face the crowd.

till.py, the file you edit23 lines
# Bean There's till. Prices are in whole pennies: 320 means £3.20.
FLAT_WHITE = 320
CROISSANT = 245

name = input("Name: ")
flat_whites = int(input("Flat whites: "))
croissants = int(input("Croissants: "))

flat_white_pennies = flat_whites * FLAT_WHITE
croissant_pennies = croissants * CROISSANT
total_pennies = flat_white_pennies + croissant_pennies

flat_white_line = f"{flat_whites} x Flat white"
croissant_line = f"{croissants} x Croissant"
flat_white_amount = f"£{flat_white_pennies // 100}.{flat_white_pennies % 100:02d}"
croissant_amount = f"£{croissant_pennies // 100}.{croissant_pennies % 100:02d}"
total_amount = f"£{total_pennies // 100}.{total_pennies % 100:02d}"

print(f"Bean There, receipt for {name}")
print(f"{flat_white_line:<20}{flat_white_amount:>7}")
print(f"{croissant_line:<20}{croissant_amount:>7}")
print(f"{'Total':<20}{total_amount:>7}")
print("Thank you, see you tomorrow!")

provided for you:customer.py

Step 3: Phase 3: The price change

Phase 3: The price change

9:00. Sam comes out of the kitchen: "Brownies are out of the oven, £2.75 each. And the prices change during the day from now on, so the till must never have a price typed into a sum."

  1. Add BROWNIE = 275 under the other two prices.
  2. Ask a fourth question, after croissants: how many brownies.
  3. Print a brownie line after the croissant line, and add the brownies to the total.

Sam's receipt now reads:

Bean There, receipt for Sam
2 x Flat white        £6.40
1 x Croissant         £2.45
1 x Brownie           £2.75
Total                £11.60
Thank you, see you tomorrow!

The final check changes FLAT_WHITE, CROISSANT and BROWNIE to the afternoon's prices and serves more customers you can't see. Some of the new amounts end in a single penny digit, like £9.05, and some customers skip an item altogether.

Win this phase and the till has survived opening morning: that's Level 1.

till.py, the file you edit23 lines
# Bean There's till. Prices are in whole pennies: 320 means £3.20.
FLAT_WHITE = 320
CROISSANT = 245

name = input("Name: ").strip().title()
flat_whites = int(input("Flat whites: "))
croissants = int(input("Croissants: "))

flat_white_pennies = flat_whites * FLAT_WHITE
croissant_pennies = croissants * CROISSANT
total_pennies = flat_white_pennies + croissant_pennies

flat_white_line = f"{flat_whites} x Flat white"
croissant_line = f"{croissants} x Croissant"
flat_white_amount = f"£{flat_white_pennies // 100}.{flat_white_pennies % 100:02d}"
croissant_amount = f"£{croissant_pennies // 100}.{croissant_pennies % 100:02d}"
total_amount = f"£{total_pennies // 100}.{total_pennies % 100:02d}"

print(f"Bean There, receipt for {name}")
print(f"{flat_white_line:<20}{flat_white_amount:>7}")
print(f"{croissant_line:<20}{croissant_amount:>7}")
print(f"{'Total':<20}{total_amount:>7}")
print("Thank you, see you tomorrow!")

provided for you:customer.py

what you get

  • An editor and terminal in your browser
  • A check at the end of every step
  • Hints and the full solution
  • Nothing to install or configure

before you start

  • Level 1's quests: print, variables, f-strings, string methods, input and whole-penny money

Part of the Learn Python track

Lab 5 of 15. Learn Python by running a café till: receipts, orders, discounts and the Friday rush. Nothing to install.

Questions about this lab

Can I see the hidden orders?

When a receipt is wrong, the checker shows that order's input, what your till printed and what it should print.

How a boss lab works

A boss lab ends each level. It asks for the level's skills at once, gives you the exact output to produce and checks your program against orders you can't see. Phases get harder as you go, and the checker tells you how many receipts were right and what the first wrong one looked like.