forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinerlander.py
87 lines (67 loc) · 1.56 KB
/
linerlander.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
"""
Ejercicio
"""
# Pilas/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)
# encolar
queue = []
queue.append(1)
queue.append(2)
queue.append(3)
print(queue)
# colar
queue_item = queue[0]
del queue[0]
print(queue_item)
print(queue.pop(0))
print(queue)
"""
Extra
"""
def web_navegation():
stack = []
while True:
action = input("Añade una urla 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 ala web {stack[len(stack) -1]}.")
else:
print('Estás en la página de inicio.')
#web_navegation()
def share_printed():
queue = []
while True:
action = input("Añade una documento o seleciona imprimir/salir: ")
if action == "salir":
break
elif action == "imprimir":
if len(queue) > 0:
print(f"Imprimiendo: {queue.pop(0)}")
else:
print('La cola de la impresión esta vacía')
break
else:
queue.append(action)
print(f'cola de impresión {queue}')
#share_printed()