Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Function basics
More advanced concepts


Good! Coming back to the previous example:

def calculate_price(weight, price_per_pound=1.5, tax=0.15):
  return weight * price_per_pound * (1+tax)

You may ask one more question: since optional arguments are assigned values from left to right, how can I invoke the function with explicit values for weight and tax, but not for price_per_pound?

The answer is simple: use argument names!

calculate_price(170, tax=0.89)

With this invocation, the values for the arguments would be: weight=170, price_per_pound=1.5 (default value), tax=0.89.


Given a function named calculate_cone_area, invoke the function with r=5, h=3, and the default value of pi.

Stuck? Here's a hint!

Provide argument names when you invoke the function.