Curso Completo De Python Programacion En Python Desde Cero Apr 2026
# Método especial (representación) def __str__(self): return f"Perro({self.nombre}, {self.edad})" mi_perro = Perro("Rex", 3) mi_perro.ladrar() print(mi_perro)
import mi_modulo print(mi_modulo.saludar()) from mi_modulo import saludar, PI from mi_modulo import * # no recomendado import mi_modulo as mm curso completo de python programacion en python desde cero
# Aritméticos: + - * / // % ** print(10 / 3) # 3.333... print(10 // 3) # 3 (división entera) print(10 % 3) # 1 (resto) print(2 ** 3) # 8 (potencia) Lógicos: and or not 5. Estructuras de Control Condicionales (if/elif/else) [{estado}] {t['descripcion']}")
persona = { "nombre": "Ana", "edad": 30, "ciudad": "Madrid" } print(persona["nombre"]) persona["profesion"] = "ingeniera" for clave, valor in persona.items(): print(f"{clave}: {valor}") (elementos únicos) {self.edad})" mi_perro = Perro("Rex"
# Esto es un comentario print("Hola") # Comentario en línea
def mostrar_tareas(tareas): if not tareas: print("No hay tareas.") return for i, t in enumerate(tareas, 1): estado = "✓" if t["completada"] else "✗" print(f"{i}. [{estado}] {t['descripcion']}")