-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalculator_match_case.py
More file actions
19 lines (17 loc) · 892 Bytes
/
calculator_match_case.py
File metadata and controls
19 lines (17 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
num_1: int = int(input("Enter first number: "))
num_2: int = int(input("Enter second number: "))
operation: str = input("Enter the operation to be performed: ")
match operation:
case "add" | "addition" | "+":
print(f"The answer is {num_1 + num_2} after performing {operation} on {num_1} and {num_2}.")
case "sub" | "subtraction" | "-":
print(f"The answer is {num_1 - num_2} after performing {operation} on {num_1} and {num_2}.")
case "product" | "multiplication" | "*":
print(f"The answer is {num_1 * num_2} after performing {operation} on {num_1} and {num_2}.")
case "quotient" | "division" | "/":
if num_2 == 0:
print("Invalid Operation.")
else:
print(f"The answer is {num_1 / num_2} after performing {operation} on {num_1} and {num_2}.")
case _:
print(f"{operation} is beyond my capabilities.")