Skip to content

Instantly share code, notes, and snippets.

@Glutexo
Created August 22, 2022 10:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glutexo/97daa781830108ca81012990cadff874 to your computer and use it in GitHub Desktop.
Save Glutexo/97daa781830108ca81012990cadff874 to your computer and use it in GitHub Desktop.
Rounding in Python
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