commit message from python script
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
import random
|
import random, operator
|
||||||
|
|
||||||
|
|
||||||
class my_rechner:
|
class my_rechner:
|
||||||
def __init__(self, zahl=0):
|
def __init__(self):
|
||||||
self.zahl = zahl
|
self.zahl1 = random.randint(1, 1000)
|
||||||
self.rechen_art = ['*', '+', '-']
|
self.zahl2 = random.randint(1, 1000)
|
||||||
self.art = random.choice(self.rechen_art)
|
self.operators = [('+', operator.add), ('-', operator.sub), ('*', operator.mul), ('/', operator.truediv) ]
|
||||||
|
self.op, self.fn = random.choice(self.operators)
|
||||||
|
|
||||||
|
|
||||||
def check_input(self):
|
def check_input(self):
|
||||||
@@ -17,21 +18,22 @@ class my_rechner:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def check_rechnen(self):
|
def check_rechnen(self):
|
||||||
self.zahl = random.randint(1, 1000)
|
self.zahl1 = random.randint(1, 1000)
|
||||||
self.art = random.choice(self.rechen_art)
|
self.zahl2 = random.randint(1, 1000)
|
||||||
|
self.op, self.fn = random.choice(self.operators)
|
||||||
|
|
||||||
def main_run(self):
|
def main_run(self):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print(self.zahl , self.art)
|
print("Rechne {zahl1} {op} {zahl2} ".format(zahl1=self.zahl1, op=self.op, zahl2=self.zahl2))
|
||||||
r = str(str(self.zahl) + ' ' + str(self.art) + ' '+ str(self.zahl))
|
summe = self.fn(self.zahl1, self.zahl2)
|
||||||
summe = eval(r)
|
my_ergebnis = input("Was ist dein Ergebnis :")
|
||||||
self.check_rechnen()
|
self.check_rechnen()
|
||||||
print(r)
|
print("Deine Input", my_ergebnis)
|
||||||
print(summe)
|
print("Ergebniss", summe)
|
||||||
|
|
||||||
check_input = input("Noch eine Frage ? :")
|
check_input = input("Willst du aufhöhren ? (j) :")
|
||||||
if len(check_input) == 1 and check_input == "n":
|
if len(check_input) == 1 and check_input == "j":
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("false")
|
print("false")
|
||||||
|
|||||||
Reference in New Issue
Block a user