PY
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
#Created by Evan Martine
def a(x,y):
num3 = str(x + y)
print('The answer is: ' + num3 + '\n\n')
def s(x,y):
num3 = str(x - y)
print('The answer is: ' + num3 + '\n\n')
def m(x,y):
num3 = str(x * y)
print('The answer is: ' + num3 + '\n\n')
def d(x,y):
num3 = str(x / y)
print('The answer is: ' + num3 + '\n\n')
func_dict = {"a": a, "s": s, "m": m, "d": d} #use dictionaries to use user inputs as function or variable names
def operation(input,num1,num2):
return func_dict[input](num1,num2)
#while True: #This is for when using an IDE
if True:
print('Options')
print("Enter 'a' to add two numbers")
print("Enter 's' to subtract two numbers")
print("Enter 'm' to multiply two numbers")
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run