Source: https://www.irif.fr/~sangnier/enseignement/16-17/Ip1-Python/IP1-Python-cours-td-1-4.pdf