-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBasicOperations.py
More file actions
36 lines (32 loc) · 1.19 KB
/
BasicOperations.py
File metadata and controls
36 lines (32 loc) · 1.19 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
def add(x, y):
return x + y
def sub(x, y):
return x - y
def mult(x, y):
return x * y
def div(x, y):
return x / y
print("====================================================")
print(" Basic Operations ")
print("====================================================")
print(" Please select the number of the operation needed ")
print("____________________________________________________")
print(" ")
print(" 1. Addition ")
print(" 2. Subtraction ")
print(" 3. Multiplication ")
print(" 4. Division ")
print("____________________________________________________")
op = int(input("Operation: "))
num1 = float(input("First Number: "))
num2 = float(input("Second Number: "))
if op == '1':
print(num1, "+", num2, "=", add(num1,num2))
elif op == '2':
print(num1, "-", num2, "=", sub(num1,num2))
elif op == '3':
print(num1, "*", num2, "=", mult(num1,num2))
elif op == '4':
print(num1, "/", num2, "=", div(num1,num2))
else:
print("ERROR: SELECT AN OPERATION ON THE LIST")