Fix formatting and improve greeting function in prueba.py

This commit is contained in:
Javier 2025-10-31 09:50:58 +01:00
parent 4e031680ba
commit ed481d9b15
2 changed files with 3 additions and 2 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
# ===================================== # =====================================
# VARIABLES Y TIPOS (No se declara tipo explícito) # VARIABLES Y TIPOS (No se declara tipo explícito)
# ===================================== # =====================================
nombre = "Javi" nombre = "Javi"
edad = 22 edad = 22
pi = 3.14 pi = 3.14
activo = True activo = True
@ -38,6 +38,7 @@ while contador < 3:
def saludar(nombre): def saludar(nombre):
return f"Hola {nombre}!" return f"Hola {nombre}!"
print(saludar("Mundo")) print(saludar("Mundo"))
@ -64,6 +65,6 @@ class Persona:
def saludar(self): def saludar(self):
print(f"Soy {self.nombre} y tengo {self.edad} años.") print(f"Soy {self.nombre} y tengo {self.edad} años.")
p1 = Persona("Javi", 22) p1 = Persona("Javi", 22)
p1.saludar() p1.saludar()