Put your new knowledge of queues to use with this practice interview question. Create three classes total, one of which is a queue class, to simulate how a printer can obtain a job from a print queue.
- [Instructor] Now that we've gone over…implementing queues in Python,…let's put this new skill into practice…with a queues challenge.…The prompt is to create three classes…that, together, model how a printer…could take print jobs out of a print queue.…There are a few requirements.…The first is a class called PrintQueue…that follows the queue data structure implementation.…The second requirement would be a class called Job,…that has a pages attribute and each job…can have one to 10 pages.…
You can assign this number randomly in your program.…The job class should also have a print page method…that decrements page and a check complete method,…which will check whether or not…all the pages have been printed.…The third requirement is a printer class.…The printer class should have a get job method…that makes use of the queues built-in de-queue method…to take the first job in the print queue off of the queue.…Make sure you account for the case…where printqueue.items is empty,…or else you'll get an error.…
Go ahead and give this a try…
- Abstract types and data structures
- Stacks as a linear abstract data type
- Creating the Stack class and its methods
- Adding items to the top and bottom of a stack
- Creating the Queue class and its methods
- Manipulating items in a queue
- Creating the Dequeue class and its methods
- Adding and removing items from a dequeue
Skill Level Advanced
Learning the Python 3 Standard Librarywith Kathryn Hodge2h 10m Intermediate
What you should know1m 26s
1. Abstract Data Types and Data Structures
2. The Stack
3. The Queue
4. The Deque
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.