Question:medium

Arrange the following in correct order:
A. listvalues = ['abc', 'Gen', 1, 2.4]
B. pickle.load(fileobject)
C. fileobject = open("file.dat", "wb")
D. pickle.dump(listvalues, fileobject)
Choose the correct answer from the options given below:

Show Hint

Remember:
- You cannot use pickle.dump() (D) before defining the list (A) and opening the file (C).
- You cannot read/load data (B) until you have first created and written it to the file (A $\rightarrow$ C $\rightarrow$ D)!
Updated On: Jun 11, 2026
  • A, B, C, D
  • B, A, C, D
  • D, C, B, A
  • A, C, D, B
Show Solution

The Correct Option is D

Solution and Explanation


Step 1: Understanding the Concept:

Pickling in Python is the process of serializing an object hierarchy. The correct sequence involves defining data, opening a file in binary write mode, dumping the data, and then potentially loading it back.

Step 2: Detailed Explanation:

1. A: Define the data to be pickled.
2. C: Open the file in 'wb' (write binary) mode.
3. D: Dump the list values into the file object.
4. B: Load the data back from the file object.

Step 3: Final Answer:

The correct order is A, C, D, B.
Was this answer helpful?
0


Questions Asked in CUET (UG) exam