Last active 1687456628

cyberes's Avatar cyberes revised this gist 1687456628. Go to revision

1 file changed, 4 insertions, 4 deletions

calculator.py

@@ -1,8 +1,8 @@
1 1 while True:
2 2 try:
3 - opr = input("calculator> ")
4 - exec(f'ans = {opr}')
5 - print(ans)
3 + print(eval(input("calculator> ")))
4 + except Exception as e:
5 + print(e)
6 6 except KeyboardInterrupt:
7 7 print()
8 - quit()
8 + quit()

cyberes's Avatar cyberes revised this gist 1687456068. Go to revision

1 file changed, 8 insertions

calculator.py(file created)

@@ -0,0 +1,8 @@
1 + while True:
2 + try:
3 + opr = input("calculator> ")
4 + exec(f'ans = {opr}')
5 + print(ans)
6 + except KeyboardInterrupt:
7 + print()
8 + quit()
Newer Older