Skip to content

Instantly share code, notes, and snippets.

@rochacbruno
Last active April 19, 2023 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rochacbruno/db174284bedcee000dd15a8937d69ea6 to your computer and use it in GitHub Desktop.
Save rochacbruno/db174284bedcee000dd15a8937d69ea6 to your computer and use it in GitHub Desktop.
"""E o pintinho piu."""
class Bicho:
def __init__(self, nome, som):
self.nome = nome
self.som = som
self.sexo = nome[-1] == "a" and "a" or "o"
def sound(self, times=1):
return f"{self.som} " * times
def title(self, times=1):
article = self.sexo == "o" and "" or "a"
sep = times > 1 and "\n" or ""
return f"Minha sogra tinha um{article} {self.nome}{sep}" * times
def night_sound(self, times=1):
return f"De noite {self.sexo} {self.nome} {self.sound(times)}"
def final(self, times=1):
return f"e o {self.nome} {self.sound(times)}!"
pintinho = Bicho("Pintinho", "Piu")
bichos = [
Bicho("Galinha", "có!"),
Bicho("Galo", "cocó!"),
Bicho("Peru", "glu glu!"),
Bicho("Gato", "miau!"),
Bicho("Cachorro", "au au!"),
Bicho("Vaca", "mó!"),
Bicho("Boi", "mú!"),
Bicho("Nenêm", "gugu!"),
Bicho("Pato", "quá!"),
]
print(pintinho.title(2))
print(pintinho.night_sound(3))
print(pintinho.final(3))
for n, bicho in enumerate(bichos):
for i in range(1, 3):
print(bicho.title())
print(bicho.night_sound())
for j in range(n - 1, -1, -1):
bichos[j].final()
for i in range(1, 3):
print(pintinho.final(3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment