Python functions for cosmology