66 lines
1.8 KiB
Python
Executable File
66 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) |