-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpart2.py
More file actions
25 lines (22 loc) · 708 Bytes
/
part2.py
File metadata and controls
25 lines (22 loc) · 708 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
def takeInput():
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
operator = input("Enter the operator (+,-,*,/): ")
return num1, num2, operator
#taking input
def displayResult(num1, num2, operator):
if operator == '+':
result = num1 + num2
elif operator == '-':
result = num1 - num2
elif operator == '*':
result = num1 * num2
elif operator == '/':
result = num1 / num2
else:
print("Invalid operator")
return
print(num1, operator, num2, "=", result)
num1, num2, operator = takeInput()
displayResult(num1, num2, operator)
#displaying result