Respuesta :

print("Using a for loop to print the colors list elements:")

print("Using a for loop with range(10) to print iterator values and a string:")

for i in range(10):

print(i, “Hello”)

counter = 0

print("Using a while loop to print iterator values and a string:")

while counter < 5:

print(counter, "Loop while the counter is less than 5")

counter = counter + 1

print("The for loop removes and prints list elements in stack order:")

for i in range(len(colors)):

print(colors.pop())

print("The colors list after all elements are removed:\n", colors)

new_colors = ["red", "orange", "yellow", "green", "blue", "purple"]

print("The loop prints and removes elements in the new_colors list in queue order:")

for i in range(len(new_colors)):

print(new_colors.pop(0))

print("The new_colors list after all elements are removed:\n", new_colors)

more_colors = ["violet", "pink", "brown", "teal", "magenta"]

more_colors_deque = deque(more_colors)

print("Elements in the more_colors list:\n", more_colors)

print("Elements in the deque object:\n", more_colors_deque)

print("Using a for loop to print the deque elements as a queue:")

for i in range(len(more_colors_deque)):

print(more_colors_deque.popleft())

print("Printing the deque object after all elements are removed:\n",

more_colors_deque)

ACCESS MORE
EDU ACCESS
Universidad de Mexico