Page 43 - C++
P. 43
+ Pop(60) 210 210
Pop(150)
Push(150+60)=210
(½ mark for correct stack status till „-‟)
(½ mark for correct stack status till „*‟)
(½ mark for correct stack status till „*‟)
(½ mark for correct stack status till „+‟)
or
(½ mark for writing the correct result without showing the working of Stack)
Q4. (a) Nancy intends to position the file pointer to the beginning of a text file.Write Python 1
statement for the same assuming F is the Fileobject.
Ans F.seek(0)
(1 mark for the correct answer)
(b) Write a function countmy( )in Python to read the text file “DATA.TXT” and count the
number of times “my” occurs in the file.
For example if the file “DATA.TXT” contains: 2
“This is my website. I have displayed my preferences in the CHOICE section.”
The countmy( ) function should display the output as:
“my occurs 2 times”.
Ans
(½ mark for reading the file using read)
(½ mark for correctly using split())
(½ mark for the correct loop)
(½ mark for displaying the correct value of count)
(c) Write a function in Python to search and display details of all those students, whose 3
stream is “HUMANITIES” from pickled file “Student.dat”. Assuming the pickled file is
containing the objects of the following class:
Page No. 26