forked from david-gary/CalculatorLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleOperations.py
More file actions
34 lines (28 loc) · 1.11 KB
/
simpleOperations.py
File metadata and controls
34 lines (28 loc) · 1.11 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
def simple_calculate(operation, num1, num2):
"""
Performs the given simple operation on the given numbers, which may be either integers or floats.
args:
- operation: the operation to perform (+, -, *, or /)
- num1: the first number
- num2: the second number
returns:
- the result of the operation on the given numbers
"""
if operation == '+':
return num1 + num2
elif operation == '-':
# TODO: finish this statement
# - should return the result of subtracting num2 from num1
pass # Replace this line with your code
elif operation == '*':
# TODO: finish this statement
# - should return the result of multiplying num1 by num2
pass # Replace this line with your code
elif operation == '/':
# TODO: finish this statement
# - should return the result of dividing num1 by num2
# - remember to raise a ValueError if num2 is 0
pass # Replace this line with your code
else:
raise ValueError(
'Invalid Operation: Simple Operations are (+, -, *, and /)')