-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (30 loc) · 823 Bytes
/
Copy pathmain.py
File metadata and controls
35 lines (30 loc) · 823 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
35
#write by yash-pagar
def add_numbers(x, y):
return x + y
def subtract_numbers(x, y):
return x - y
def multiply_numbers(x, y):
return x * y
def divide_numbers(x, y):
if y == 0:
return "Error! Division by zero."
else:
return x / y
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
choice = input("Enter choice (1/2/3/4): ")
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
if choice == '1':
print("Result:", add_numbers(a, b))
elif choice == '2':
print("Result:", subtract_numbers(a, b))
elif choice == '3':
print("Result:", multiply_numbers(a, b))
elif choice == '4':
print("Result:", divide_numbers(a, b))
else:
print("Invalid input")