Files
inf-kswo/IO/Calculator.py
Janis Hutz ede0ee318b Format
There really is no hope of making this code even half-way decent without
spending the time to rewrite them all properly. Don't want to do any of
that
2025-11-03 17:08:35 +01:00

69 lines
1.8 KiB
Python
Executable File

# Library import
import math
# Startup
out = 0
print(
"""
,--------. ,--. ,--.
'--. .--',--,--. ,---. ,---.| ,---. ,---. ,--,--, ,--.--. ,---. ,---.| ,---. ,--,--, ,---. ,--.--.
| | ' ,-. |( .-' | .--'| .-. || .-. :| \| .--'| .-. :| .--'| .-. || \| .-. :| .--'
| | \ '-' |.-' `)\ `--.| | | |\ --.| || || | \ --.\ `--.| | | || || |\ --.| |
`--' `--`--'`----' `---'`--' `--' `----'`--''--'`--' `----' `---'`--' `--'`--''--' `----'`--'
=================
Alpha 1.0
Build 1
28.05.21
"""
)
# Userinput
i = input("Rechung eingeben: ")
# Separation
l = i.split()
x1 = l.pop(0)
x = int(x1)
# Calculation
if len(l) == 1:
print("Wrong entry, retry, use spaces in between numbers and operands.")
else:
while len(l) > 1:
y1 = l.pop(1)
y = int(y1)
if "*" in l:
out = x * y
elif "+" in l:
out = x + y
elif "-" in l:
out = x - y
elif "/" or ":" in l:
out = x / y
elif "^" or "**" in l:
out = x**y
elif "<>" in l:
math.sqrt(x)
else:
print("unkown operand, retry")
if len(l) != 0:
operand = l.pop(0)
x = out
else:
print("The result is:")
# Output
print(out)