diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index e5ac8f3e896ed1655c2091431564a092eb4d0c17..4a5f57d3d09e4e834d1ae2cca91f6ca4be7c400f 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -15,7 +15,7 @@ Mon ordinateur m'indique que \(\pi\) vaut /approximativement/: -#+begin_src python :export both :session "Python" +#+begin_src python :results value :session "Python" :exports both import math math.pi #+end_src @@ -29,7 +29,7 @@ Mais calculé avec la *méthode* des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme *approximation*: -#+begin_src python :session "Python" +#+begin_src python :results value :session "Python" :exports both import numpy as np np.random.seed(seed=42) N=10000 @@ -50,7 +50,7 @@ intervenir d'appel à la fonction sinus se base sur le fait que si Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80). Le code suivant illustre ce fait: -#+begin_src python :session "Python" :export both +#+begin_src python :results output file :var matplot_lib_filename="figure_pi_mc2.png" :session "Python" :exports both import matplotlib.pyplot as plt np.random.seed(seed=42) @@ -71,15 +71,21 @@ print(matplot_lib_filename) #+end_src #+RESULTS: -: +[[file:]] Il est alors aisé d'obtenir une approximation (pas terrible) de \(\pi\) en comptant combien de fois, en moyenne, \(X^2+Y^2\) est inférieur à 1: -#+begin_src python :session "Python" +#+begin_src python :results output :session "Python" :exports both 4*np.mean(accept) #+end_src #+RESULTS: : 3.112 +: +: + + +]] +