-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
mouredev.py
100 lines (67 loc) · 1.49 KB
/
mouredev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
Ejercicio
"""
# Pila/Stack (LIFO)
stack = []
# push
stack.append(1)
stack.append(2)
stack.append(3)
print(stack)
# pop
stack_item = stack[len(stack) - 1]
del stack[len(stack) - 1]
print(stack_item)
print(stack.pop())
print(stack)
# Cola/Queue (FIFO)
queue = []
# enqueue
queue.append(1)
queue.append(2)
queue.append(3)
print(queue)
# dequeue
queue_item = queue[0]
del queue[0]
print(queue_item)
print(queue.pop(0))
print(queue)
"""
Extra
"""
# Web
def web_navigation():
stack = []
while True:
action = input(
"Añade una url o interactúa con palabras adelante/atrás/salir: "
)
if action == "salir":
print("Saliendo del navegador web.")
break
elif action == "adelante":
pass
elif action == "atrás":
if len(stack) > 0:
stack.pop()
else:
stack.append(action)
if len(stack) > 0:
print(f"Has navegado a la web: {stack[len(stack) - 1]}.")
else:
print("Estás en la página de inicio.")
web_navigation()
def shared_printed():
queue = []
while True:
action = input("Añade un documento o selecciona imprimir/salir: ")
if action == "salir":
break
elif action == "imprimir":
if len(queue) > 0:
print(f"Imprimiendo: {queue.pop(0)}")
else:
queue.append(action)
print(f"Cola de impresión: {queue}")
shared_printed()