petit_bac.py

Created by ph-moutou

Created on June 12, 2018

962 Bytes

Ce programme propose une lettre tirée au hasard parmi toutes celles qui n’ont pas été déjà choisies. On peut modifier les catégories et leur nombre. Elles sont au nombre de 10 par défaut : 1-animal, 2-prénom, 3-pays/ville, 4-métier, 5-fleur/plante, 6-fruit/légume, 7-produit/marque, 8-écrivain/cinéaste, 9-sport et 10-véhicule.


from random import *
def pb(s):
  categories=["animal", "prenom", "pays/ville", 
"metier", "fleur/plante", "fruit/legume", 
"produit/marque", "ecrivain/cineaste", 
"sport", "vehicule"]
  lettres_deja=[]
  seed(s)#pour modifier la suite aleatoire
  for i in range(len(categories)):
    c=input("categorie {} : {} (esc:passe)".format(i+1,categories[i]))
    if c!="":categories[i]=c
  c=input("pret?")
  while c!="0":
    proposition=len(categories)*[""]
    l=randint(1,26)
    while l in lettres_deja:
      l=randint(1,26)
    print("la lettre est {}".format(chr(l+64)))
    lettres_deja.append(l)
    for i in range(len(categories)):
      proposition[i]=input("{} : ".format(categories[i]))
    c=input("esc:revoir,1:lettre,0:fin?")
    while c=="":
      for i in range(len(categories)):
        c=input("{} : {} ".format(categories[i],proposition[i]))
        if c!="":proposition[i]=c
      c=input("esc:revoir,1:lettre,0:fin?")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

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.