Tip Calculator example code block


Can anyone please explain where/how the variable bill is defined within this block of code for the Tip Calculator? I see where meal_cost is defined, but I don’t see how the value for meal_cost is called by the code (hope that makes sense) or connected to the variable bill.

Thank you,



line 14 passes meal_cost’s value to a function

You might or might not have talked about functions in math class, you’d have something like this:

f(x) = x + 1

Which is a function that adds 1 to the value that is provided to it, and once that is defined you can use:

to get the value 3

At the time that the function is defined its input value is unknown, but just the same a name is needed to express what the result is


Perfect, the math function example makes total sense. Thank you!


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