-
-
Save parzibyte/a7c37a242c6aeb0c45b9423095069359 to your computer and use it in GitHub Desktop.
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
class Mascota(): | |
nombre = "" | |
edad = 0 | |
def __init__(self, nombre, edad): | |
self.nombre = nombre | |
self.edad = edad | |
# Aquí pueden ir más cosas que se hacen en un constructor | |
def saludar(self): | |
print("¡Hola! Me llamo {} y mi edad es {}".format( | |
self.nombre, self.edad)) | |
mascota = Mascota("Maggie", 3) | |
mascota.saludar() | |
otra_mascota = Mascota("Snowball", 1) | |
otra_mascota.saludar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment