-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMini calculator.py
More file actions
22 lines (21 loc) · 822 Bytes
/
Copy pathMini calculator.py
File metadata and controls
22 lines (21 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Taking input for two numbers (a and b) and the operation choice (n)
a = int(input("Enter the value of a:"))
b = int(input("Enter the value of b:"))
n = int(input("Choose your operation:\n1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n"))
# Checking the operation chosen by the user
if (n == 1):
# If the user chose 1, perform addition
print(a + b)
elif (n == 2):
# If the user chose 2, perform subtraction
print(a - b)
elif (n == 3):
# If the user chose 3, perform multiplication
print(a * b)
elif (n == 4):
# If the user chose 4, perform division
# (Ensure that division by zero is handled in real applications)
print(a / b)
else:
# If the user enters an invalid operation choice
print("Invalid choice! Please choose a valid operation.")