Professional Documents
Culture Documents
CH 4 - File Handling Material For Board Exam
CH 4 - File Handling Material For Board Exam
if found==True:
print("employee record found and updated")
else:
print("employee record not found and updating not
possible")
(i) Write the statement to import the needed module.
(ii) Write the statement to open the file named “emp.bin” as
per the need of the code.
(iii) Write the statement to store the position of the file
pointer.
(iv) Complete the blank with the statement to write the
object “e” into the file.
8. Ariba Malik has been following incomplete code, which
takes a student‟s details (rollnumber, name and marks)
and writes into a binary file stu.dat using pickling.
import pickle
sturno=int(input(“Enter roll number:”))
stuname=input(“Enter name:”)
stumarks=float(input(“Enter marks:”))
stu1={"RollNo.":sturno,"Name":stuname,"Marks":stumarks}
with __________ as fh: # Fill_Line1
________________ # Fill_Line2
______________ as fin: # Fill_Line3
________________ # Fill_Line4
print(Rstu)
if Rstu[“Marks”]>=85:
print(“Eligible for merit certificate”)
else:
print(“Not eligible for merit certificate”)