Name the Python module need to be imported to invoke the function? load()

2023

Name the Python module need to be imported to invoke the function? load()

Answer: B. pickleAnswer: pickle Reason: The load() function is provided by the pickle module and is used to deserialize (read) Python objects from a binary file. Import the…

  1. A.

    csv

  2. B.

    pickle

  3. C.

    sql

  4. D.

    binary

Attempted by 2226 students.

Show answer & explanation

Correct answer: B

Answer: pickle Reason: The load() function is provided by the pickle module and is used to deserialize (read) Python objects from a binary file. Import the module: import pickle

Open the file in binary read mode: with open('file.pkl', 'rb') as f:

Deserialize the object: obj = pickle.load(f)

Note: pickle.load expects a file opened in binary mode ('rb'). Using text mode will raise an error or produce incorrect results.

Explore the full course: Hpsc Pgt Computer Science

Loading lesson…