The Total


#1

Hi I am having issues with this my problem is when i set total = meal and it runs the code it outputs 47.50 instead of 54.63

# Assign the variable total on line 8!

meal = 44.50
tax = 0.0675
tip = 0.15

meal = meal + meal * tax
total = meal

print("%.2f" % total)

#2

Hi!

You've not dealt with the instruction as it relates to this line.

You are told to:

Assign the variable total to the sum of meal + meal * tip on line 8

The right-hand side will be similar to that of line 7 code. Just replace tax with tip.

Hope this helps! :smile:


#3

The reason i used Total = meal was because I thought when you change a variable as shown then call the variable you changed it would be updated with the change. Is that wrong?


#4

The scenario you pictured will be of a loop/function, where a recursion occurs. The difference is, instead of having it as meal multiplied by tax, it needs to be multiplied by tip and so, line 7 won't do the job.

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

meal will give 47.50 while total will output 54.63. Assigning is what's happening here, really.

Err.. I hope I helped! :wink:


#5

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