class Alumno(): def __init__(self, nombre, nota): self.nombre = nombre self.nota = nota print("El alumno se ha creado con éxito!") def __str__(self): info = self.nombre + ", " + str(self.nota) return info def __calificacion__(self): if self.nota < 5: return print(self.nombre, " ha obtenido una nota de ", self.nota, " Ha suspendido.") else: return print(self.nombre, " ha obtenido una nota de ", self.nota, " Ha aprobado.") alumno1 = Alumno("Alejandro", 6) print(alumno1) alumno1.__calificacion__() alumno2 = Alumno("Marc", 2) print(alumno2) alumno2.__calificacion__()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter