Python Tutorial · Revision notes

Python Modules

A module is a Python file with reusable code. You will learn how to import modules and use the standard-library modules math, os, random, statistics, sys and collections.

Quick revision

  • Module = .py file; import, import as, from ... import
  • math: sqrt, ceil, floor, factorial, gcd, pi (radians for trig)
  • os: getcwd, listdir, makedirs, path.join, exists, remove
  • random: randint (both ends), randrange (stop excluded), choice, sample, shuffle
  • statistics: mean, median, mode, pstdev vs stdev
  • sys: argv (strings), exit, path, platform, getsizeof
  • collections: Counter, defaultdict, deque, namedtuple
Read the full Python Modules notes on Doubtclip →