Quiz Catalog

Catalog of quizzes

class BankCard:
  def __init__(self, x):
    self.balance = x

  def __lt__(self, other):
    return self.balance < other.balance

card1 = BankCard(700)
card2 = BankCard(200)
print(card1 > card2)
True
  • class/method/lt

class PersonHeight:
  def __init__(self, x):
    self.height = x

  def __gt__(self, other):
    return self.height < other.height

height1 = PersonHeight(170)
height2 = PersonHeight(165)
print(height1 >= height2)
TypeError: '>=' not supported between instances of 'PersonHeight' and 'PersonHeight
  • class/method/lt