-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathl5q1.py
More file actions
34 lines (30 loc) · 722 Bytes
/
Copy pathl5q1.py
File metadata and controls
34 lines (30 loc) · 722 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
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
def add(a,b):
return a+b
def sub(a,b):
return a-b
def mul(a,b):
return a*b
def div(a,b):
return a/b
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Please select operation : \n" \
"1. Addition \n" \
"2. Subtraction \n" \
"3. Multiplication \n" \
"4. Division \n")
select = int(input("Select operations form 1, 2, 3, 4 :"))
if select == 1:
print(a, "+", b, "=", add(a,b))
elif select == 2:
print(a, "-", b, "=", sub(a,b))
elif select == 3:
print(a, "*", b, "=", mul(a,b))
elif select == 4:
if b == 0:
exit
elif b != 0:
print(a, "/", b, "=", div(a,b))
else:
print("Invalid input")