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))
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from calc import calculator as calc
|
||||
|
||||
print("erfolgreich importiert")
|
||||
|
||||
current_calc = calc()
|
||||
|
||||
print(current_calc.pythagoras(3, 4))
|
||||
print(current_calc.addition(current_calc.mem_res, 20))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
i = 0
|
||||
|
||||
while True:
|
||||
i += 1
|
||||
print("Hallo!", i)
|
||||
if i == 5:
|
||||
break
|
||||
|
||||
|
||||
for i in range(5):
|
||||
print("Hallo!", i+1)
|
||||
|
||||
|
||||
names: list = ["Max Mustermann", "Thies Körner", "Christoph Treusch von Buttlar"]
|
||||
print(names)
|
||||
|
||||
for name in names:
|
||||
print(name)
|
||||
|
||||
|
||||
students: list[dict] = [{"name": "Max Mustermann", "age": 25, "favorite_colour": "blue"},
|
||||
{"name": "Thies Körner", "age": 16, "favorite_colour": "purple"}]
|
||||
print(students)
|
||||
|
||||
for student in students:
|
||||
print(student["name"], student["age"], student["favorite_colour"])
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
# def leitet sich von define ab
|
||||
# in den Klammern sind die Parameter (hier a, b)
|
||||
def addition(a, b):
|
||||
result = a + b
|
||||
return result
|
||||
|
||||
summe = addition(10, 20)
|
||||
print(summe)
|
||||
summe1 = addition(summe, 0.25)
|
||||
print(summe1)
|
||||
Reference in New Issue
Block a user