mirror of
https://github.com/JonasunderscoreJones/EPI-2324.git
synced 2025-10-23 08:29:19 +02:00
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
'''EPR Übungsblatt 03'''
|
|
__author__ = "7987847, Werner"
|
|
|
|
import epr_functions
|
|
|
|
print("Welcome to the EPR Functions Console.")
|
|
print("Type 'help' for a list of commands.")
|
|
print("Type 'exit' to exit the console.")
|
|
|
|
# Main loop of the console
|
|
while True:
|
|
command = input("> ")
|
|
try:
|
|
|
|
if command == "help":
|
|
print("Commands:")
|
|
print("help - Shows this help")
|
|
print("exit - Exits the console")
|
|
print("decimal_to_octal - Converts a decimal number to an octal number")
|
|
print("decimal_to_basis - Converts a decimal number to a number with a given base")
|
|
print("chaos_turtle - Draws a random pattern with a turtle")
|
|
elif command == "exit":
|
|
break
|
|
elif command == "decimal_to_octal":
|
|
print("Der Rechner rechnet Dezimalzahlen in Oktalzahlen um.")
|
|
print("Geben Sie eine positive Dezimalzahl ein.")
|
|
print(epr_functions.decimal_to_octal(int(input("Dezimalzahl: "))))
|
|
elif command == "decimal_to_basis":
|
|
print("Der Rechner rechnet Dezimalzahlen in Zahlen mit einer beliebigen Basis um.")
|
|
print("Geben Sie eine positive Dezimalzahl und eine positive Basis ein.")
|
|
print(epr_functions.decimal_to_basis(int(input("Dezimalzahl: ")), int(input("Basis: "))))
|
|
else:
|
|
print("Unknown command. Type 'help' for a list of commands.")
|
|
# Catch ValueError exceptions, when the user enters invalid input
|
|
except epr_functions.InvalidInputError:
|
|
print("Invalid input. Please try again.")
|