In this we are going to see a basic example of python less than or equal to operator using operator overloading in Python Programming Language.
class Point:
def __init__(self, X):
self.X = X
def __lt__(self, U):
if(self.X < U.X):
return True
else:
return False
def __le__(self, U):
if(self.X <= U.X):
return True
else:
return False
p1 = Point(int(input("Please enter the value: ")))
p2 = Point(int(input("Please enter the value: ")))
if(p1 < p2):
print("The p1 is less than p2")
else:
print("The p2 is less than p1")
if(p1 == p2):
print("The p1 is equal to p2")
else:
print("The p2 is not equal to p1")
# Coded by Dhiraj Shelke
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP