Built-in functions and help

  • Python comes with a number of built-in functions.
  • A function may take zero or more arguments.
print('hello')
print()
print(max(1,2,3,10))
print(min(5,2,10))
print(min('a', 'A', '0'))   # works with characters, the order is (0-9, A-Z, a-z)
print(max(1, 'a'))    # can't compare these
round(3.712)      # to the nearest integer
round(3.712, 1)   # can specify the number of decimal places
help(round)       # works everywhere, including the command line
round?            # Jupyter Notebook's additional syntax
?round            # same
  • Every function returns something, whether it is a variable or None:
result = print('example')
print('result of print is', result)   # what happened here? Answer: print returns None