# Stuck on Python Syntax Tip calculator

#1

Hi guys so I dont really understand this line of code I will paste it below.

# Assign the variable total on line 8!

meal = 44.50
tax = 6.75 / 100
tip = 15.0 / 100

meal = meal + meal * tax
total = meal + meal * tip

print("%.2f" % total)

So as you can see from above it says that the meal is equal to 44.50 but I am curious as to why I do meal + meal * tax as at the start it doesn’t say that we are paying for two meals. When I run the code I get and answer of £54.63 this puzzles me as I was expecting if you added the meal + meal it would come to 89 anyone tell me why this is.

Thanks Matty

#2

Hi @mccoyboy,

Regarding …

``````meal + meal * tax
``````

The value of `meal` is the cost of the meal before the tax is added.
Since `tax` represents the tax rate on a meal as a proportion of the price of the meal, `meal * tax` is the amount of the tax to be added to the price of the meal.
Therefore, `meal + meal * tax` is the cost of the meal plus the tax.

We are paying for only one meal, plus the tax on that meal, and finally the tip.

#3

Ahh I see now @appylpye Thanks very much for the help!

#4