Practice: Build a Tip Calculator
Time to build something real using everything from this week: variables, types, operators, input, and formatted output.
Your tip calculator should:
- Ask for the bill amount
- Ask for a tip percentage
- Calculate the tip amount and the total (bill + tip)
- Print both, each formatted to exactly 2 decimal places, using f-strings
Work through it in the code editor below. This is graded — your tutor can see exactly what you submit.
Build a Tip Calculator
Write a program that:
- Asks for the bill amount (
input(), converted tofloat) - Asks for a tip percentage (
input(), converted tofloat) - Calculates the tip amount:
bill * (tip_percent / 100) - Calculates the total:
bill + tip_amount - Prints the tip and total, each formatted to exactly 2 decimal places using an f-string, in the format
Tip: $X.XXandTotal: $X.XX