Logic Building
# Take inputs
bill = float(input("Enter bill amount: "))
tip_percent = float(input("Enter tip percentage: "))
people = int(input("Enter number of people: "))
# Calculate
tip_amount = (bill * tip_percent) / 100
total = bill + tip_amount
per_person = total / people
print(f"Tip amount: {tip_amount:.2f}")
print(f"Total bill: {total:.2f}")
print(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
Calculate tip and split bill.
Key Concepts:
- Calculate tip amount
- Add to bill for total
- Divide by number of people