Standard Library

Dr Andy Evans

[Fullscreen]

Core libraries

  • Scripts, by default only import sys (various system services/functions) and builtins (built-in functions, exceptions and special objects like None and False).
  • The Python shell doesn't import sys, and builtins is hidden away as __builtins__.

Built in functions

abs()
all()
any()
ascii()
bin()
bool()
bytearray()
bytes()
callable()
chr()
classmethod()
compile()
complex()
delattr()
dict()
dir()
divmod()
enumerate()
eval()
exec()
filter()
float()
format()
frozenset()
getattr()
globals()
hasattr()
hash()
help()
hex()
id()
input()
int()
isinstance()
issubclass()
iter()
len()
list()
locals()
map()
max()
memoryview()
min()
next()
object()
oct()
open()
ord()
pow()
print()
property()
range()
repr()
reversed()
round()
set()
setattr()
slice()
sorted()
staticmethod()
str()
sum()
super()
tuple()
type()
vars()
zip()
__import__()

Python Standard Library

Useful libraries: text

Collections

Useful libraries: binary data

Useful libraries: maths

Statistics

mean()
harmonic_mean()
median()
median_low()
median_high()
median_grouped()
mode()
pstdev()
pvariance()
stdev()
variance()
Arithmetic mean ("average") of data.
Harmonic mean of data.
Median (middle value) of data.
Low median of data.
High median of data.
Median, or 50th percentile, of grouped data.
Mode (most common value) of discrete data.
Population standard deviation of data.
Population variance of data.
Sample standard deviation of data.
Sample variance of data.

Random selection

  • Random library includes functions for:
    • Selecting a random choice
    • Shuffling lists
    • Sampling a list randomly
    • Generating different probability distributions for sampling.

Auditing random numbers

Useful libraries: lists/arrays

Useful libraries: TkInter

Turtle

Useful libraries: talking to the outside world

Databases