Sie sind auf Seite 1von 1

ASSIGNMENT BINARY FILES

Q1. A binary file “Employee.DAT” contains data attributes like: Ecode, Ename and Esalary in the form of a list Write the following functions:
Emp_Add(): Append Employee
Emp_Display(): Read the employee data and read all the records on the screen whose salary in between Rs. 35,000 and Rs.55,000.
Q2. Given a binary file “STUDENT.DAT”, containing records of the following attributes:
AdmNo: Admission number of the student
Name: Name of the student
Percentage: Percentage marks of the student
Write a function that would read the contents of file “STUDENT.DAT” and display the details of those students whose Percentage is
above 75.
Q3. Following is the attributes of each in a binary data file named “PRODUCT.DAT”.
PCode: Product code
PName: Product name
QStock: Stock quantity
UPrice: Unit price
Write a function Product_Update() to increase the Unit price (Uprice) as 10% whose product name is ‘FREEZE’.
Q4. Given a file “SPORTS.DAT” containing records of sports with following attributes:
Participant: Name of the participants
Events: Sports event name like: Swimming, Athletics etc.
Write a function Event_Copy() that would read contents from the file “SPORTS.DAT” and creates a file named “ATHELETIC.DAT”
coping only those records from “SPORTS.DAT” where event name is “ATHELETICS”. Assume that ‘_’ is a field separatorin “SPORTS.DAT”.
Q5. Given a binary file “PHONE.DAT”, containing records of the following attributes:
Phoneno: Phone number
AreaCode: Area Code like: DEL, MUM, CHE, KOL etc.
Name: Name of the person
Write the code for function Ptransfer_Detail() that would copy all those records which are having Areacode as “DEL” from “APHON.DAT”
to “PHONEBACK.DAT”.
1. Write the code for function Phone_Display() to display the records of either “APHONE.DAT” or “PHONEBACK.DAT” according to the user
2. choice. Note that the user should enter 1 for “APHONE.DAT” and 2 for “PHONEBACK.DAT”.
Q6. A binary file “CAMERA.DAT” containing the attributes of camera as given below:
ModelNo: Camera model number
Megapixel: Pixels of camera
Company: Manufacturer or company name
 Write the code for function Camera_add() to enter data into “CAMERA.DAT”.
 Write the code for function Camera_search to search for a camera “CAMERA.DAT” according to the Model No. The function
should search
and display the details of the camera.
Q7. Assuming the class DRINKS as defined below:
class DRINKS:
def_init_(self)
self.DENAME =”
self.Quantity = 0
self.Price = 0
defgetDRINK(self):
self.DENAME= input(“Enter drink name”). upper()
self.Quantity= int(input(“Enter quantity(50/100/150ml):”))
self.Price= float(input(“Enter drink price:”))
defshowDRINK(self):
print(self.DENAME+’,’, ‘Quantity:’, self.quantity, ‘ml.,’, ‘Price:’, self.Price)
Write the following functions in Python:
1. Write_Drinks() function to write the objects of DRINKS to a binary file “DRINK.DAT”. This function will call the class method getDRINKS() to
enter the details of class DRINKS.
2. View_Drinks function to read the objects of DRINKS from the binary file “DRINK.DAT” and display the details on the screen whose DNAME
is “MANGO” and Price>50. This function will call the showDRINKS() class method to display the details of class DRINKS.

Das könnte Ihnen auch gefallen