All lessons

Hello, Python · step 4 of 22

Lab: the tip calculator

Sign in if you want this lab saved to your progress.

Your first lab

Restaurants expect a tip on the bill. Build the calculator a cashier would use — it combines variables, maths and rounding.

Given for you

  • bill — the total on the receipt
  • tip_percent — the percentage to tip

Your program should print three lines:

  1. the tip amount, rounded to 2 decimals
  2. the total to pay, rounded to 2 decimals
  3. what each of 3 friends owes if the bill is split evenly, rounded to 2 decimals

Tip: build the values in named variables first (tip, total, per_person) — the autograder looks them up by name, and so will you when you read your code tomorrow.

Build it

Fill in the code, then run it. Every check has to pass for the lab to count.

lab-tip-calculator.py

Given for you

bill = 84.50
tip_percent = 18