xxxxxxxxxx
#A class for heights in meters
class Height:
def __init__(self, value):
self.value = value
#define the __le__() method
def __le__(self, other):
if isinstance(other, Height):
#Check that the 'other' object is an instance of this class
return self.value <= other.value
#Raise an error if 'other' is not an instance of this class
raise TypeError("Both objects should be instances of 'Height'")
h1 = Height(5.4)
h2 = Height(7.5)
h3 = Height(3.0)
print(h1 <= h2)
print(h2 <= h3)