diff --git a/new/__init__.py b/new/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/new/main.py b/new/main.py new file mode 100644 index 0000000..059c4dc --- /dev/null +++ b/new/main.py @@ -0,0 +1,6 @@ +from new.program import Program + +if __name__ == '__main__': + # Global start point + program = Program() + program.main() diff --git a/new/program.py b/new/program.py new file mode 100644 index 0000000..6de7bd9 --- /dev/null +++ b/new/program.py @@ -0,0 +1,56 @@ +import math +from datetime import datetime + + +class Program: + """ + Class to specify the program like as in C# + """ + + def __init__(self): + pass + + @staticmethod + def sqrt(input_value: float) -> float: + """ + Calculates the square root of a value + :param input_value: + :return: + """ + return float(math.sqrt(input_value)) + + @staticmethod + def date(date_one: datetime, date_two: datetime): + """ + Calculates to difference of two dates + :param date_one: + :param date_two: + :return: + """ + return abs(date_one - date_two).days + + @staticmethod + def get_input(output: str) -> str: + """ + Gets input and gives a given output + Prints given output and gives given input + :param output: + :return: + """ + input_value = input(output) + if input_value == 'x': + exit() + + return input_value + + def main(self): + """ + Start point of Program + :return: + """ + input_value = float(self.get_input('Wurzel aus: ')) + print(f'Die Wurzel aus {input_value} ist {self.sqrt(input_value)}') + + date1 = datetime.strptime(self.get_input('Datum 1: '), '%d.%m.%Y') + date2 = datetime.strptime(self.get_input('Datum 2: '), '%d.%m.%Y') + print(f'Die Differenz aus {date1} und {date2} ist {self.date(date1, date2)}')