Reassign in a single line


#1

Reassign meal on line 7!

meal = 44.50
tax = 0.0675
tip = 0.15

meal+meal*tax

It was not working what to do guyz.


#3

Thanks....cssninja


#4

Supplemental

Using augmentation assignment and a little math knowledge, we can rewrite the equation as follows:

meal *= 1 + tax

This isn't important to know, but it is handy.

Try it. Let meal equal 10.

meal = 10
tax  = 0.0675  (6.75 %)
tip  = 0.15    (15 %)

First let's figure the tip amount on the bill:

tip_amount = meal * tip        # 1.50
meal *= 1 + tax                # 10 * 1.0675 == 10.68
total = meal + tip_amount      # 12.18

Always fun to play with numbers!


#5

Thank you so much :grinning:


#6

2 posts were split to a new topic: How can *= be a function?


How can *= be a function?
#7