-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperations.py
More file actions
34 lines (22 loc) · 841 Bytes
/
operations.py
File metadata and controls
34 lines (22 loc) · 841 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
import inquirer
question = [
inquirer.List('operator',
message="Please choose an operator:",
choices=["+", "*", "/", "//", "**","-"],
default="+"),
inquirer.Text("num1", message="Enter first number:"),
inquirer.Text("num2", message="Enter second number:"),
]
answers = inquirer.prompt(question)
if answers['operator'] == '+':
result = int(answers['num1']) + int(answers['num2'])
print("Answer:", result)
if answers['operator'] == '*':
result = int(answers['num1']) * int(answers['num2'])
print("Answer:", result)
if answers['operator'] == '/':
result = int(answers['num1']) / int(answers['num2'])
print("Answer:", result)
if answers['operator'] == '-':
result = int(answers['num1']) - int(answers['num2'])
print("Answer:", result)