0% found this document useful (0 votes)
112 views1 page

Binary Test Question

The document contains 8 questions that ask the writer to create Python functions to interact with various binary files. The functions include: 1. Creating a function to input data records into a binary file called "Book.dat" with fields for book number, name, author, and price. 2. Creating a function to count and return the number of books by a given author stored in the "Book.dat" file. 3. Displaying details of students from the "STUDENT.DAT" file whose percentage is above 75%, along with the number of such students. 4. Searching and displaying details from the "Bus.Dat" file for records where the destination is "Cochin

Uploaded by

Aditya Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views1 page

Binary Test Question

The document contains 8 questions that ask the writer to create Python functions to interact with various binary files. The functions include: 1. Creating a function to input data records into a binary file called "Book.dat" with fields for book number, name, author, and price. 2. Creating a function to count and return the number of books by a given author stored in the "Book.dat" file. 3. Displaying details of students from the "STUDENT.DAT" file whose percentage is above 75%, along with the number of such students. 4. Searching and displaying details from the "Bus.Dat" file for records where the destination is "Cochin

Uploaded by

Aditya Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. A binary file “Book.

dat” has structure [BookNo, Book_Name, Author,


Price].
1. Write a user defined function CreateFile() to input data for a record
and add to [Link] .
2. Write a function CountRec(Author) in Python which accepts the
Author name as parameter and count and return number of books by
the given Author are stored in the binary file “[Link]

Q2. 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%.

Q3 Write a function in python to search and display details, whose


destination is “Cochin” from binary file “[Link]”. Assuming the binary file
is containing the following elements in the list:
1. Bus Number
2. Bus Starting Point
3. Bus Destination
Q4. Write a function addrec() in Python to add more new records at the
bottom of a binary file “[Link]”, assuming the binary file is
containing the following structure :[Roll Number, Student Name]

Q5. Write a function searchprod( pc) in python to display the record of a


particular product from a file [Link] whose code is passed as an
argument. Structure of product contains the following elements [product
code , product price]

Q6. Write a function routechange(route number) which takes the Route


number as parameter and modify the route name(Accept it from the user)
of passed route number in a binary file “[Link]”.

Q7. Write a function countrec(sport name) in Python which accepts the


name of sport as parameter and count and display the coach name of a
sport which is passed as argument from the binary file “[Link]”. Structure
of record in a file is given below ——————– – [sport name, coach name]

Q8. A binary file “[Link]” has structure [employee id, employee name,
salary]. Write a function countrec() in Python that would read contents of
the file “[Link]” and display the details of those employee whose salary
is above 20000.

You might also like