Python Python Basics All Together Now Cleaner Code Through Refactoring

grantcenter
grantcenter
8,345 Points

Question on calling the service charge function

I had almost everything right in my code except i was originally calling the function like:

amount_due = calculate_price

instead of:

amount_due = calculate_price(number_of_tickets)

I guess my question is why do you have to include the (number_of_tickets) part when calling the function? Is that actually a part of the function name? Just a little confused because earlier it felt like that was just a placeholder

1 Answer

Steven Parker
Steven Parker
186,662 Points

The "number_of_tickets" is what is known as an argument to the function. The function uses this value to compute the amount. It is the value of the argument that is assigned to the parameter, which is the placeholder that was used in the function definition.

And FYI: even when a function doesn't need any arguments, you still must put parentheses after the name when you call it.