calcul_mental.py

Created by ptitjoz

Created on October 20, 2018

726 Bytes

faire du calcul mental sur les 4 opérations (au choix) difficulté paramétrable Version 2


#V2.1
from random import *
s="-"
c="calcul"
p=0
for i in range(28):
  s=s+"-"
  print()
print(c,"mental")
print(s)
k=(input("+ - * /  ? "))
l=int(input("Borne mini ? "))
h=int(input("Borne maxi ? "))
n=int(input("Nombre de calculs ? "))
print(s)
if h<l:
  l,h=h,l
for i in range(1,n+1):
  a=randint(l,h)
  b=randint(l,h)
  if k=="+":
    z=a+b
    o="+"
  if k=="*":
    z=a*b
    o="*"
  if k=="-":
    if a<b:
      a,b=b,a
    z=a-b
    o="-"
  if k=="/":
    t=a*b
    #z=a
    #a=t
    z,a=a,t
    o="/"   
  print(c,i,"sur",n)
  print(a,o,b)
  r=int(input("Reponse ? "))
  if r==z:
    print("Bravo !")
    p=p+1
  else:
    print("Faux, la reponse etait",z)
  print(s)
print("Ta note est",p,"/",n)