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