Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
5.8k views
in Computer by (15.7k points)

Arun, during Practical Examination of Computer Science, has been assigned an incomplete search() function to search in a pickled file student.dat. The File student.dat is created by his Teacher and the following information is known about the file. 

• File contains details of students in [roll_no,name,marks] format.

• File contains details of 10 students (i.e. from roll_no 1 to 10) and separate list of each student is written in the binary file using dump(). 

Arun has been assigned the task to complete the code and print details of roll number 1. 

def search(): 

f = open("student.dat",____)   #Statement-1 

____:   #Statement-2 

while True: rec = pickle.____    #Statement-3 

if(____):     #Statement-4 

print(rec) 

except: 

pass ____    #Statement-5

I. In which mode Arun should open the file in Statement-1? 

a) r 

b) r+ 

c) rb 

d) wb

II.  Identify the suitable code to be used at blank space in line marked as Statement2 

a) if(rec[0]==1)

b) for i in range(10) 

c) try 

d) pass

III. Identify the function (with argument), to be used at blank space in line marked as Statement-3. 

a) load() 

b) load(student.dat) 

c) load(f) 

d) load(fin)

VI. What will be the suitable code for blank space in line marked as Statement-4. 

a) rec[0]==2 

b) rec[1]==2 

c) rec[2]==2 

d) rec[0]==1

V. Which statement Arun should use at blank space in line marked as Statement4 to close the file.

 a) file.close() 

b) close(file) 

c) f.close() 

d) close()

Please log in or register to answer this question.

1 Answer

+1 vote
by (15.2k points)

1. Correct Answer: c) rb

2. Correct Answer: c) try

3. Correct Answer: c) load(f)

4. Correct Answer: d) rec[0]==1

5. Correct Answer: c) f.close()

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...