From e8d65a9cf673c21591f40fc5ff19a01ccee7e9d9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 13 Dec 2020 01:03:54 +0100 Subject: [PATCH] Added files from schoolwork --- old/__init__.py | 0 old/date.py | 19 +++++++++++++++++++ old/sqrt.py | 12 ++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 old/__init__.py create mode 100644 old/date.py create mode 100644 old/sqrt.py diff --git a/old/__init__.py b/old/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/old/date.py b/old/date.py new file mode 100644 index 0000000..dfc09d2 --- /dev/null +++ b/old/date.py @@ -0,0 +1,19 @@ +from datetime import datetime + + +def get_input() -> str: + input_value = input('Datum: ') + if input_value == 'x': + exit() + + return input_value + + +if __name__ == '__main__': + while True: + try: + value1 = datetime.strptime(get_input(), '%d.%m.%Y') + value2 = datetime.strptime(get_input(), '%d.%m.%Y') + print(f'Die Differenz aus {value2} und {value2} ist {abs((value1 - value2).days)}') + except Exception as e: + print(f'Ungültige Eingabe! {e}') diff --git a/old/sqrt.py b/old/sqrt.py new file mode 100644 index 0000000..f3ed7d6 --- /dev/null +++ b/old/sqrt.py @@ -0,0 +1,12 @@ +import math + +if __name__ == '__main__': + while True: + try: + input_value = input('Berechne die Quadratwurzel aus: ') + if input_value == 'x': + exit() + value = float(input_value) + print(f'Die Quadratwurzel aus {value} ist {float(math.sqrt(value))}') + except Exception as e: + print(f'Ungültige Eingabe! {e}')