<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># charge le generateur aleatoire
from random import *
# charge les fct. math.
from math import *

# definition d'une liste pour le for
L=[200, 1000, 4000]
for N in L:

    # calcul de pi par la methode de Monte-Carlo
    # Utilisation de N flechettes
    
    # initialisation du numerateur
    c=0.0
    for i in range(0,N):
        x=random()
        y=random()
        R=x*x+y*y
        if (R&lt;1):
            c=c+1

    c=4*c
    p=c/N
    print "Pi ~= ", p,"\terreur: ", abs(pi-p), "\talpha:", 17/sqrt(N)
</pre></body></html>