You are on page 1of 4

Kendriya Vidyalaya No 1 AFS Jamnagar

Third Monthly Test 2021-22


Computer Science (083) (Theory)
Class: XII
SET A
Maximum Marks: 40 Time Allowed: 1.5 hours
All questions carry equal marks.

1. The readlines() method returns ____________?


a. Characters b. Lines
c. List of lines d. List of characters
2. Which of the following command is used to open a file “c:\temp.txt” for reading in binary
format only?
a. r b. w c. rb d. wb
3. Correct syntax of file.readlines() is
a. fileObject.readlines( sizehint ) b. fileObject.readlines()
c. fileObject.readlines(sequence) d. none of the mentioned
4. Which function is used to write all the characters?
a. writecharacters() b. writeall()
c. write() d. writeline()
5. read() will return________________
a. List b. Line
c. String d. character
6. Which of the following file mode will refer to the BINARY mode? 
a. bin b. b c. binary d. w
7. Which of the following file mode is not a valid file mode ?
a. rw b. rb c. ra d. ab
8. To open a file in python language ................. function is used?
a. open() b. read()
c. create d. file()
9. To read 20 characters from file object FILE at once we may use?
a. FILE.read(20) b. FILE.readlines(20)
c. FILE.read(char=20) d. FILE.readline(char=20)
10. Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which
of the following option can be used to read all the remaining lines.
a. myfile.read() b. myfile.read(3)
c. myfile.readline() d. myfile.readlines()
11. What is the significance of the seek() method?.
a. the path of file b. the end position within the file
c. the current position of the file d. place the pointer at the desired
pointer within the file location
12. Binary files represent the actual content:
a. Video b. Audio
c. Image d. All of these
13. Which of the following is not a function / method of csv module in Python
a. reader() b. readrows()
c. writer() d. writerows()
14. Raman, a student of class 12, is learning CSV File Module in Python. During examination,
he has been assigned an incomplete python code (shown below) to create a CSV File
'Student.csv' (content shown below). Help him in completing the code which creates the
desired CSV File.
CSV File
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A
Incomplete Code
import _____ #Statement-1
fh = open(____________________) #Statement-2
stuwriter =__________________ #Statement-3
data = [ ]
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [ _____ ] #Statement-4
data.append(_____) #Statement-5
stuwriter. _____ #Statement-6
#Statement-7
15. Identify the suitable code for blank space in the line marked as Statement-1.
a. csv b. pickle
c. CSV d. csv_file
16. Identify the missing code for blank space in line marked as Statement-2:
a. "Student.csv","wb" b. "Student.csv","w"
c. "Student.csv","w",newline=’ ‘ d. "Student.csv","wb",newine=’’
17. Choose the function name (with argument) that should be used in the blank space of line
marked as Statement-3.
a. csv.writer() b. writer(fh)
c. csv.writer(fh) d. writer()
18. Identify the suitable code for blank space in line marked as Statement-4?
a. ['ROLL_NO', 'NAME', 'CLASS', b. ['roll_no', 'name', 'class', 'section']
'SECTION']
c. [ROLL_NO, NAME, CLASS, d. [roll_no,name,Class,section]
SECTION]
19. Identify the suitable code for blank space in line marked as Statement-5?
a. rec b. header c. data d. fh
20. Choose the function name that should be used in the blank space of line marked as
Statement-6 to create the desired CSV File?
a. writerow() b. writerows() c. dump() d. write()
21. identify the suitable code for blank space in line marked as statement-7
a. close() b. myfile.close()
c. fh,close() d. mydata.close()
22. Assertion (A):Text file stores information in ASCII or Unicode characters. Reason (R):In
text file , we can easily read file in computer. In the light of the above two statements,
choose the correct option: 
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
23. Assertion (A): In binary file , there is no delimiter for a line. Reason (R):In text file , there
is delimiter for a line. In the light of the above two statements, choose the correct option:  
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
24. What value will be shown if we try to open a binary file using a text?
a. Default value b. Garbage value
c. Advance value d. Parameter value
25. Pickle module implements binary protocol for___________________ a Python object
structure
a. serializing b. serializing and deserializing
c. deserializing d. None of these
26. ..................... method of pickle module is used to read data from a binary file.
a. write() b. read() c. dump() d. load()
27. Which statement is used to retrieve the current position within the file?
e. fp.seek( ) f. fp.pos()
g. fp.tell() h. fp.loc()
28. Consider the following directory structure.

Suppose root directory (School) and present working directory are the same. What will be the
absolute path of the file Syllabus.jpg?
a. School/syllabus.jpg b. School/Academics/syllabus.jpg
c. School/Academics/../syllabus.jpg d. School/Examination/syllabus.jpg
29. What will be the data type of data_rec?
myfile = open("Myfile.txt",”w”)
myfile.writelines(data_rec)
myfile.close().
a. String b. Tuple
c. list d. dictionary
30. Myfile.txt contains : India is my country and all Indians are my brothers and sisters.
What will be the output of the following code?
myfile = open("Myfile.txt")
vlist = list("aeiouAEIOU")
vc=0
x = myfile.read()
for y in x:
if (y in vlist):
vc+=1
print(vc)
myfile.close()
a. 20 b. 19 c. 18 d. 21
31. Myfile.txt contains: India is my country and all Indians are my brothers and sisters.
What will be the output of the following code?
myfile = open("Myfile.txt")
x=myfile.read()
print(myfile.tell())
myfile.close() 
e. 64 f. 65 g. 66 h. 67
32. To force python to write the contents of file buffer on to storage file,........method may be
used.
a. Buffer() b. Close()
c. Flush() d. Open()
33. What is the difference between r+ and w+ modes? 
a. In r+ mode, file length truncates to zero
b. In w+ mode, file length truncates to zero either file exists or not.
c. No difference
d. Depends on the operating system

34. What are the binary files used for? 


a. To store data b. It is used to store data in the form of bytes
c. To look folder good d. All of the above
35. To read the next line of the file from a file object f1, we use:
a. F1.read() b. F1.readlines()
c. F1.readline() d. All of the above
36. To read 2 bytes from a file object infile, we use
a. infile.read() b. infile.readlines()
c. infile.read(2) d. infile.readlines(2)
37. Which determines the mode in which file has to be opened?
a. Access mode b. File name
c. write() d. read()
38. Observe the following code and answer the questions that follow:
File = open("Mydata","a")
___________________ #Blank1
File.close()
What type of file is Mydata?
a. Binary b. Text
c. csv d. all of the above
39. Fill in Blank 1 with a statement to write “ABC” in the file “Mydata” in above code.
a. Mydata.write(“ABC”) b. File.write(“ABC”)
c. Mydata.writelines(“ABC”) d. File.writelines(“ABC”)
40. Syntax of seek function in Python is myfile.seek(offset, reference_point) where myfile is the
file object. What is the default value of reference_point when file pointer to move at end of
file? 
a. 0 b. 1 c. 2 d. 3

You might also like