import math class Pastel: def __init__(self, ingredientes, tamaño): self.ingredientes = ingredientes self.tamaño = tamaño def __repr__(self): return (f'Ingredientes ({self.ingredientes}, 'f'Tamaño {self.tamaño})') def area(self): return self.tamaño_area(self.tamaño) @staticmethod def tamaño_area(A): return math.pi*A**2 mi_pastel = Pastel(['harina', 'huevos', 'leche', 'azucar'], 20) print(mi_pastel.ingredientes) print(mi_pastel.tamaño) print(mi_pastel.tamaño_area(10)) class Coffee: @staticmethod def is_hot(temperature): if temperature > 70: return True else: return False print(Coffee.is_hot(80)) # True print(Coffee.is_hot(60)) # False class Persona: def __init__(self, nombre, apellido): self.nombre = nombre self.apellido = apellido def nombre_completo(self): return f"{self.nombre} {self.apellido}" @classmethod def de_nombre_completo(cls, nombre_completo): nombre, apellido = nombre_completo.split() return cls(nombre, apellido) @staticmethod def es_mayor_de_edad(edad): return edad >= 18 p1 = Persona("Juan", "Pérez") p2 = Persona.de_nombre_completo("María García") print(p1.nombre_completo()) # Juan Pérez print(p2.nombre_completo()) # María García print(Persona.es_mayor_de_edad(20)) # True print(Persona.es_mayor_de_edad(15)) # False