Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import random
- mascota1 = str(input("Como se llama tu mascota: "))
- mascota2 = str(input("Como se llama tu otra mascota: "))
- def ambre():
- hambre = random.randint(0,1)
- return hambre
- def limpiesa():
- limpieza = random.randint(0,1)
- return limpieza
- class Mascota(object):
- def __init__(self,nombre,hambre,limpio):
- self.nombre = nombre
- self.limpio = limpio
- self.hambre = hambre
- def tiene_hambre(self):
- if self.hambre == True:
- print ("%s tiene hambre" %(self.nombre))
- else:
- print ("No tiene hambre %s" %(self.nombre))
- def limpiar(self):
- if self.limpio == True:
- print ("%s necesita limpieza" %(self.nombre))
- else:
- print ("Todo limpio con %s" %(self.nombre))
- animal1 = Mascota(mascota1,ambre(),limpiesa())
- animal1.limpiar()
- animal2 = Mascota(mascota2,ambre(),limpiesa())
- animal2.tiene_hambre()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement