VELAMMAL BODHI CAMPUS, ANUPPANADI, MADURAI
EXAM: UNIT TEST-V
SUBJECT: COMPUTER SCIENCE CHAPTER: FILE HANDLING & DATA STRUCTURES
MAX. MARKS: 35 CLASS: XII DATE: 17/07/25 TIME: 90MIN
SET-A
A) ANSWER THE FOLLOWING QUESTIONS
(8X1=8)
1. To read the entire content of the CSV file as a nested list from a file object infile,
we use __________ command.
(a) infile.read() (b) infile.reader() (c) csv.reader(infile) (d) infile.readlines()
2. The full form of CSV is
a) Comma Separated Values b) Comma Separated Value
c) Comma Separated Variables d) Comma Separate Value
3. Which is not the valid mode for binary files?
a) r b) rb c) wb d) wb+
4. Which of the following function is used to read the data in binary file?
a) read() b) open() c) dump() d) load()
5. Suresh wants to open the binary file student.dat in read mode. He writes the
following statement but he does not know the mode. Help him to find the same.
F=open(‘student.dat’, ____)
a) r b) rb c) w d) wb
6. The csv files are faster than Binary Files:
a) True b) False
7. a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
Assertion (A): CSV (Comma Separated Values) is a file format for data storage which
looks like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by comma.
8. Assertion (A) and Reason(R) based question. Mark the correct choice as:
Assertion (A): A stack is a FIFO data structures.
Reasoning (R): One of the common implementations of stack is in storing browsing
history.
B) ANSWER THE FOLLOWING QUESTIONS (5X2=10)
9. Differentiate read() and readlines() with syntax.
10. Write a function COUNT_AND( ) in Python to read the text file “STORY.TXT” and
count the number of times “AND” occurs in the file. (include AND/and/And in the
counting)
11. Write a Python function that finds and displays all the words longer than 5
characters from a text file "Words.txt".
12. Give any four applications of stack.
13. To write a python program to count the number of occurrence of the word “INDIA”
in a text file Country.txt.
C) ANSWER THE FOLLOWING QUESTIONS
(3X3=9)
14. Write a function in Python, Push(book) where, book is a dictionary containing the
details of a book in form of {bookno : price}.
1|Page
The function should push the book in the stack which have price greater than 300.
Also display the count of elements pushed into the stack.
15. Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list
push all numbers divisible by 5 into a stack implemented by using a list. Display the
stack if it has at least one element, otherwise display appropriate error message.
16. A List contains following record of a Book:
[Book Name, Write Name, Price]
Write the following user defined functions to perform given operations on the stack
named “BOOK” :
(i) Push_Rec( ) – To push the record containing Book name and author name of Books
having price > 500 to the stack.
(ii) Pop_Rec( ) – To pop the objects from the stack and display them. Also display
“STACK UNDERFLOW” when there are no elements in the Stack.
D) ANSWER THE FOLLOWING QUESTIONS
(2X4=8)
17. MsJoshika is the Lab Attendant of the school. She is asked to maintain the project
details of the project synopsis submitted by students for upcoming Board Exams.
The information required are:
-prj_id - integer
-prj_name-string
-members-integer
-duration-integer (no of months)
As a programmer of the school u have been asked to do this job for Joshika and define
the following functions.
i) Prj_input() - to input data of a project of student and append to the binary file
named Projects
ii) Prj_update() - to update the project details whose member are more than 3 duration
as 3 months.
18. Write a program in Python that defines and calls the following user defined
functions:
i. Add(): to add the record of an animal to a csv file “animal.csv”. Each record should
be with field elements [animalname, animaltype, animalfood]
ii. Search(): to print all the animal names who eat grass as their food.
2|Page