Paul's Python CoursePPC

The standard library

Not met yet

Python ships with a shelf of modules you only have to import. math has ceil, floor and sqrt; datetime handles dates, times and the gaps between them; collections.Counter counts things; itertools has tools for loops, like accumulate for running totals. Look on the shelf before you build your own.

Try it

main.py

Output

Press Run and what your program prints shows up here.

Easy to get wrong

  • Thinks datetime's weekday() counts from Sunday, or from 1. It counts Monday as 0.
  • Thinks math.ceil rounds to the nearest whole number, rather than always up.
  • Thinks Counter's most_common(1) gives back just the item, rather than a list of (item, count) pairs.

Where it comes up