Home > Software engineering >  How do I make use of the math symbols in a string (Python) it keeps concatenating
How do I make use of the math symbols in a string (Python) it keeps concatenating

Time:06-15

Good day, I'm new to this and I need help!

print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("What tip should we give? 12, 15, 20? "))
people = input("How many people are spliting the bill? ")
total_bill = (f"{bill} * {tip / 100} / 5")
print(total_bill)

The only symbol that ran was the one in the braces. I have tried various lines to get it done but no luck. the only time it worked was when i kept in the tip(0.12) directly. Can't even remember how anymore.. Please help!

CodePudding user response:

When I run your code with bill = 120, tip = 15, people = 4 I get:

120.0 * 0.15 / 5

Apart from the fact that your don't use 'people' in the rest of your code why don't you just do something like:

total_bill = int(bill)*(1 int(tip)/100)
bill_per_person = total_bill/int(people)
print('The total bill is $', str(total_bill), 'and each person needs to pay $', str(bill_per_person))
  • Related