XII-CS Holiday Homework - Autumn Break
XII-CS Holiday Homework - Autumn Break
Q. Section - A
No
This section consists of 25 Questions (1 to 25).
1 Which operator has the highest Priority / Precedence
a) ** b) > c) not d) %
2 Given String S=“EXAM2021” what will be the output of print( S[: : -2] )
a)10MX b) EA22 c) XM01 d) 22AE
3 Given a tuple Tup1=(25,35,43,22,13,56,45,78,90), Identify the statement from the
options below that will produce the result as (25,43,13,45)
a. print(Tup1[-9:-2:2]) b. print(Tup1[0:7:1])
c. print(Tup1[::2]) d. print(Tup1[-8:-2:2])
4 Which of the following is true for a Python dictionaries ?
a) All the keys in dictionary must be of same data type.
b) A dictionary can contain any object type except another dictionary.
c) Dictionary Values are accessed by the keys.
d) Dictionaries are immutable type of data.
5 Which of the following options can be used to print second last line of a text file "Myfile.txt"?
a. myfile = open('Myfile.txt'); print(myfile.readlines( )[-1])
b. myfile = open('Myfile.txt','r'); print(myfile.readlines( )[-2])
c. myfile = open('Myfile.txt'); print(myfile.readline(last_line-1))
d. myfile = open('Myfile.txt'); print(myfile.readlines( )[n-2])
6 What will be the output of following print statements:-
num= „20‟
print(num*2)
a) 40 b) „40‟ c) 2020 d) Error
7 If a mixed expression contains Relational, Arithmetic and logical operator, then in which order they
will be executed?
a) Arithmetic, Logical, Relational b) Relational , Arithmetic Logical
c) Arithmetic, Relational , Logical d) Relational, Logical, Arithmetic
8 Pick out odd one option:
a) break b) continue c) pass d) while
9 Which is valid statement:-
a) List, Tuple & Dictionary are mutable, immutable & mutable data types.
b) List, Tuple & Dictionary are immutable, mutable & mutable data types.
c) List, Tuple & Dictionary are mutable, mutable & immutable data types.
d) All statements are valid.
10 Consider a tuple T1=(2,3,{1:„One‟,2:„Two‟,3:„Three‟}). Identify the statement that will result
in an error.
a. print(2 in T1) b. print(T1[0]) c. print(T1[3]) d. print(len(T1))
11 A function can have number of return statement(s).
a) Only One b) Zero
c) Any (but all must execute) d) Any (but execute only one of them)
12 Which function header statement is correct:-
(a) def interest (prin, time=2, rate):
Page 1 of 9
(b) def interest (prin=2000, time=2, rate):
(c) def interest (prin=2000; time=2; rate)
(d) def interest (prin, time=2, rate=0.10):
13 Identify which module is used to read/write data from/in the text file?
a. csv b. CSV c. No special module required. d. Pickle
14 Which types of files stores information in the form of a stream of ASCII or Unicode Characters
a) Binary Files
b) Both Text Files and CSV Files
c) Only Text files
d) Only CSV Files
15 Consider following Python Code to read text file:
F=open(“Story.txt”)
Data=F.read(10).
Which of the following statement is True regarding variable Data
a) Data contains list of 10 lines
b) Data contain list of 10 characters
c) Data contains string of 10 characters
d) Data contains integer value 10
16 Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the
following options can be used to read all the remaining lines?
a) myfile.read(n-3) b). myfile.read(n)
c) myfile.readline() d) myfile.readlines()
17 Which of the following statements is not correct?
a) If we try to read a text file that does not exist, an error occurs.
b) If we try to read a text file that does not exist, the file gets created.
c) If we try to write on a text file that does not exist, no error occurs.
d) If we try to write on a text file that does not exist, the file gets created.
18 To read data from binary file function is used ?
a) pickles.load(file_object) b) file_object.load(object)
c) object=load(file_object) d) object=pickle.load(file_object)
19 file.seek(56,0), What relative stream position 0 represent in given seek function?
a) Relative to beginning of file b) Relative to end of file
c) Relative to current position of file d) None of the above
20 The process of converting the structure to a byte stream before writing to the file is known as _
Pickling b) Unpickling c) Dump d) Load
21 The paths are from the topmost level of the directory structure.
a) Direct b) Relative c) Absolute d) Parent
22 Name the error which raised by pickle.load( ) function when it reaches end of file while reading
binary file?
a) fileError b) ErrorEndofFile c) EOFError d) FileEndError
Page 2 of 9
c) Old data will be lost and new data will be stored.
d) An Error will occur.
Section – B
a) 50 # 51 # 52 # 53 # 54 # 55 # b) 54 # 53 # 54 # 55#
c) 53 # 54 # 55 # 56 # d) 51 # 52 # 53 # 54 # 55
a) 4 b) 5 c) 6 d) 3
Page 5 of 9
39 Suppose the content of “Story.txt" is :-
God is one
GOD is everywhere
God bless you
What will be the content of the file “Kahani.txt” after execution of following Python Code?
File1 = open("Story.txt")
File2 = open("Kahani.txt", „w‟)
content = File1.read()
data=content.split()
for word in data:
if „o‟ in word :
File2.write(word+“ ”)
File1.close()
File2.close()
a) God One GOD God b) God One God you
c) God One GOD God you d) God GOD God
40 Raj has written following program to copy story.txt file data into file kahani.txt. Help Raj to
complete the program by choosing correct option to fill in blank.
# Program to copy Story.txt file into new file Kahni.txt
file1=open("story.txt","r")
file2=open("kahani.txt","w")
data=file1.read()
# to write data in kahani.txt
file1.close()
file2.close()
print("File copied")
a) file1.writedata() b) file2.writedata( ) c) file1.write(data) d) file2.write(data)
41 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?
a) 0 b)1 c) 2 d) 3
42 The content of text file INSTITUTE.TXT is :
KVS is a great organization
What will be the content of INSTITUTE.TXT after execution of following Python code:
file1=open("INSTITUTE.TXT","w")
file.write(“of India”)
file1.close()
a) KVS is a great organization of India b)KVS is a great organization of World
c) KVS is a great organization d)of India
43 Raj is trying to write an object obj1 = (1,2,3,4,5) on a binary file "test.dat". Consider the following
code written by him.
import pickle
obj1 = (1,2,3,4,5)
myfile = open("test.dat",'wb')
pickle. #Statement 1
myfile.close( )
Identify the missing code in Statement 1.
a) dump(myfile,obj1) b) dump(obj1, myfile)
Page 6 of 9
c) write(obj1,myfile) d) load(myfile,obj1)
44 The content of binary file STUDENT.DAT is :
Page 7 of 9
file1.close()
a) 0#Think b) 1#Think c) 0#Alway d) 1#Alway
47 What will be the output of following Python Code:
def chkdigit(a,b):
da=a%10
db=b%10
if da<db:
return a
elif da>db:
return b
else:
return da,db
#main-coding
print(chkdigit(603,297))
a) 297 b) 603 c) (3,7) d) [3,7]
48 What will be the output of following Python Code:
def change(num):
for x in range(0,len(num),2):
num[x], num[x+1]=num[x+1], num[x]
#main-coding
data=[10,20,30,40,50,60]
change(data)
print(data)
a) [10, 20, 30, 40, 50, 60] b) [60, 50, 40, 30, 20, 10]
c) [20, 10, 40, 30, 60, 50] d) [40, 50, 60, 10, 20, 30]
49 Consider following Python Code and tell which line(s) have error(s):-
Section - C
52 Fill in the blank in Line 3 to write record / data of one student in CSV file.
a) writer b) writerow c) writerows d) writeline
53 Fill in the blank in Line 4 with file open mode for reading data from CSV file
a) “r” b) “a” c) “w” d) “rb”
Page 9 of 9