Skip to content

Commit 2f4497d

Browse files
authored
Merge pull request mouredev#6580 from Yisusocanto/main
#8 - Python
2 parents 8460fec + 51eca7f commit 2f4497d

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
class Traductor:
2+
3+
apellido = None
4+
5+
def __init__(self, name: str, edad: int, idioma: list):
6+
self.name = name
7+
self.edad = edad
8+
self.idioma = idioma
9+
10+
def print(self):
11+
print(f"Nombre: {self.name} / apellido: {self.apellido} / Edad: {self.edad} / idioma: {self.idioma}")
12+
13+
14+
mi_traductor = Traductor("Jesus", 20, ["español", "ingles", "frances"])
15+
mi_traductor.print()
16+
mi_traductor.apellido = "ocanto"
17+
mi_traductor.print()
18+
mi_traductor.idioma.pop(0)
19+
mi_traductor.print()
20+
21+
22+
#extra
23+
#
24+
class Pila:
25+
26+
def __init__(self, contenido: list):
27+
self.contenido = contenido
28+
29+
def print(self):
30+
print(f"contenido de la pila: {self.contenido}")
31+
32+
def agregar(self, elemento):
33+
self.contenido.append(elemento)
34+
35+
def quitar(self):
36+
self.contenido.pop()
37+
38+
39+
40+
mi_pila = Pila(["manzana"])
41+
mi_pila.print()
42+
mi_pila.agregar("pera")
43+
mi_pila.print()
44+
mi_pila.quitar()
45+
mi_pila.print()
46+
47+
48+
class Cola:
49+
50+
def __init__(self, contenido: list):
51+
self.contenido = contenido
52+
53+
def print(self):
54+
print(f"contenido de la cola: {self.contenido}")
55+
56+
def agregar(self, elemento):
57+
self.contenido.append(elemento)
58+
59+
def quitar(self):
60+
self.contenido.pop(0)
61+
62+
63+
64+
mi_cola = Cola(["manzana"])
65+
mi_cola.print()
66+
mi_cola.agregar("pera")
67+
mi_cola.print()
68+
mi_cola.quitar()
69+
mi_cola.print()

0 commit comments

Comments
 (0)