====== LU10.L02 - Einleser als Modul ======
===== Aufgaben =====
==== Teilaufgabe 1 ====
'''
input_reader module with input validation
'''
def read_float(text_to_display):
pass
==== Teilauftrag 2 ====
def read_float(text_to_display):
while True:
try:
num = float(input(text_to_display))
except ValueError:
print("Please, enter a real number!")
continue
else:
return num
==== Teilauftrag 3 ====
def read_int(text_to_display):
while True:
try:
num = int(input(text_to_display))
except ValueError:
print("Please, enter a valid whole number!")
continue
else:
return num
==== Teilauftrag 4 ====
Importieren Sie ihr ''input_reader'' Modul in ihrem ''main.py'' damit das Programm funktioniert.
# Import the input_reader module here
from input_reader import read_float, read_int
def main():
# do something
float = read_float('Please enter a real number> ')
int = read_int('Please enter a whole number> ')
print(float)
print(int)
if __name__ == '__main__':
main()