forked from avinashkranjan/Amazing-Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalcy.py
40 lines (29 loc) · 697 Bytes
/
Calcy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 6 23:26:25 2020
@author: Avinash Ranjan
"""
import re
print("Magical Calculator")
print("Type 'quit' to exit\n")
previous = 0
run = True
def performMath():
global run
global previous
equation = ""
if previous == 0:
equation = input("Enter Equation:")
else:
equation = input(str(previous))
if equation == 'quit':
print("GoodBye, Human..!")
run = False
else:
equation = re.sub('[a-zA-Z,:()"{}"]', '', equation)
if previous == 0:
previous = eval(equation)
else:
previous = eval(str(equation) + equation)
while run:
performMath()