fromkandinskyimportdraw_string,fill_rectfromionimportkeydown,KEY_OKdefpi_ultra_light():# Setup ecran initial
BG=(255,255,255)fill_rect(0,0,320,222,BG)draw_string("PI EN DIRECT",100,5,(0,0,255))# Parametres : 500 decimales pour ne pas saturer la RAM
n=500len_a=int(10*n/3)+1try:a=[2]*len_aexceptMemoryError:draw_string("Erreur RAM",10,50,(255,0,0))returnx,y=10,50cnt=0forjinrange(n):q=0foriinrange(len_a-1,-1,-1):x_val=10*a[i]+q*(i+1)a[i]=x_val%(2*i+1)q=x_val//(2*i+1)a[0]=q%10digit=q//10# Formatage du texte
char=str(digit)ifcnt==0:char+="."# Affiche "3." au tout debut
# Affichage du compteur (on efface juste le chiffre precedent)
fill_rect(110,25,100,18,BG)draw_string("Decimales: "+str(cnt),10,25,(255,0,0))# Affichage de la decimale
draw_string(char,x,y,(0,0,0))# Calcul de la position suivante
# Si c'est "3.", on decale un peu plus
x+=20ifcnt==0else10ifx>300:x=10y+=18# Si on arrive en bas de l'ecran
ify>200:# On efface la zone de texte mais on garde le titre
fill_rect(0,50,320,172,BG)x,y=10,50cnt+=1# Touche OK pour stopper manuellement
ifkeydown(KEY_OK):breakdraw_string("TERMINE",120,205,(0,150,0))# Lancement direct
pi_ultra_light()
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.