-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmath2functions.py
More file actions
54 lines (40 loc) · 1.2 KB
/
Copy pathmath2functions.py
File metadata and controls
54 lines (40 loc) · 1.2 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#Function Calculator Module
#Define Variables
result = 0
#User Input
#try:
# num1 = int(input("Please enter the first number: "))
#except:
# print("Please enter a number")
#try:
# num2 = int(input("Please enter the secound number: "))
#except:
# print("Please enter a number")
#ope = input("Please enter mathematic operand +, -. * or x, /: ")
#print()
#Define Functions, they also print the full equation.
def addition(num1, num2):
print(f"{num1} + {num2} = {num1 + num2}")
return num1 + num2
def subtraction(num1, num2):
print(f"{num1} - {num2} = {num1 - num2}")
return num1 - num2
def multiplication(num1, num2):
print(f"{num1} * {num2} = {num1 * num2}")
return num1 * num2
def division(num1, num2):
print(f"{num1} / {num2} = {num1 / num2}")
return num1 / num2
#COMMENTED OUT FOR includingmath2.py
#Logical statement for operand, and assigns result using the correct function
#if(ope == '+'):
# result = addition(num1, num2)
#elif(ope == '-'):
# result = subtraction(num1, num2)
#elif(ope == '*' or ope == 'x'):
# result = multiplication(num1, num2)
#elif(ope == '/'):
# result = division(num1, num2)
#Prints result
#print()
#print(f"The result is {result}.")