Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create an empty stack and push the name J . R . R . Tolkien in as the first ( bottom )
Create an empty stack and push the name JRR Tolkien" in as the first bottom element.
Read Print the contents of your stack; it's okay if it includes newline characters
and the brackets Python uses when outputting lists.
One at a time, pop and output the three top names from the stack; this should remove those three names from the collection.
Push your own name into the stack.
Print the contents of the stack.
Steps for the queue:
Create a queue using the deque class covered in this module.
Push the name of a fictional character from a book, movie, tv show, etc into the queue; this name should go at the "back" of the queue as the newest addition and would be the last name to be removed
One at a time, push the names from the text file into your queue.
Print the contents of the queue; it's okay if it includes newline characters
and the brackets Python uses when outputting lists.
One at time, pop and print the five oldest names in the queue; this will remove those names from the collection.
Push the name of a school teacher you liked into the "back" of the queue.
Push the name of a favorite actor or musical artist; this name should go at the "back" of the queue.
Print the contents of the queue; it's okay if it includes newline characters
and the brackets Python uses when outputting lists.the text file and push each name onto the stack.
pip python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started