-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mathe-Spiel.py
68 lines (55 loc) · 1.74 KB
/
Mathe-Spiel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Der Benutzer soll eine Matheaufgabe lösen, die random gestellt wird
# Der Benutzer wählt seine Rechnungsart aus durch einem Menü
import random
option = ""
while(option != "0"):
countVersuche = 1
countRechnung = 1
wertebereich = 5
print("\nHauptmenü")
print("\nGeben Sie die gewünschte Zahl ein")
print("""0 : Exit
1 : Addition
2 : Multiplikation
3 : Division
4 : Subtraktion\n""")
print("Ihre Eingabe", end=": ")
option = input()
#Für 0 = Exit
if(option == "0"):
print("Sie haben das Programm beendet")
break
while(countVersuche <= 3):
#Random Zahl zwischen 0 und max
x = random.randint(0, wertebereich)
y = random.randint(0, wertebereich)
#Für 1 = Addition
if(option == "1"):
operator = "+"
erg = x + y
#Für 2 = Multiplikation
elif(option == "2"):
operator = "*"
erg = x * y
#Für 3 = Division
elif(option == "3"):
operator = "/"
erg = x / y
#Für 4 = Subtraktion
elif(option == "4"):
operator = "-"
erg = x - y
# Die Aufgabe wird angezeigt und das Ergebnis eingegeben
print(x, operator, y, end=" = ")
ergEingabe = int(input())
if(erg == ergEingabe):
print("Richtig!")
# Alle 5 Runden wird der Wertebereich um 5 erhöht
if(countRechnung == 5):
countRechnung = 1
wertebereich = wertebereich + 5
else:
countRechnung = countRechnung + 1
else:
countVersuche = countVersuche + 1
print("Falsch")