Created
August 22, 2022 10:01
-
-
Save Glutexo/97daa781830108ca81012990cadff874 to your computer and use it in GitHub Desktop.
Rounding in Python
This file contains 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
ANIMALS = { | |
"๐": "๐ฐ", | |
"๐": "๐ญ", | |
"๐": "๐ฑ", | |
"๐": "๐ถ", | |
"๐ ": "๐ฏ", | |
"๐": "๐ฎ", | |
"๐": "๐ท", | |
"๐": "๐ต", | |
"๐ฅ": "๐ค", | |
"๐": "๐ด" | |
} | |
class Animal: | |
def __init__(self, species): | |
self.species = species | |
def __round__(self): | |
return Animal(ANIMALS[self.species]) | |
def __repr__(self): | |
return repr(self.species) | |
def __str__(self): | |
return self.species | |
def main(): | |
rabbit = Animal("๐") | |
rounded_rabbit = round(rabbit) | |
print(rabbit) | |
print(rounded_rabbit) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment