-
Notifications
You must be signed in to change notification settings - Fork 0
/
arthimetic_operations.py
26 lines (24 loc) · 1010 Bytes
/
arthimetic_operations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# This class does arithmetic operations
class ArthimeticClass:
def add(x, y):
# adding two numbers
if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
raise TypeError("Both inputs should be numbers")
return x + y
def subtract(x, y):
# subtracting two numbers
if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
raise TypeError("Both inputs should be numbers")
return x - y
def multiply(x, y):
# multiplying two numbers
if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
raise TypeError("Both inputs should be numbers")
return x * y
def divide(x, y):
# dividing two numbers
if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
raise TypeError("Both inputs should be numbers")
elif y == 0:
raise TypeError("division by zero is not allowed")
return x / y