# Assign the variable total on line 8! meal = 44.50 tax = 0.0675 tip = 0.15 meal = meal + meal * tax total = meal + meal*tax print("%.2f" % total) Oops, try again. It looks like the printed output is 50.71 instead of 54.63. Double check the instructions!
It's suppose to be right? What is wrong? Oops, try again. It looks like the printed output is 50.71 instead of 54.63. Double check the instructions!
It didn't ask for that and either way, still didn't work. it gave 50.86 =/= 54.63 (what it wants)
And if you used....
meal = 44.50 tax = 0.0675 tip = 0.15 meal = meal + meal * tax total = meal + meal*tip print("%.2f" % total)
This exercise has us calculate the tip as a percentage of meal AND tax. That means,
m = 100 t = 6.75 / 100 g = 15 / 100 m1 = m + m * t m1 = m * ( 1 + t ) m2 = m1 + m1 * g m2 = m1 * ( 1 + g ) but, m1 = m * ( 1 + t ) giving, m2 = m * ( 1 + t ) * ( 1 * g )
total = meal * (1 + tax) * (1 + tip)
A different perspective that runs counter to the above...
m = 100 x = 6.75 / 100 g = 15 / 100 t = m * 1 + m * x + m * g t = m * (1 + x + g)
total = meal * (1 + tax + tip)
Another way of calculating it. This time the tip (gratuity) is calculated against the retail price, tax not included.
I keep getting message "Oops, try again. It looks like meal is set to 47.50375 instead of 44.50." I have reset the code and even copy and pasted your code given above but i still get the same answer. It seems the the code is not calculating the tip. It looks like meal is set to 47.50375 instead of 44.50. Do you know of any bugs or am I doing some thing stupid?
I hope you can help as I am keen to progress. Thanks.
Depending on which section you are in
The Meal ==> meal = 44.50
The Tax ==> tax = 0.0675
The Tip ==> tip = 0.15
Reassign in a Single line ==> should result in 47.50375
The total ==> 54.63
Hi, I really appreciate you taking the time to reply.
What do you mean reassign in a single line? I have assigned the variable meal the value 44.50 on line 3! Do you think this is an editor issue rather than a code issue. Please forgive any stupid questions that I ask
I mentioned the =Section= names....
Give us the FULL code you are using
and also specify in which Section you are using the code......
1# Assign the variable meal the value 44.50 on line 3!
3 meal = 44.50
4 tax = 0.0675
5 tip = 0.15
7 meal = meal + meal * tax
8 total = meal + meal * tip
10 print("%.2f" % total)
Do you mean remove all the empty lines from 4 downward. I tried that, but i am still getting the same error.
Not to worry, I will move on as it's not worth wasting anymore time on it.
I really appreciate your help, thanks.
That worked for me...