Last active
August 22, 2020 08:12
-
-
Save saumalya75/13d0c798af462e23afc3ca92d1540fbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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