Code Academy's bullshit!
1 04 Feb 2016 07:24 by u/rocketmaster
So, i was told to calculate this:
meal = 44.50 tax = 0.0675 tip = 0.15
Here's what i was told to do: meal * tax, and then add the tip to get 47.50. It keeps returning 3.75 or some such nonsense instead of that. HOW DO I DO IT??? I was never told Python was just a calculator. It's NOT a programming language at all!
8 comments
2 u/ElementalPee 04 Feb 2016 18:54
It sounds like maybe you're not including the cost of the original meal in your total. There are a couple ways to do that. You could just add in the original meal price at the end, or you could multiply it by 1.0675 instead of 0.0675.
0 u/european 04 Feb 2016 18:33
Is tip based on pre tax?
0 u/MagicalCentaurBeans 04 Feb 2016 18:49
CodeAcademy has a lot like this. Ambiguous and somewhat pointless. There is a correct answer, and when you find out what it is, you're going to feel shafted. Like when your big sister would ask if you wanted to go to the theme park and you scream "yes!" and she shoots back "today's opposite day"
0 u/rocketmaster [OP] 04 Feb 2016 19:12
Did i mention i was supposed to reassign the value of meal, too?
0 u/ElementalPee 04 Feb 2016 19:28
Would you mind pasting the exact assignment wording? Something seems off here. $47.50 looks like it would be the right total for the meal and the tax but adding in the tip puts it over. Even just the meal plus tip, completely ignoring the tax, puts it over $51.
0 u/Schrodingers_Spy 04 Feb 2016 21:03
Can confirm - I've done this lesson, and it's operator error.
Double check the instructions - and your code. If you continue to get stuck, you can post your code here or there.
0 u/rocketmaster [OP] 04 Feb 2016 22:33
Here's the "hint" i was given:
Let's see: meal * tax will give you the number of tax dollars to put on your bill, and meal + that number will give you the cost of the meal + tax!
The interpreter will evaluate the right-hand side of the equation first. It will ask itself, "What's meal * tax?" Once it does this and gets the result (about 3.00), it will ask itself, "What's meal + this number?" (44.50 + about 3.00 = about 47.50.) Finally, it'll move to the left-hand side of the equation and say, "Oh man, I should totally reassign meal (which was 44.50) to this new value of about 47.50." And that's how meal gets reassigned!
0 u/Grospoliner 04 Feb 2016 23:45
Are you adding a 1 before your % increases?
Meal = 44.5
Tax = 6.75%
Tip = 15%
That would return a cost of:
44.50(1.0675) = 47.5
47.5(1.15) = 54.6 (for tipping on tax)
or
47.5 + 44.5(.15) = 54.175 (for tipping on meal)