0% found this document useful (0 votes)
19 views

Xii Cs Worksheet-binary File

The document outlines various Python functions for handling binary files related to student, employee, book, toy, item, project, inventory, and candidate records. It includes tasks such as creating, reading, updating, and displaying records based on specific criteria, such as percentages, salaries, and product details. The document serves as a worksheet for students in a computer science class to practice binary file handling in Python.

Uploaded by

Mohammed Mishal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Xii Cs Worksheet-binary File

The document outlines various Python functions for handling binary files related to student, employee, book, toy, item, project, inventory, and candidate records. It includes tasks such as creating, reading, updating, and displaying records based on specific criteria, such as percentages, salaries, and product details. The document serves as a worksheet for students in a computer science class to practice binary file handling in Python.

Uploaded by

Mohammed Mishal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

BHARATHI VIDHYALAYA SENIOR SECONDARY SCHOOL

WORK SHEET – BINARY FILE HANDLING


CLASS: XII SUBJECT: COMPUTER SCIENCE
1 A binary file “STUDENT.DAT” has structure [admission_number, Name, Percentage]. Write a function
countrec() in Python that would read contents of the file “STUDENT.DAT” and display the details of those
students whose percentage is above 75. Also display number of students scoring above 75%.
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 STUDENT.DAT 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.
Consider a binary file Employee.dat 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.
A binary file named “TEST.dat” 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 TEST.dat. The function will calculate & display the Average of the ScoredMarks of the
passed Subject on screen.
A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].
a) Write a user defined function CreateFile() to input data for a record and add to Book.dat file.
b) 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 “Book.dat”
A binary file “Toy.dat” has structure [TID, Toy, Status, MRP].
i. Write a user defined function CreateFile() to input data for a record and add to Toy.dat.
ii. Write a function OnOffer() in Python to display the detail of those Toys, which has status as “ON OFFER”
from Toy.dat file.
A binary file “Toy.dat” has structure [TID, Toy, Status, MRP].
i. A binary file “ITEMS.DAT” has structure (ID, GIFT, Cost). Write a function to write more items in
ITEM.DAT
ii. Write a function Economic() in Python that would read contents of the file “ITEMS.DAT” and display the
details of those ITEMS whose cost is greater then 2500.
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)
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.
A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].
Write a user defined function CreateFile() to input data for a record and add to
Book.dat 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 “Book.dat”
A binary file “STUDENT.DAT” has structure (admission_number, Name,
Percentage).
Write a function countrec() in Python that would read contents of the file
“STUDENT.DAT” and display the details of those students whose percentage is above
75. Also count and display number of students scoring above 75%.
Mr. Darvy is a store manager working in a convenience store. She needs to manage the records of
inventory. For this, she wants the following information of each product to be stored:
• ProductID - integer
• ProductName - string
• Quantity - integer
• Price – float
• Brand - string

You, as a programmer assigned to develop POS software for this store, have been asked to do this job for
Mr. Darvy.
(I) Write a function to input the data of a product and append it in a binary file named ‘INVENTORY.DAT’.
(II) Write a function to update the data of those products whose Brand is ‘Nestle’ and reduce their price by
5%.
(III) Write a function to read the data from the binary file and display the data of all those products which
are produced by ‘Nirvana’ (brand).
Rahman is a manager working in a recruitment agency. He needs to manage the records of various
candidates. For this, he wants the following information of each candidate to be stored: -
Candidate_ID – integer
Candidate_Name – string
Designation – string
Experience – float
You, as a programmer of the company, have been assigned to do this job for Rahman.
(i) Write a function to input the data of a candidate and append it in a binary file.
(ii) Write a function to update the data of candidates whose experience is more than 10
years and change their designation to "Senior Manager".
(iii) Write a function to read the data from the binary file and display the data of all those
candidates who are not "Senior Manager".
Shivam Sen is a programmer in school , He needs to manage the records of various students. For this he wants
the following information of each student to be stored:
i. Mention any two difference between binary and csv files ?
ii. AddStudents() is a function to input the data of a students and append it in the file STUDENT.DAT containing
student information – roll number, name and marks (out of 100) of each student.
iii.GetStudents() is a function Write a function to read the data from the file 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

You might also like