Replace this line with your code.
If meal = 44.50, then why isn't meal + meal = 89.00 (before tip or tax calculation) What am i missing?
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
Thank you for the reply.
I understand your code.
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.
So its 44.50 * 0.0675 = 3.00 then + 44.50 = 47.50
Thanks again for your reply
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
Thank you for your help, I really appreciate it
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.