Sponsor Area
Stacks & Queues In List
Write PUSH (Books) and POP (Books) methods in python to add Books and remove Books considering them to act as Push and Pop operations of Stack.
def push(Books):
Stack.append(Books)
print 'Element:', Book, 'inserted successfully'
def pop():
if Stack == []:
print('Stack is empty!')
else:
print('Deleted element is',Stack.pop())
Some More Questions From Stacks & Queues in list Chapter
Differentiate between file modes r+ and rb+ with respect to Python.
Evaluate the following postfix notation of expression. Show status of the stack after every operation.
22,11,/,14,10,,+,5,2
22,11,/,14,10,,+,5,2
Write a statement in Python to perform the following operations:
- To open a text file “BOOK.TXT” in read mode
- To open a text file “BOOK.TXT” in write mode
Write a method in python to write multiple line of text contents into a text file myfile.txt line.
Consider the following definition of class Staff, write a method in python to search and display the content in a pickled file staff.dat, where Staff code is matching with ‘S0105’.
class Staff:
def __init__(self,S,SNM):
self.Staffcode=S
self.Name=SNM
def Show(self):
print(self.Staffcode,' ',
self.Name)
class Staff:
def __init__(self,S,SNM):
self.Staffcode=S
self.Name=SNM
def Show(self):
print(self.Staffcode,' ',
self.Name)Write PUSH (Books) and POP (Books) methods in python to add Books and remove Books considering them to act as Push and Pop operations of Stack.
Write a method in python to find and display the prime numbers between 2 to N. Pass N as an argument to the method.
Evaluate the following postfix notation of expression. Show status of the stack after every operation.
84, 62, –, 14, 3, *, +
84, 62, –, 14, 3, *, +
Sponsor Area
Mock Test Series
Mock Test Series



