Practice using arithmetic operators and string formatting to build a useful program.
Create a tip calculator that:
When your program runs, it should look something like this:
Enter your bill amount: 42.50
Enter tip percentage: 20
Bill: $42.50
Tip (20%): $8.50
Total: $51.00
# input() always returns a string, so convert to float for math
bill = float(input("Enter your bill amount: "))
tip_percent = float(input("Enter tip percentage: "))
tip_amount = bill * (tip_percent / 100)
total = bill + tip_amount
print(f"Bill: ${bill}")
print(f"Tip ({tip_percent}%): ${tip_amount}")
print(f"Total: ${total}")
Write your tip calculator in the code cell below. Test it with different bill amounts and tip percentages to make sure it works correctly.
Bonus Challenge: Try calculating tips for a few different scenarios:
from math import floor
bill = float(input("Entry your bill amount: "))
tip = float(input("Entry your tip amount: "))
total = bill * (1 + (tip / 100))
total = total * 100
total = floor(total)
total = total / 100
print(f"Your total was ${total}")
Entry your bill amount: 99 Entry your tip amount: 8.25 Your total was $107.16