I have a question about adding sums/how python sees numbers


#1

I’m doing this exercise:

Assign the variable total on line 8!

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

meal = meal + meal * tax

This isn’t making sense what it’s telling me to do. Surely meal + meal * tax would be 44.50+44.50 (89)

So it’s telling me to do 89.0 * tax instead of 44.50 * tax

Shouldn’t the actual code be

Assign the variable total on line 8!

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

meal = meal + (meal * tax)

That is saying 44.50 * tax instead of 89.0 * tax that the code codeacademy is telling me to put?


#2

order of operations, multiplying comes before adding, so the multiplying happens before adding:

http://www.purplemath.com/modules/orderops.htm


#3

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