In terms of math, how is meal + meal not 89? (meal = 44.50)


#1

This is the code
meal = 44.50
tax = 0.0675
tip = 0.15

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

print("%.2f" % total)
With Meal being 44.50, the way i see it (as a complete noob) is 44.50 + 44.50 * 00.675. At this point i see 89 * 0.0675... just a bit confused. Because i know the answer is 54.63... it just doesn't add up


#2

Multiplication has higher precedence than addition


#3

@surridge ,

See 5.15. Operator precedence.


#4

This it the order of precedence:

Brackets
Orders (powers/roots)
Division
Multiplication
Addition
Subtraction


#5

what does this print command mean


#6

Maybe try to see it like this:

total = meal + (meal * tip)


#7

I learned it as P.E.M.D.A.S back in the day.