forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrianSilvero.py
94 lines (68 loc) · 1.65 KB
/
BrianSilvero.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
"""
Ejercicio
"""
stack = []
# Pila/Stack (LIFO)
#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 = []
#queque
queue.append(1)
queue.append(2)
queue.append(3)
print(queue)
queue_item = queue[0]
del queue[0]
print (queue_item)
queue.pop(0)
print(queue)
"""
Extra
"""
def web_navegation():
stack= []
while True:
action = input("Añade un url o iteractua con palabras adelante/atras/salir: ")
if action == "salir":
print("Saliendo del navegador web")
break
elif action == "adelante":
stack.pop(0)
elif action == "atras":
if stack > 0:
stack.pop()
else:
stack.append(action)
pass
print(f"Has navegado a la web: {stack[len(stack) - 1]}")
if len(stack) > 0:
print(f"Has navegado a la web: {stack[len(stack) - 1]}")
else:
print("Estas en la pagina de inicio.")
# web_navegation()
def shared_printer ():
queue= []
while True:
action = input("Añade documento o selecciona imprimir/salir: ")
if action == "salir":
print("Saliendo de impresora")
break
elif action == "imprimir":
if len(queue) > 0:
print(f"Imprimiendo {queue.pop(0)}")
else:
print("La cola esta vacia")
else:
queue.append(action)
print(f"Cola de impresion {queue}")
shared_printer()