Functions

Libraries and import statements

Writing your own functions

def name(parameters)
  statements
def fahrenheit_to_celsius(f):
  """ Converts a temperature in Fahrenheit to Celsius """
  c = 5/9*(f-32)
  return c

Type annotations

def duplicate(msg):
    """Returns a string containing two copies of `msg`"""

    return msg + msg
def duplicate(msg: str) -> str:
    """Returns a string containing two copies of `msg`"""

    return msg + msg