Which mode is used to open a binary file for both reading and writing?
(A) rb+
(B) wb+
(C) ab+
(D) rb
Which module needs to be imported in Python for binary file operations?
(A) json
(B) pickle
(C) os
(D) file
What does the wb mode do in binary file operations?
(A) Opens a binary file for reading
(B) Opens a binary file for writing (overwriting the file if it exists)
(C) Appends to a binary file
(D) Opens a binary file for both reading and writing
Which method is used to write data to a binary file using the pickle module?
(A) load()
(B) write()
(C) append()
(D) dump()
What is the function of rb mode in binary file operations?
(A) Read and write
(B) Read only
(C) Write only
(D) Append only
Which method is used to load or read data from a binary file using the pickle module?
(A) write()
(B) dump()
(C) load()
(D) read()
To append data to an existing binary file, which mode should you use?
(A) rb
(B) wb
(C) ab
(D) rb+
Which of the following operations is not directly supported by the pickle module?
(A) Writing data to a binary file
(B) Loading data from a binary file
(C) Searching data in a binary file
(D) Appending data to a binary file
Assertion-Reasoning:
Assertion (A): The wb+ mode in binary file operations allows both reading and writing. Reason (R): The wb+ mode opens the binary file for writing only, and overwrites the file if it exists.
(A) Both A and R are true, and R is the correct explanation of A.
(B) Both A and R are true, but R is not the correct explanation of A.
(C) A is true, but R is false.
(D) A is false, but R is true.
Assertion (A): The dump() method is used to store Python objects in a binary file using the pickle module. Reason (R): The dump() method can append data to an existing binary file without overwriting.
(A) Both A and R are true, and R is the correct explanation of A.
(B) Both A and R are true, but R is not the correct explanation of A.
(C) A is true, but R is false.
(D) A is false, but R is true.
SQL Programming Questions:
Write a Python program to open a binary file in write mode and store a list of numbers using the pickle.dump() method.
Write a Python program to open an existing binary file in read mode and display the content using pickle.load().
Write a Python program to append a new list of numbers to an existing binary file using ab mode.
Write a Python program to search for a specific number in a binary file after loading its content.
Write a Python program to create a binary file using wb mode and store a dictionary of student details.
Write a Python program to update an existing binary file by reading, modifying a value, and writing it back using rb+ mode.
Write a Python program to close a binary file after performing write operations and ensure no data is lost.
Write a Python program to demonstrate reading from a binary file using rb mode and checking for EOF (End of File).
Write a Python program to handle exceptions while performing dump() and load() operations on a binary file.
Write a Python program to open a binary file in ab+ mode and append a set of records, then read and display all the records.