forked from lpr014/omega
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalc_Main.py
More file actions
68 lines (52 loc) · 1.39 KB
/
Calc_Main.py
File metadata and controls
68 lines (52 loc) · 1.39 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#Group:
#
#Last_Edit: Sept. 28 1:10 PM by Lorantz
#
#Calc_Main.py
#Main Program
from Mult import *
from InputParser import *
from Add import *
from Divide import *
#the .pyc files are created because we are importing them into the main
#simply ignore them, dont bother adding them to github.
print('Welcome to Calculator!')
while True:
while True:
#parse the users input
ans = -1
arr = inputParser()
#print arr
args=len(arr)
#testing
num1=0
num2=0
#testing#
if args==1:
print ('\n\t'+str(arr[0]))
break
if arr=='invalid input':
print("\n\t"+arr)
break
if args >= 2:
num1=arr[0]
op=arr[1]
if(op != '*'and op != '/'and op != '+' and op != '-' and op != '!' and op != '//' and op !="^"):
break
if args >= 3:
num2=arr[2]
print('\nCalculating...\n')
#decide op ( + - * / ^ !)
if op == '*':
ans=multiply(num1, num2)
elif op == '!':
ans=fact(int(num1))
elif op == '^':
ans=power(num1, num2)
elif op == '+':
ans=add(num1, num2)
elif op == '/':
ans=divide(num1, num2)
elif op =='//':
ans=whole(num1, num2)
print '\tANSWER: ', ans