Why is this wrong: meal = 44.50 tax = meal*0.0675 tip = (meal + tax)*0.15 total = meal + tax + tip print total

meal = 44.50
tax = meal*0.0675
tip = (meal + tax)*0.15
total = meal + tax + tip
print total

get error message…seems right to me…but maybe you want one step at a time?

You only want to print 2 decimal places.

print("%.2f" % total)

2 Likes

I think that this exercise is built so it recognizes only one possible way of solving this problem.

According to my example: When I typed on the second step:

meal = 44.5
tax = 1.0675

It gave me the answer that 1.0675 did not look like 0.0675. But by having a number one before the point it gives you meal + meal * tax

Then total is just simply a sum of meal, tax and tip (which was 1.15).

But it did not go through :slight_smile:

meal = meal + meal *tax

I agree; however when I type that on line 1 it is rejected

It keep showing the message: “Did you declare a variable called meal?” But i think i already declare meal!!?

variable_meal = 44.50
variable_tax = variable_meal * 0.0675
variable_mealntax = variable_meal + variable_tax
variable_tip = variable_mealntax * 0.15
variable_total = variable_meal + variable_tax + variable_tip
print variable_total

■■■■■■ ■■■■! I am having the same issue and that’s why I opened the forum Q&A.
Here is a screenshot:

Assign the variable total on line 8!

meal = 44.50
tax = 0.0675
tip = 0.15

meal = meal + meal * tax
total=44.50+44.50*0.15

print("%.2f" % total)

Oops, try again. It looks like the printed output is 51.17 instead of 54.63. Double check the instructions!

You need to declare the variable as meal, not variable_meal or else the program won’t recognize it

This should fix things.

2 Likes

This post was flagged by the community and is temporarily hidden.

it did, thanks a lot.

here is my way:

meal = 44.5
tax = 0.0675
tip = 0.15
cost = meal + meal * tax
total = cost + cost * tip
print total

Reatribua meal na linha 7!

meal = 44.5
tax = 0.0675
tip = 0.15

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

print total

you have to code like

total = meal + meal * tip

It will print 54.63

Explanation:
These variables names are already assigned with the values and just related them.

meal = 44.50
tax = 0.0675
tip = 0.15

I’m beginner too. Just learning.

Hello Im doing this and give a wrong result…

Someone can help me?
Thanks
Leandro

The total on line 8 needs to take into account both the tax and the tip. The idea of line 5 is to re-assign the variable meal so that it takes into account the tax. Therefore, by using the meal variable in the total you only have to account for the tip.

total = meal + meal * 0.15

The way you have written it (using the original value for meal) means that the tax is not taken into account.

Hope that helps

Hello!
You help me to resolve, thank you!!! :grinning:

here is my version.

meal = 44.50
tax = 0.0675
tip = 0.15
cost = (meal * tax) + meal
totalCost = (cost * tip) + cost
print (totalCost)

1 Like

I am having trouble getting the right answer. Every time I run the code its giving me the answer 54.62 not 54.63, which it says is the correct answers.
I’m running it as follows :
total = 47.50 + 47.50 * 0.15

What am I doing wrong?

Hello, I like your version, thank you!