कथन 2 के लिए उत्तर चुनें.
Choose the answer for statement 2.
import ___________ # statement 1
rec = [ ]
while True:
rn = int(input("Enter"))
nm = input("Enter")
temp = [rn, nm]
rec.append(temp)
ch = input("Enter choice (Y/N)")
if ch.upper == "N":
break
f = open("stud.dat", "____________") #statement 2
__________ .dump(rec, f) #statement 3
_______.close( ) # statement 4
A)
B)
C)
D)
Explanation:
Let's break down the code for statement 2.
Context:
The code involves writing data (a list of records) into a file, and since we're using serialization (as inferred from the usage of .dump()
), the file should be opened in binary write mode.
Explanation:
f = open("stud.dat", "____________")
:
Since we're writing binary data (likely usingpickle.dump()
), the correct mode to open the file should be"wb"
, which stands for write binary.
Answer:
(B) wb