Tip calculator

def tip_calculator(): print("--- Tip Calculator ---") try: bill = float(input("Enter the total bill amount: $")) tip_percent = float(input("Enter the tip percentage (e.g., 15 for 15%): ")) people = int(input("Enter the number of people splitting the bill: ")) tip = (tip_percent / 100) * bill total = bill + tip per_person = total / people if people > 0 else total print(f"\nTip amount: ${tip:.2f}") print(f"Total bill with tip: ${total:.2f}") print(f"Amount per person: ${per_person:.2f}") except ValueError: print("Invalid input. Please enter numeric values.") # Run the calculator tip_calculator()

Code output

--- Tip Calculator --- Enter the total bill amount: $80 Enter the tip percentage (e.g., 15 for 15%): 10 Enter the number of people splitting the bill: 2 Tip amount: $8.00 Total bill with tip: $88.00 Amount per person: $44.00