Skip to main content

4.3) Module Content And Help


To get a list of functions and objects in a module, use the function 'dir()'.

>>> import math
>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh',
'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf',
'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']

Ignore the ones with underscore in the name, they’re only important for advanced level Python programming. To find out more about what the listed functions/objects are and do, use the help() function:

>>> help (math.factorial)

Using the 'dir' and 'help' functions, identify which functions:

  1. compute the logarithm in base 10
  2. translate an angle from degrees to radians

Practice: Import the module 'random' and use the dir and help functions to explore this module.