Inheritance

Question

Write Insert(Place) and Delete(Place) methods in python to add Place and RemovePlace considering them to act as Insert and Delete operations of the data structure Queue.

Answer

class queue:
	
	place = [ ]
	def insert(self):
		a = raw_input('Enter place')
		queue.place.append(a)
	def delete(self):
		if (queue.place == [ ] ):
			print('Queue empty')
		else:
			print('Deleted element is', queue.place[0])
			queue.place.delete()

Sponsor Area