All pastes #172852 Raw Edit

Sans nom

public text v1 · immutable
·published 2006-09-16 10:47 UTC
rendered paste body
#!/usr/bin/python
# -*- coding: ISO-8859-15 -*-
 
from random import randrange
 
def nombres():
    
    nombrediv = randrange(0,100)
    nombrefacteur1 = randrange(0,10)
    nombrefacteur2 = randrange(0,10)
    choix = randrange(0,10)
    return nombrediv,nombrefacteur1,nombrefacteur2,choix
 
resultat = 0
resultatentre = 0
choix = randrange(0,1)
recommencer = 0
autoretry = 1
note = 0
compteur = 0
nombrediv,nombrefacteur1,nombrefacteur2,choix = nombres()
while autoretry == 1 :
   if choix > 5 :
         if nombrediv%nombrefacteur1 == 0 :
            print nombrediv, 'divise par', nombrefacteur1
            resultat = nombrediv/nombrefacteur1
            resultatentre = input('est egale à?')
            if resultatentre == resultat :
                  print "Bravo c\'est bon"
                  note = note + 1 
                  nombrediv,nombrefacteur1,nombrefacteur2,choix = nombres()
            else:
                  print "Mauvaise réponse, le resultat était : ", resultat
                  autoretry == 0
                  nombrediv,nombrefacteur1,nombrefacteur2,choix = nombres()
         else:
            autoretry == 1
   else :
         print nombrefacteur1, "multiplié par", nombrefacteur2
         resultat = nombrefacteur1*nombrefacteur2
         resultatentre = input('est égal à ?')
         if resultatentre == resultat :
               print "Bravo c\'est bon"
               nombrediv,nombrefacteur1,nombrefacteur2,choix = nombres()
               
         else:
               print "Mauvaise réponse, le resultat était : ", resultat
               nombrediv,nombrefacteur1,nombrefacteur2,choix = nombres()
compteur = compteur + 1               
raw_input('Appuyez sur entrée pour quitter le programme...')