-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharithmetic.py
49 lines (39 loc) · 1.25 KB
/
arithmetic.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
You need to complete the code in the following functions:
- SubtractNumbers
- MultiplyNumbers
- DivideNumbers
'''
def AddNumbers(num_1, num_2):
'''
This function should return num_1 + num_2.
'''
return num_1 + num_2
def SubtractNumbers(num_1, num_2):
'''
This function should return num_1 - num_2. Replace the line below with the
correct code.
'''
return num_1 - num_2
def MultiplyNumbers(num_1, num_2):
'''
This function should return num_1 * num_2. Replace the line below with the
correct code.
'''
return num_1 * num_2
def DivideNumbers(num_1, num_2):
'''
This function should return num_1 / num_2. If there is a divide by 0 error,
return the string 'Error'. Repalce the line below with the correct code.
'''
if num_1 == 0 or num_2 == 0:
return 'Error'
divide = num_1 / num_2
return divide
# You don't need to change anything below this line.
num_1 = float(input("Enter first number: "))
num_2 = float(input("Enter second number: "))
print(num_1, "+", num_2, "=", AddNumbers(num_1, num_2))
print(num_1, "-", num_2, "=", SubtractNumbers(num_1, num_2))
print(num_1, "*", num_2, "=", MultiplyNumbers(num_1, num_2))
print(num_1, "/", num_2, "=", DivideNumbers(num_1, num_2))