Skip to content

Instantly share code, notes, and snippets.

@saumalya75
Last active August 22, 2020 08:12
Show Gist options
  • Select an option

  • Save saumalya75/13d0c798af462e23afc3ca92d1540fbc to your computer and use it in GitHub Desktop.

Select an option

Save saumalya75/13d0c798af462e23afc3ca92d1540fbc to your computer and use it in GitHub Desktop.
class Student:
def __init__(self, name: str, phone_number: int, standard: str):
self.name = name
self.standard = standard
self.phone_number = phone_number
def __str__(self):
return self.name
@staticmethod
def _get_standard_weight(std: str):
standard_weightage_list = [
'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII'
]
return standard_weightage_list.index(std.upper()) + 1
def __eq__(self, other):
if self._get_standard_weight(self.standard) == \
self._get_standard_weight(other.standard):
return True
else:
return False
def __gt__(self, other):
if self._get_standard_weight(self.standard) > \
self._get_standard_weight(other.standard):
return True
else:
return False
def __ge__(self, other):
if self._get_standard_weight(self.standard) >= \
self._get_standard_weight(other.standard):
return True
else:
return False
def __lt__(self, other):
if self._get_standard_weight(self.standard) < \
self._get_standard_weight(other.standard):
return True
else:
return False
def __le__(self, other):
if self._get_standard_weight(self.standard) <= \
self._get_standard_weight(other.standard):
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment