CBSE Class 12 Computer Science File Handling Worksheet Set B

Read and download free pdf of CBSE Class 12 Computer Science File Handling Worksheet Set B. Download printable Computer Science Class 12 Worksheets in pdf format, CBSE Class 12 Computer Science File Handling Worksheet has been prepared as per the latest syllabus and exam pattern issued by CBSE, NCERT and KVS. Also download free pdf Computer Science Class 12 Assignments and practice them daily to get better marks in tests and exams for Class 12. Free chapter wise worksheets with answers have been designed by Class 12 teachers as per latest examination pattern

File Handling Computer Science Worksheet for Class 12

Class 12 Computer Science students should refer to the following printable worksheet in Pdf in Class 12. This test paper with questions and solutions for Class 12 Computer Science will be very useful for tests and exams and help you to score better marks

Class 12 Computer Science File Handling Worksheet Pdf

Question. Which function is used to change the position of the File Handle to a given specific position.
a) seek()
b) read()
c) tail()
d) write()

Answer : A

Question. How do you change the file position to an offset value from the start?
a) fp.seek(offset, 0)
b) fp.seek(offset, 1)
c) fp.seek(offset, 2)
d) none of the mentioned

Answer : A

Question. Which is the correct statement with respect of seek() function?
a) 0: sets the reference point at the beginning of the file
b) 1: sets the reference point at the current file position
c) 2: sets the reference point at the end of the file
d) All of these

Answer : D

Question. Which of the following statements correctly explain the function of seek() method?
a) tell the current position within the file.
b) indicate that the next read or write occurs from that position in a file.
c) determine if you can move the file position or not.
d) move the current file position to a different location at a defined offset.

Answer : D

Question. What does the <readlines()> method returns?
a) str
b) a list of lines
c) list of single characters
d) list of integers

Answer : B

Question. Which of the following functions can be used to check if a file “logo” exists?
a) os.path.isFile(logo)
b) os.path.exists(logo)
c) os.path.isfile(logo)
d) os.isFile(logo)

Answer : C

Question. Seek() function with negative offset only works when file is opened in ——– mode.
a) read mode
b) write mode
c) binary mode
d) All of these

Answer : C

Question. What happens if no arguments are passed to the seek function?
a) file position is set to the start of file
b) file position is set to the end of file
c) file position remains unchanged
d) error

Answer : D

Question. What is the use of seek() method in files()?
a) sets the file’s current position at the offset
b) sets the file’s previous position at the offset
c) sets the file’s current position within the file
d) none of the mentioned

Answer : A

Question. To read the next line of the file from a file object fobj, we use:
a) fobj.read(2)
b) fobj.read()
c) fobj.readline()
d) fobj.readlines()

Answer : C

Question. Which of the following commands can be used to read “n” number of characters from a file using the file object <file>?
a) file.read(n)
b) n = file.read()
c) file.readline(n)
d) file.readlines()

Answer : A

Question. What is the use of seek() method in files?
a) sets the file‟s current position at the offset
b) sets the file‟s previous position at the offset
c) sets the file‟s current position within the file
d) none of the mentioned

Answer : A

Question. Which of the following statements correctly explain the function of tell() method?
a) tells the current position within the file.
b) indicates that the next read or write will occur at that many bytes from the beginning of the file.
c) move the current file position to a different location.
d) it changes the file position only if allowed to do so else returns an error.

Answer : A, B

Question. Which of the following command is used to open a file “c:\temp.txt” in append-mode?
a) outfile = open(“c:/temp.txt”, “a”)
b) outfile = open(“c:\\temp.txt”, “rw”)
c) outfile = open(“c:\temp.txt”, “w+”)
d) outfile = open(“c:\\temp.txt”, “r+”)

Answer : A

Question. How do you get the current position within the file?
a) fp.seek()
b) fp.tell()
c) fp.loc
d) fp.pos

Answer : B

Question. Which of the following command is used to open a file “c:\temp.txt” in read-mode only?
a) infile = open(“c:\temp.txt”, “r”)
b) infile = open(“c:\\temp.txt”, “r”)
c) infile = open(file = “c:\temp.txt”, “r+”)
d) infile = open(file = “c:\\temp.txt”, “r+”)

Answer : B

Question. If we open the file in read mode then the initial value of tell() is
a) -1
b) 0
c) 1
d) End of the file

Answer : A

Question. What happens if no arguments are passed to the seek function?
a) file position is set to the start of file
b) file position is set to the end of file
c) file position remains unchanged
d) error

Answer : D

 
1. Fill in the blanks.
 
i. ..................... format is a text format, accessible to all applications across several platforms.
 
ii. ..................... method is used for random access of data in a CSV file.
 
iii. ..................... method of pickle module is used to write an object into binary file.
 
iv. ..................... method of pickle module is used to read data from a binary file.
 
v. ..................... is a string method that joins all values of each row with comma separator in CSV.
 
vi. ..................... object contains the number of the current line in a CSV file.
 
2. State whether the following statements are True or False.
 
i. The type of operation that can be performed on a file depends upon the file mode in which it is opened.
 
ii. Functions readline() and readlines() are essentially the same.
 
iii. Comma is the default delimiter for a CSV file.
 
iv. tell() method of Python tells us the current position within the file.
 
v. The offset argument to seek() method indicates the number of bytes to be moved.
 
vi. If the offset value is set to 2, beginning of the file would be taken as seek position.
 
3. Multiple Choice Questions (MCQs)
 
(a) Which of the following is not a valid mode to open a file?
 
(i) ab   (ii) rw   (iii) r+   (iv) w+
 
(b) Which statement is used to change the file position to an offset value from the start?
 
(i) fp.seek(offset, 0) (ii) fp.seek(offset, 1)
 
(iii) fp.seek(offset, 2) (iv) None of the above
 
(c) The difference between r+ and w+ modes is expressed as?
 
(i) No difference (ii) In r+ mode, the pointer is initially placed at the beginning of the file and the pointer is at the end for w+
 
(iii) In w+ mode, the pointer is initially placed at the beginning of the file and the pointer is at the end for r+
 
(iv) Depends on the operating system
 
(d) What does CSV stand for?
 
(i) Cursor Separated Variables    (ii) Comma Separated Values
 
(iii) Cursor Separated Values     (iv) Cursor Separated Version
 
(e) Which module is used for working with CSV files in Python?
 
(i) random   (ii) statistics   (iii) csv   (iv) math
 
(f) Which of the following modes is used for both writing and reading from a binary file?
 
(i) wb+    (ii) w    (iii) wb   (iv) w+
 
(g) Which statement is used to retrieve the current position within the file?
 
(i) fp.seek()   (ii) fp.tell()   (iii) fp.loc   (iv) fp.pos
 
(h) What happens if no arguments are passed to the seek() method?
 
(i) file position is set to the start of file
 
(ii) file position is set to the end of file
 
(iii) file position remains unchanged
 
(iv) results in an error
 
(i) Which of the following modes will refer to binary data?
 
(i) r   (ii) w   (iii) +   (iv) b
 
(j) Every record in a CSV file is stored in reader object in the form of a list using which method?
 
(i) writer()   (ii) append()   (iii) reader()   (iv) list()
 
4. Consider the following code:
 
f = open('test', 'w+')
f.write('0123456789abcdef')
f.close()
f=open('test','rb')
f.seek(-3,2) //Statement 1
print(f.read(2)) //Statement 2
f.close()
Explain statement 1 and give output of statement 2.
5. What is the output of the following code :
fh = open("test.txt", "r")
Size = len(fh.read())
print(fh.read(5))
 
6. Give the output of the following snippet:
 
import pickle
list1, list2 = [2, 3, 4, 5, 6, 7, 8, 9, 10], []
for i in list1:
if (i%2==0 and i%4==0):
list2.append(i)
f = open("bin.dat","wb")
pickle.dump(list2, f)
f.close()
f = open("bin.dat", "rb")
data = pickle.load(f)
f.close()
for i in data:
print(i)
 
7. Following is the structure of each record in a data file named as
 
”PRODUCT.DAT”.
{"prod_code":value, "prod_desc":value, "stock":value}
The values for prod_code and prod_desc are strings, and the value for stock is an integer. Write a function in PYTHON to update the file with a new value of stock.
The stock and the prod_code, whose stock is to be updated, are to be input during the execution of the function.
 
8. Given a binary file “STUDENT.DAT”, containing records of the following type:
 
[S_Admno, S_Name, Percentage]
Where these three values are:
S_Admno – Admission Number of student (string)
S_Name – Name of student (string)
Percentage – Marks percentage of student (float)
Write a function in PYTHON that would read contents of the file
“STUDENT.DAT” and display the details of those students whose percentage is above 75.
 
9. Assuming the tuple Vehicle as follows:
 
( vehicletype, no_of_wheels)
Where vehicletype is a string and no_of_wheels is an integer.
Write a function showfile() to read all the records present in an already existing binary file SPEED.DAT and display them on the screen, also count the number of records present in the file.
 
10. Write a function in PYTHON to search for a BookNo from a binary file
 
“BOOK.DAT”, assuming the binary file is containing the records of the following type:
{"BookNo":value, "Book_name":value}
Assume that BookNo is an integer.
 
11. Assuming that a binary file VINTAGE.DAT contains records of the following type [VNO, VDesc, price].
 
Write a function in PYTHON to read the data VINTAGE.DAT and display those vintage vehicles, which are priced between 200000 and 250000.
 
12. Write a function in PYTHON to delete a laptop from a binary file
“LAPTOP.DAT” containing the records of following type.
[ModelNo, RAM, HDD, Details]
where ModelNo, RAM, HDD are integers and Details is a string. The user should enter the model number and the function should delete the details of the laptop from the file.
 
13. Write a menu-driven program to perform all the basic operations using dictionary on student binary file such as
 
i. Inserting records
ii. Reading all records & displaying
iii. Updating record based on given roll number
iv. Searching record based on given marks
v. Deleting a record based on given name
Structure of student dictionary :
{“ ROLLNO”: roll,”NAME”:name,”MARKS”:marks}
 
14. What are the advantages of CSV file formats?
 
15. Write a menu-driven program implementing user-defined functions to perform different functions on a csv file “student” such as:
 
(a) Write a single record to csv
(b) Write all the records in one single go onto the csv.
(c) Display the contents of the csv file.

 

Please click on below link to download CBSE Class 12 Computer Science File Handling Worksheet Set B

Practice Worksheets Class 12 Computer Science
CBSE Class 12 Computer Science All Chapters Worksheet
CBSE Class 12 Computer Science Arrays Worksheet
CBSE Class 12 Computer Science Binary Files Worksheet
CBSE Class 12 Computer Science Boolean Algebra Worksheet
CBSE Class 12 Computer Science C++ Worksheet Set A
CBSE Class 12 Computer Science C++ Worksheet Set B
CBSE Class 12 Computer Science Classes And Objects Worksheet
CBSE Class 12 Computer Science Communication Technology Worksheet
CBSE Class 12 Computer Science Computer Networks Worksheet Set A
CBSE Class 12 Computer Science Computer Networks Worksheet Set B
CBSE Class 12 Computer Science Computer Networks Worksheet Set C
CBSE Class 12 Computer Science Constructor And Destructor Worksheet Set A
CBSE Class 12 Computer Science Constructor And Destructor Worksheet Set A
CBSE Class 12 Computer Science Constructor And Destructor Worksheet Set B
CBSE Class 12 Computer Science Data Base Concept Worksheet
CBSE Class 12 Computer Science Data File Handling Worksheet
CBSE Class 12 Computer Science Data Management Worksheet Set A
CBSE Class 12 Computer Science Data Management Worksheet Set B
CBSE Class 12 Computer Science Data Management Worksheet Set C
CBSE Class 12 Computer Science Data Management Worksheet Set D
CBSE Class 12 Computer Science Data Management Worksheet Set E
CBSE Class 12 Computer Science File Handling Worksheet Set A
CBSE Class 12 Computer Science File Handling Worksheet Set B
CBSE Class 12 Computer Science File Handling Worksheet Set C
CBSE Class 12 Computer Science Function In Python Program Worksheet
CBSE Class 12 Computer Science Functions Worksheet Set A
CBSE Class 12 Computer Science Functions Worksheet Set B
CBSE Class 12 Computer Science Header Files Worksheet
CBSE Class 12 Computer Science Implementation of Queue Worksheet Set A
CBSE Class 12 Computer Science Implementation of Queue Worksheet Set B
CBSE Class 12 Computer Science Implementation of Stack Worksheet
CBSE Class 12 Computer Science Inheritance Worksheet Set A
CBSE Class 12 Computer Science Inheritance Worksheet Set B
CBSE Class 12 Computer Science Pointers Worksheet
CBSE Class 12 Computer Science Programming and Computational Thinking Worksheet Set A
CBSE Class 12 Computer Science Programming and Computational Thinking Worksheet Set B
CBSE Class 12 Computer Science Programming and Computational Thinking Worksheet Set C
CBSE Class 12 Computer Science Programming and Computational Thinking Worksheet Set D
CBSE Class 12 Computer Science Programming and Computational Thinking Worksheet Set E
CBSE Class 12 Computer Science Programming and Computational Thinking Worksheet Set F
CBSE Class 12 Computer Science Python Worksheet
CBSE Class 12 Computer Science Recursion Worksheet
CBSE Class 12 Computer Science Revision Worksheet
CBSE Class 12 Computer Science Society Law and Ethics Worksheet Set A
CBSE Class 12 Computer Science Society Law and Ethics Worksheet Set B
CBSE Class 12 Computer Science Society Law and Ethics Worksheet Set C
CBSE Class 12 Computer Science Society Law and Ethics Worksheet Set D
CBSE Class 12 Computer Science Society Law and Ethics Worksheet Set E
CBSE Class 12 Computer Science Sql Worksheet Set A
CBSE Class 12 Computer Science Sql Worksheet Set B
CBSE Class 12 Computer Science Using Python Libraries Worksheet
CBSE Class 12 Computer Science Worksheet Set A Solved
CBSE Class 12 Computer Science Worksheet Set B Solved
CBSE Class 12 Computer Science Worksheet Set C Solved
CBSE Class 12 Computer Science Worksheet Set D Solved
CBSE Class 12 Computer Science Worksheet Set E Solved
CBSE Class 12 Computer Science Worksheet Set F Solved

File Handling CBSE Class 12 Computer Science Worksheet

The above practice worksheet for File Handling has been designed as per the current syllabus for Class 12 Computer Science released by CBSE. Students studying in Class 12 can easily download in Pdf format and practice the questions and answers given in the above practice worksheet for Class 12 Computer Science on a daily basis. All the latest practice worksheets with solutions have been developed for Computer Science by referring to the most important and regularly asked topics that the students should learn and practice to get better scores in their examinations. Studiestoday is the best portal for Printable Worksheets for Class 12 Computer Science students to get all the latest study material free of cost. Teachers of studiestoday have referred to the NCERT book for Class 12 Computer Science to develop the Computer Science Class 12 worksheet. After solving the questions given in the practice sheet which have been developed as per the latest course books also refer to the NCERT solutions for Class 12 Computer Science designed by our teachers. After solving these you should also refer to Class 12 Computer Science MCQ Test for the same chapter. We have also provided a lot of other Worksheets for Class 12 Computer Science which you can use to further make yourself better in Computer Science.

Where can I download latest CBSE Practice worksheets for Class 12 Computer Science File Handling

You can download the CBSE Practice worksheets for Class 12 Computer Science File Handling for the latest session from StudiesToday.com

Are the Class 12 Computer Science File Handling Practice worksheets available for the latest session

Yes, the Practice worksheets issued for File Handling Class 12 Computer Science have been made available here for the latest academic session

Is there any charge for the Practice worksheets for Class 12 Computer Science File Handling

There is no charge for the Practice worksheets for Class 12 CBSE Computer Science File Handling you can download everything free

How can I improve my scores by solving questions given in Practice worksheets in File Handling Class 12 Computer Science

Regular revision of practice worksheets given on studiestoday for Class 12 subject Computer Science File Handling can help you to score better marks in exams

Are there any websites that offer free Practice test papers for Class 12 Computer Science File Handling

Yes, studiestoday.com provides all the latest Class 12 Computer Science File Handling test practice sheets with answers based on the latest books for the current academic session