import random from Tkinter import* #liste_image=["image1.png"\"image2.png",\"image3.png",\"image4.png",\"image5.png"] liste_questions=["Question 1: Dans cette situation, puis-je dépasser?\n",\ "Question 2: ai-je le droit de m'arrêter sur le bas côté?\n",\ "Question 3: Quelle est la limite maximale en ville?\n" ,\ "Question 4: Suis-je prioritaire?\n" ,\ "Question 5: Dans cette situation, que faire?\n"] liste_choix=["1) Oui 2)Non \n",\ "1) Oui 2) Non \n",\ "1)30 kmh 2)50kmh 3)70kmh 4)pas de limite \n",\ "1) Oui 2) non \n",\ "1) Je m'arrête 2) j'accelere 3) je ralentit en serrant à droite 4) je continue dans ma lancée\n"] liste_reponse=[1,2,2,1,1] liste_QuestionPose=[0,0,0,0,0] def Aleatoire(): n=0 compteur = 0 R=0 i=0 for n in range(5): while liste_QuestionPose[i] == 1: i = random.randint(0, 4) if liste_QuestionPose[i] == 0: print(liste_questions[i]) print(liste_choix[i]) liste_QuestionPose[i] = 1 R=int(input("Choisissez la bonne réponse:")) if R == liste_reponse[i]: compteur = compteur+1 print("Note:") if compteur == 5 : print("5/5 C'est très bien.") if compteur == 4 : print("4/5 C'est bien. ") if compteur == 3 : print("3/5 tu n'aurais pas eu ton code") if compteur == 2 : print("2/5 tu n'aurais pas eu ton code") if compteur == 1 : print("1/5 tu n'aurais pas eu ton code.") if compteur == 0 : print("0/5 tu n'aurais pas eu ton code.") def Question(): n=0 compteur = 0 R=0 for i in range(5): print(liste_questions[i]) print(liste_choix[i]) R=int(input("Choisissez la bonne réponse:")) if R == liste_reponse[i]: compteur = compteur+1 print(compteur) #note et commentaire : print("Note:") if compteur == 5 : print("5/5 C'est très bien.") if compteur == 4 : print("4/5 C'est bien. ") if compteur == 3 : print("3/5 tu n'aurais pas eu ton code") if compteur == 2 : print("2/5 tu n'aurais pas eu ton code") if compteur == 1 : print("1/5 tu n'aurais pas eu ton code.") if compteur == 0 : print("0/5 tu n'aurais pas eu ton code.") def FenetreAleatoire(): fenetre1 = Tk() canvas = Canvas(fenetre1, width=400, height=120, background="grey") canvas.create_text(fenetre1, text = (liste_questions)) canvas.pack() label = Label(fenetre1, text="voici votre série bonne chance !") label.pack() bou1 = Button(fenetre1, text="lancer la série", command=Aleatoire) bou1.pack() def FenetreNormal(): fenetre2 = Tk() label = Label(fenetre2, text="voici votre série bonne chance !") label.pack() bou1 = Button(fenetre2, text="lancer la série", command=Normal) bou1.pack() fenetre = Tk() texte1 = Label(fenetre, text='Bonjour tout le monde !', fg='black') texte1.pack() bou1 = Button(fenetre, text='Questions aléatoires', command=FenetreAleatoire) bou1.pack() bou2 = Button(fenetre, text='exercice classique', command=Question) bou2.pack() bou3 = Button(fenetre, text='quitter', command = fenetre.destroy) bou3.pack() fenetre.mainloop()