notebook to python functions