commit message from python script
This commit is contained in:
@@ -9,6 +9,8 @@ class my_rechner:
|
|||||||
self.zahl2 = random.randint(1, 1000)
|
self.zahl2 = random.randint(1, 1000)
|
||||||
self.operators = [('+', operator.add), ('-', operator.sub), ('*', operator.mul), ('/', operator.truediv) ]
|
self.operators = [('+', operator.add), ('-', operator.sub), ('*', operator.mul), ('/', operator.truediv) ]
|
||||||
self.op, self.fn = random.choice(self.operators)
|
self.op, self.fn = random.choice(self.operators)
|
||||||
|
self.count_true = 0
|
||||||
|
self.count_false = 0
|
||||||
|
|
||||||
|
|
||||||
def check_input(self):
|
def check_input(self):
|
||||||
@@ -26,17 +28,20 @@ class my_rechner:
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
print("Rechne {zahl1} {op} {zahl2} ".format(zahl1=self.zahl1, op=self.op, zahl2=self.zahl2))
|
print("Rechne {zahl1} {op} {zahl2} ".format(zahl1=self.zahl1, op=self.op, zahl2=self.zahl2))
|
||||||
summe = self.fn(self.zahl1, self.zahl2)
|
summe = round(float(self.fn(self.zahl1, self.zahl2)),2)
|
||||||
my_ergebnis = input("Was ist dein Ergebnis :")
|
my_ergebnis = float(input("Was ist dein Ergebnis :"))
|
||||||
self.check_rechnen()
|
self.check_rechnen()
|
||||||
print("Deine Input", my_ergebnis)
|
print("Deine Input", my_ergebnis)
|
||||||
|
if my_ergebnis == summe:
|
||||||
|
self.count_true = self.count_true + 1
|
||||||
|
print("richtig !!!")
|
||||||
print("Ergebniss", summe)
|
print("Ergebniss", summe)
|
||||||
|
|
||||||
|
print("Du hast insgesamt", self.count_true, "richtig")
|
||||||
|
|
||||||
check_input = input("Willst du aufhöhren ? (j) :")
|
check_input = input("Willst du aufhöhren ? (j) :")
|
||||||
if len(check_input) == 1 and check_input == "j":
|
if len(check_input) == 1 and check_input == "j":
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
print("false")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user