The new materials
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from math import sqrt
|
||||
|
||||
|
||||
class calculator():
|
||||
|
||||
def __init__(self):
|
||||
self.mem_number_1 = 0
|
||||
self.mem_number_2 = 0
|
||||
self.mem_res = 0
|
||||
|
||||
# nimmt a^2 + b^2 und zieht die Wurzel für c
|
||||
def pythagoras(self, numA, numB):
|
||||
numA = numA**2
|
||||
numB = numB**2
|
||||
summe = self.addition(numA, numB)
|
||||
numC = sqrt(summe)
|
||||
self.mem_res = numC
|
||||
return numC
|
||||
|
||||
# addiert 2 Werte
|
||||
def addition(self, a, b):
|
||||
result = a + b
|
||||
self.mem_res = result
|
||||
return result
|
||||
|
||||
# wiederholt fortlaufend
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
current_calc = calculator()
|
||||
print("Enter values")
|
||||
a = int(input("a: "))
|
||||
b = int(input("b: "))
|
||||
operation = int(input("What to do: [1 : Addition, 2 : Pythagoras]: "))
|
||||
|
||||
if operation == 1:
|
||||
print("Summe: ", current_calc.addition(a, b))
|
||||
elif operation == 2:
|
||||
print("c: ", current_calc.pythagoras(a, b))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user