The following are links to additional questions that our community has asked about this exercise:
This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!
Not seeing your question? It may still have been asked before – try () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().
Specifically, with positional parameters, only the position within the parentheses is important.
def my_function(x, y, z):
# code here involving variables x, y, z
return some_thing
# Now call it
apple = 7
orange = 8
pear = 10
print(my_function(apple, orange, pear))
The interpreter will assign the value 7 to the function parameter x, 8 to y, and 10 to z, solely due to the fact that x, y, and z have the same relative positions within the parentheses as do apple, orange and pear in the calling statement. The variable names matter not at all.
If the original function declaration had contained a variable name along with a default value, as def tax(bill = 1.00), then the original poster’s thought would have been valid, and the variable names would count. More on that here.
A very quick review of the first page returned by Dr. Google on the topic tilts about 60 - 40 on the side of post-tax tipping. At any rate, it’s certainly not a clear-cut majority either way
OK I tried to apply what I had learned so far and ask for an input, then do the calculation on the input value. Even making sure it gets converted into an integer. like so:
def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print ("With tax: %f" % bill)
return bill
def tip(bill):
"""Adds 15% tip to a restaurant bill."""
bill *= 1.15
print ("With tip: %02f" % bill)
return bill
meal_cost = input("Meal Cost :")
meal_cost = int(meal_cost)
meal_with_tax = tax(meal_cost)
meal_with_tip = tip(meal_with_tax)
However when I try to run this code it just says “EOFError: EOF when reading a line”. Is this a bug in the interpreter? Every way I look at it this should just work… Anyone able to help me with this?