Tip Calculator

Calculate tip and total bill.

BeginnerPhase 6 - Category 5: Real-World Logic ProblemsExample 10 of 15
tip-calculator.py
1# Take inputs
2bill = float(input("Enter bill amount: "))
3tip_percent = float(input("Enter tip percentage: "))
4people = int(input("Enter number of people: "))
5
6# Calculate
7tip_amount = (bill * tip_percent) / 100
8total = bill + tip_amount
9per_person = total / people
10
11print(f"Tip amount: {tip_amount:.2f}")
12print(f"Total bill: {total:.2f}")
13print(f"Per person: {per_person:.2f}")

Output

Enter bill amount: 100
Enter tip percentage: 15
Enter number of people: 4
Tip amount: 15.00
Total bill: 115.00
Per person: 28.75

What's going on

Calculate tip and split bill.

Key Concepts:

Calculate tip amount
Add to bill for total
Divide by number of people