-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmathBot.py
More file actions
36 lines (33 loc) · 807 Bytes
/
Copy pathmathBot.py
File metadata and controls
36 lines (33 loc) · 807 Bytes
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
# Math Bot
# add sub mul div
# 2 var
# "usage: add|sub|mul|div v0 v1" if invalid input
def main():
user_input = input("")
split_values = user_input.split()
v0 = int(split_values[1])
v1 = int(split_values[2])
if split_values[0] == "add":
print(v0 + v1)
return True
if split_values[0] == "mul":
print(v0 * v1)
return True
if split_values[0] == "div":
if v1 == 0:
print("can't divide by 0")
return True
else:
print(v0 / v1)
return True
if split_values[0] == "sub":
print(v0 - v1)
return True
if split_values[0] == "quit":
return False
else:
print("usage: add|sub|mul|div v0 v1")
return True
while True:
if not main():
break