Sign InCoursewareNuggetsTutorials CoursesCodePad

Color Balls

In this task, you have a list of colors and use a queue to store them. Draw a row of balls based on the colors in the queue.

class Queue: def __init__(self): self.items = [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): return self.items.pop() def peek(self): return self.items[len(self.items)-1] def isEmpty(self): return (self.items == []) def draw_balls(color_list): #TODO: Draw color balls using the colors specified in color_list. Make sure to use a queue. draw_balls(["red", "blue", "green", "yellow", "purple", "red", "orange"])
© CS Wonders·About·Gallery·Fun Facts·Cheatsheet