Question: node.py class Node ( object ) : Represents a singly linked node. def _ _ init _ _ ( self , data,
node.py
class Nodeobject:
Represents a singly linked node."""
def initself data, nextNone:
Instantiates a Node with a default next of None."""
self.data data
self.next next
def main:
node None
node NodeA None
node NodeB node
printnodedata
printnodedata
#printnodedata error
nodelNodeC node
printnodeldata
if namemain:
main
LinkQueue.py
# linked Queue
from node import Node
class LinkedQueueobject:
def initself:
self.front self.rear None
def isEmptyself:
return selffront None # or you could ask for both
def addself item:
node Nodeitem
if self.isEmpty:
self.front self.rear node
return
self.rear.next node
self.rear node
def popself:
if self.isEmpty:
return None
value self.front.data
self.front self.front.next
if self.front None:
self.rear None
return value
def getFrontself:
if self.front None:
return None
return self.front.data
def getRearself:
if self.rear None:
return None
return self.rear.data
def strself:
probe self.front
st "queue:
while probe None:
st st strprobedata
probe probe.next
return st
# driver
def main:
queue LinkedQueue
printqueue # Print the queue
queue.add # Add
queue.add # Add
queue.add # Add
printqueue # Print the queue
queue.pop # Remove
queue.pop # Remove
printqueue # Print the queue
queue.add # Add
queue.add # Add
printqueue # Print the queue
printFront: queue.getFront # Get the front
printRear: queue.getRear # Get the rear
if namemain:
main
Create a python code for computer science student that is python beginner with this infomation: Chose an object from real life that is normally placed in a queue. Ex: call center
Create a class for that object and in addition to the constructor, init also write the method for the display str Create several of this object by instantiating the class in main and placed them in the queue. Use the queue class that we wrote in class. If you use another queue class because you were absent give credit to the author to follow the honor code. Add your objects, remove them, and print your removed objects. Print the final front object and print the rear object.
You will need your node.py if you use the class code, your queue python file, and your new class file that you are creating. You new file can have the imports and the main.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
