BRILLIANT CBSE SCHOOL
PUDUKKOTTAI ULLUR
Binary File Questions
Class : XII Sub : Computer Science (083)
1) Ms Joshika 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) 5 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. iii) Prj_solo() - to read the data from the binary file and display
the data of all project synopsis whose member is one.
2) A binary file “[Link]” has structure [BookNo, Book_Name, Author, Price]. Write a user defined function
CreateFile() to input data for a record and add to [Link] file . Write a function CountRec(Author) in Python
which accepts the Author name as parameter and count and return number of books written by the given Author
are stored in the binary file “[Link]” OR A binary file “[Link]” has structure (admission_number,
Name, Percentage). Write a function countrec() in Python that would read contents of the file
“[Link]” and display the details of those students whose percentage is above 75. Also count and
display number of students scoring above 75%.
3) A binary file [Link] needs to be created with following data written it in the form of Dictionaries.
Rollno Name Age
1001 TOM 17
1002 BOB 16
1003 KAY 16
Write the following functions in python accommodate the data and manipulate it. a) A function insert() that
creates the [Link] file in your system and writes the three dictionaries. 2+3 15 | Page b) A function read() that
reads the data from the binary file and displays the dictionaries whose age is 16.
4) Sheela is a Python programmer. She has written a code and created a binary file "[Link]" that has structure
[BookNo, Book_Name, Author, Price]. The following user defined function CreateFile0 is created to take input
dáta for a record and add to [Link] and another user defined function CountRec(Author) which accepts the
Author name as parameter and count and return number of books by the given Author.
5) Mr. Deepak is a Python programmer. He has written a code and created a binary file “[Link]” with
empid, ename and salary. The file contains 15 records. He now has to update a record based on the employee id
entered by the user and update the salary. The updated record is then to be written in the file “[Link]”. The
records which are not to be updated also have to be written to the file “[Link]”. If the employee id is not
found, an appropriate message should to be displayed.
6) Reshabh is a programmer, who has recently been given a task to write a python code to perform the following
binary file operations with the help of two user defined functions/modules:
a. AddStudents() to create a binary file called [Link] containing student information – roll number,
name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who have a percentage greater than 75. In
case there is no student having percentage > 75 the function displays an appropriate message. The function
should also display the average percent.
7) Sumit is a Python programmer. He has created a binaryfile [Link] with employeeid, ename and [Link]
file contains 10 records. He now has to update are the employeeid entered by the user and update the salary. The
updated record is then to be written in the “[Link]”. The records which are not to be updated also have to
be written to the file “[Link]”. If the employeeid is not found, an appropriate message should to be displayed.
8) Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an item to a binary file ‘[Link]’. Each record of the file is a list
[Event_id, Description, Venue, Guests, Cost]. Event_Id, Description, and venue are of str type, Guests and Cost
are of int type.
(ii) COUNTR() – To read the data from the file [Link], calculate and display the average number of guests
and average cost.
9) Manoj is learning to work with Binary files in Python using a process known as Pickling/de pickling. He
needs to create a Binary file namely [Link] and then opens, reads and displays the content of this created
file.
10) A binary file “[Link]” has structure (admission_number, Name, Percentage). Write a function
countrec() in Python that would read contents of the file “[Link]” and display the details of those
students whose percentage is above 75. Also display number of students scoring above 75%.
11) Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an item to a binary file ‘[Link]’. Each record of the file is a list
[Fur_id, Description, Price, and Discount]. Fur_Id and Description are of str type, Price is of int type, and
Discount is of float type.
(ii) COUNTR() – To count the number of records present in ‘[Link]’ whose price is less than 5000.
11) Write a Python program to open a binary file named “[Link],” which contains student records with the
structure: Roll Name SemPercentage The program should display only the records of students whose percentage
is above 30.
12) A Binary file “[Link]” stores details of lottery ticket holders . The file stores the following details :
TicketNo State Type Prizemoney Write a program using two functions to operate the file data.
(a) AddBuyers(State) : To accept more ticket details and store them into the file only if the ticket is not from
state passed as parameter to the function.
(b) TicketSearch(tid) : To open the file “[Link]” and display details of the ticket whose id is supplied as the
parameter to the function.
13) Amritya Seth is a programmer, who has recently been given a task to write a python code to perform the
following binary file operations with the help of two user defined functions/modules:
a. AddStudents() to create a binary file called [Link] containing student information – roll number,
name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who have a percentage greater than 75. In
case there is no student having percentage > 75 the function displays an appropriate message. The function
should also display the average percent.
14) Consider a binary file [Link] containing details such as empno:ename:salary(separator ‘:’). Write a
Python function Readfile() to display details of those employees who are earning between 20000 and
40000(both values inclusive) also count how many records are available in the file.
15) A binary file named “[Link]” has some records of the structure [TestId, Subject, MaxMarks,
ScoredMarks] Write a function in Python named DisplayAvgMarks(Sub) that will accept a subject as an
argument and read the contents of [Link]. The function will calculate & display the Average of the
ScoredMarks of the passed Subject on screen.
16) A binary file “[Link]” has structure [TID, Toy, Status, MRP]. i. Write a user defined function CreateFile()
to input data for a record and add to [Link]. ii. Write a function OnOffer() in Python to display the detail of
those Toys, which has status as “ON OFFER” from [Link] file.
17) A binary file “[Link]” has structure (ID, GIFT, Cost). Write a function to write more items in
[Link] ii. Write a function Economic() in Python that would read contents of the file “[Link]” and
display the details of those ITEMS whose cost is greater then 2500.
18) Vanshika is learning Python and working with Binary Files. Her teacher has given her the following
incomplete, which is creating a binary file “[Link]” which contains student’s details (RNo, Name and
Marks) in the form of [Link] now has to open the file, search for the Roll No., which will be entered by the
user and display the Student’s Details, if roll no. found otherwise print the message “Roll Number Not Found”.
The content of the List are : [Rollno, Name, Marks]
19) Tarun is a student, who wants to make a python program for Sports Department . He is using binary file
operations with the help of two user defined functions/modules.
(A) New_Entry() to create a binary file called [Link] containing sports related material information-
item_id, item_name and item_qty.
(B) Show_Item() to display the item _name and item_qty of items which item_qty less than 5. In case there is no
item available that which quantity is less than 5 the function displays message.