# If meal = 44.50, then why isn't meal + meal = 89.00 (before tip or tax calculation) What am i missing?

#1

Replace this line with your code.

#2

that is confusing, isn't it? when you have something like this:

x = 5
x = x + 3

you get 8, on the second line you store a value in a variable, this value is x (the current value of x, which is 5) + 3, which results in 8

#3

In this example:
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)

I am just thinking and wondering if it the order of the calculations.
Multiplication first?
So its 44.50 * 0.0675 = 3.00 then + 44.50 = 47.50
(approx. calculations)

#4

yea, multiplication is first (order of operations), that is why you have meal + meal. If its confusing you can also do it in two steps:

temp_tax = meal * tax
meal = meal + temp_tax

#5

Thank you for your help, I really appreciate it

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.