Added new implementation

This commit is contained in:
Sven Heidemann 2020-12-13 01:04:17 +01:00
parent e8d65a9cf6
commit 5f2dd62868
3 changed files with 62 additions and 0 deletions

0
new/__init__.py Normal file
View File

6
new/main.py Normal file
View File

@ -0,0 +1,6 @@
from new.program import Program
if __name__ == '__main__':
# Global start point
program = Program()
program.main()

56
new/program.py Normal file
View File

@ -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)}')