-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.py
More file actions
29 lines (22 loc) · 973 Bytes
/
Calculator.py
File metadata and controls
29 lines (22 loc) · 973 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
x = int(input('Please enter x: '))
y = int(input('Please enter y: '))
operator = input('Do you want to add(+), subtract(-), multiply(*), or divide(/)?: ')
add = lambda x, y: x+y
subtract = lambda x, y: x - y
multiply = lambda x, y: x * y
divide = lambda x, y: x / y
# Now that we have defined our relative functions. This is the operational logic of our program.
if operator == 'add' :
print('Addition of ', x, ' and ', y, ' is ', add(x, y))
elif operator == 'subtract' :
print('Subtraction of ', x, ' and ', y, ' is ', subtract(x, y))
elif operator == 'multiply' :
print('Multiplication of of ', x, ' and ', y, ' is ', multiply(x, y))
elif operator == 'divide':
print('Addition of ', x, ' and ', y, ' is ', divide(x, y))
else:
print('Operator Gonzo! Try Again')
# print('Addition is ' , addition(4, 4))
# print('Subtraction is ' , subtraction(4, 4))
# print('Multiplication is ' , multiplication(4, 4))
# print('Division is ' , division(4, 4))