forked from adamawoolley/py-cal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpycal.py
More file actions
58 lines (43 loc) · 1.41 KB
/
pycal.py
File metadata and controls
58 lines (43 loc) · 1.41 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
from mathfunctions import equation, mean, rt, prime
input_error = 'Please enter a valid input'
options = '''
Welcome to pycal!
If you need help, type help
'''
if __name__ == "__main__":
print(options)
ans = 0
while True:
user_input = input('>>>')
user_input = user_input.split(' ')
for i in user_input:
if 'ans' in i:
user_input[user_input.index(i)] = ans
try:
if user_input[0] == 'mean':
try:
ans = mean(user_input[1:])
print(ans)
except:
print(input_error)
elif user_input[1] == 'rt':
try:
ans = rt(int(user_input[2]), int(user_input[0]), int(user_input[3]))
print(ans)
except:
print(input_error)
# elif user_input == 'prime':
#
# for i in user_input[1:]:
#
# try:
# ans = prime(i)
# print(ans)
# except:
# print(input_error)
except:
try:
ans = equation(user_input)
print(ans)
except:
print(input_error)