Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
Function basics
More advanced concepts


def calculate_price(weight, price_per_pound=1.5, tax=0.15):
  """Calculate price for a amount
  Keyword arguments:
  weight -- weight expressed in pounds
  price_per_pound -- price paid per one pound
  tax -- the tax value that needs to the price
  return  weight * price_per_pound * (1+tax)

In Python, anything put between """ and """ will be treated as a documentation string for a given function. Note where we placed the documentation: it comes right after the line beginning with def function_name, and is indented together with the function body.

Documentation strings (or docstrings) are a convenient way to provide documentation for a function: what it does, what parameters it expects, etc.


There are many conventions and best practices related to writing function documentation in Python. If you're interested, to find out more, read PEP257.

Click Next exercise to continue.