boulier.py

Created by ppf-dufour

Created on February 17, 2024

1.01 KB

Permet de s’entraîner au boulier


from math import *
from random import *
from time import *
question=eval(input("Combien d'opérations ?"))
score=0
for q in range(0,question) :
    print("Question "+str(q+1)+"/"+str(question))
    nbre1=randint(1000,9999)
    nbre2=randint(1000,9999)
    op=input("+ , - , x , / ? ")
    if op=="+":
        sol=str(nbre1+nbre2)
    elif op=="-" :
        sol=str(abs(nbre1-nbre2))
    elif op=="*" :
        nbre1=int(nbre1/100)
        nbre2=int(nbre2/100)
        sol=str(nbre1*nbre2)
    elif op=="/" :
        nbre1=int(nbre1/10)
        nbre2=randint(2,9)
        sol= str(max(nbre1,nbre2)//min(nbre1,nbre2)) + "," + str(max(nbre1,nbre2)%min(nbre1,nbre2))
    print(max(nbre1,nbre2),op,min(nbre2,nbre1))
    d=monotonic()
    rep=input("Votre réponse ? ")
    f=monotonic()
    if rep==sol :
        print("   Bravo")
        score = score+1
    else :
        print("   FAUX ! C'était ",sol)
    print ("   ["+str(round((f-d),1))+"s <> Score="+str(score)+"/"+str(question)+"]")
    print("--------------------")