Code: Alles auswählen
import random
fragen_liste = []
richtige_antwort_liste = []
moegliche_antworten_lsiet = []
class Moegliche_Antworten:
def __init__(self,a,b,c):
self.a = a
self.b = b
self.c = c
def eingabe():
while True:
eingabe_frage = input("Frage >>")
if eingabe_frage == "beende":
return
eingabe_antwort_a = input("Antwort A >>")
eingabe_antwort_b = input("Antwort B >>")
eingabe_antwort_c = input("Antwort C >>")
richtige_antwort = input("Richtige Antwort (a,b,c) >>")
fragen_liste.append(eingabe_frage)
richtige_antwort_liste.append(richtige_antwort)
moegliche_antworten_lsiet.append(Moegliche_Antworten(eingabe_antwort_a,eingabe_antwort_b,eingabe_antwort_c))
def quiz():
while True:
zahl = random.randint(1,len(fragen_liste)-1)
print (fragen_liste[zahl])
print ("a - " + moegliche_antworten_lsiet[zahl].a)
print ("b - " + moegliche_antworten_lsiet[zahl].b)
print ("c - " + moegliche_antworten_lsiet[zahl].c)
eingabe_antwort = input("Richtig ist (a,b,c) >>")
if eingabe_antwort == richtige_antwort_liste[zahl]:
print ("Richtg")
elif eingabe_antwort == "beende":
return
else:
print ("richtig waere " + richtige_antwort_liste[zahl])
def ausgabe():
zahl = 0
while zahl < len(fragen_liste) - 1:
print (fragen_liste[zahl])
print ("a - " + moegliche_antworten_lsiet[zahl].a)
print ("b - " + moegliche_antworten_lsiet[zahl].b)
print ("c - " + moegliche_antworten_lsiet[zahl].c)
print (richtige_antwort_liste[zahl])
print ("________________________________")
zahl = zahl + 1
while True:
befehl = input("Befehl >>")
if befehl == "eingabe":
eingabe()
elif befehl == "quiz":
quiz()
elif befehl == "ausgabe":
ausgabe()
elif befehl == "beende":
break
else:
print("einagabe | quiz | ausgabe | beende")