KVS Chandigarh Region Paper

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

KENDRIYA VIDYALAYA SANGATHAN, CHANDIGARH REGION

Practice Examination for Class: XII Session: 2021-22


Subject: Computer Science (083)
(Theory: Term-1)
Maximum Marks: 35 Time Allowed: 90 Minutes
General Instructions:
The question paper is divided into 3 Sections A, B and C
Section A consists of 25 Questions (1-25). Attempt any 20 questions.
Section B consists of 24 Questions (26-49). Attempt any 20 questions.
Section C Consist of 06 case study based Questions. Attempt any 05 questions.
All questions carry equal marks.

Q. Section - A
No
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this section. Choose the best
possible option.

1 Which operator has the highest Priority / Precedence


a) ** b) > c) not d) %
2 Given String S= 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:-
n
print(num*2)
a) 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.
Page 1 of 9
10
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):
(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:

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
23 Name the function to read from CSV file.
a) read() b) csv.reader() c)csv_read() d) read_csv()
24 Write full form of CSV
a) Comma separated values b) Comma settled values
c) Common separated values d) None of the above
25 -
a) new data will be added at the end of file
b) new data will be added at the beginning of file
c) Old data will be lost and new data will be stored.
d) An Error will occur.

Section B

This section consists of 24 Questions (26 to 49). Attempt any 20 questions from this section. Choose the
best possible option.
26 What will be the output of following Python Code:
if 5>2 or 8<5 and 0 :

else:

a) Error b) Hello c) Welcome d) HelloWelcome


27 What will be the output of following Python Code:
X,Y=10,20
Y,Y,Y=Y+2, X+5, Y-2
print(Y)
a) 20 b) 15 c) 18 d) 22
28 What will be the output of following Python Code:
P,S=1,0
for X in range(-5,15,5):
P*=X
S+=X
else:

a) 10#5 b) 10#0 c) 0#10 d) 5#10


29 Identify the output of the following Python statements.
L1=[6,4,2,9,7]

(a) [6,4,2,9,7,100] (b) [6,4,2,100] (c) [6,4,2,1,0,0] (d) [6,4,


30 What will be the output of following Python Code:
import random as rd
high=4
Guess=rd.randrange(high)+50
for C in range(Guess, 56):
print(C,end="#")

a) 50 # 51 # 52 # 53 # 54 # 55 # b) 54 # 53 # 54 # 55#
c) 53 # 54 # 55 # 56 # d) 51 # 52 # 53 # 54 # 55

Page 3 of 9
31 What will be the output of following Python Code:
data=[10,"ram",20,"sham",30,"anil"]
data.append("Sunil")
data[2]="Raj"
data.pop()
del data[1]
data[-1]="Magic"
print(data)
a) [10, 'Ram', 'sham', 30, 'Sunil'] b) [10, 'Raj', 'sham', 30, 'Magic']
c) [10, 'Magic', 'sham', 30, 'Sunil'] d) [10, 'Ram', 'sham', 30, 'Magic']
32 What will be the output of following Python Code:
def evenodd(num):
for i in range(len(num)):
if num[i]%2==0:
num[i]/=2
else:
num[i]*=2
return num
#main-coding
numbers=[10,15,20,25]
print(evenodd(numbers)) #function call
a) [5, 30, 10, 25] b) [5.0, 30, 10.0, 50]
c) [20.0, 7.5, 40.0, 12.5] d) [20, 15, 40, 12.5]
33 What will be the output of following Python Code:
def convert(name):
N=' '
for k in name:
if k.isupper():
N=N+k.lower()
elif k.islower():
N=N+k.upper()
else:
N=N+k
print(N)
#main-coding
convert('Term-1#EXAM')
a) tERM-1#exam b) Term-1#EXAM
c) exam-1# tERM d) #EXAM Term-1
34 What will be the output of following Python Code:
G=10
def fun1():
global G
G=20
print(G, end="*")
G=G+10
fun1( ) #call to fun1
print(G)
a) 10*20 b) 20*30 c) 20*20 d) 10*10

Page 4 of 9
35 Suppose the content of "Myfile.txt" is :-

Humpty Dumpty sat on a wall


Humpty Dumpty had a great fall
All the king's horses and all the king's men
Couldn't put Humpty together again

What will be the output of the following code?


myfile = open("Myfile.txt")
record = myfile.readlines()
print(len(record))
myfile.close()

a) 4 b) 5 c) 6 d) 3

36 -
Always Think Positive,
Never THINK Negative
What will be the output of the following Python code?
file1=open("story.txt","r")
data=file1.read( )
word=1
k=data.split()
for i in k:
if i.upper()=="THINK":
word=word+1
print(word)
file1.close()
a) 0 b) 1 c) 2 d) 3

37 -
Twinkle twinkle little star
How I wonder what you are
Up above the world so high
Like a diamond in the sky
Twinkle twinkle little star

What will be the output of the following code?


myfile = open("Essay.txt")
line_count = 0
data = myfile.readlines()
for line in data:
if line[-2] in 'Rr':
line_count += 1
print(line_count)
myfile.close()
a) 2 b) 3 c) 4 d) 5

Page 5 of 9
38 What will be the output of following Python Code:
A,B=20,10
if A<B:

break

else:

a) Smaller Number b) Smaller c) Greater d) Syntax Error


39 Suppose the content of -
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" )
content = File1.read()
data=content.split()
for word in data:

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")

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

Page 6 of 9
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)
c) write(obj1,myfile) d) load(myfile,obj1)
44 The content of binary file STUDENT.DAT is :

{'rno': 1, 'name': 'raja', 'marks': 95.5}


{'rno': 2, 'name': 'ram singh', 'marks': 78.0}
{'rno': 3, 'name': 'sonia', 'marks': 68.0}
{'rno': 4, 'name': 'rajesh', 'marks': 85.5}
{'rno': 5, 'name': 'raj singh', 'marks': 48.0}

What will be the output of following Python Code:


import pickle as pk
counter=0
file1=open("student.dat","rb")
try:
while True:
rec=pk.load(file1)
if rec['marks']<80:
counter+=1
except EOFError:
print(counter)
file1.close()
a) 4 b) 3 c)2 d) 6
45 The following program copies all record from binary file games.dat to athelete.dat. Complete the
missing statement
import pickle as pk
file1=open("games.dat","rb")
file2=open("athelete.dat","wb")
try:
while True:
_________________ # statement-1 : to read record
_________________ # statement-2 : to write record
except EOFError:
print("file copied ")
file1.close()
file2.close()

a) statement-1: rec=pk.load(file2), statement-2: pk.dump(rec,file1)


b) statement-1: rec=pk.load(file1), statement-2: pk.dump(rec,file2)
c) statement-2: rec=pk.load(file1), statement-1: pk.dump(rec,file2)
d) statement-2: rec=pk.load(file2), statement-1: pk.dump(rec,file1)

Page 7 of 9
46 -
Always Think Positive

What will be the output of the following Python code?


file1=open("story.txt",'r')
print(file1.tell(),end="#")
file1.seek(7,0)
data=file1.read(5)
print(data)
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):-

def display[num]: #Line-1


if num=<0 : #Line-2
print("negative or zero") #Line-3
elseif num>=0: #Line-4
print("positive or zero') #Line-5
else: #Line-6
print('zero') #Line-7
#main-coding #Line-8
call display(2021) #Line-9
a) Line numbers 1,3,4,6 and 9 b) Line numbers 1,2,4,6 and 9
c) Line numbers 2,3,4,5 and 9 d) Line numbers 1,2,4,5 and 9

Page 8 of 9
Section - C

This section consists of 6 Questions (50 to 55) on case study base. Attempt any 5 questions from
this section. Choose the best possible option.

contain employee-code, employee-name and Salary for some entries. She has written the following
code. As a programmer, help her to successfully execute the given tas k
import _____________ #line-1
#Function to add / write single Employee records
def addemployee(record):

csvobj=csv.__________(file1) #line-2
csvobj._____________(record) #line-3
file1.close()
#Function to read employee records
def reademployee():
) #line-4
csvobj=csv._______(file1) #line-5
for rec in csvobj:
if int(rec[2])>15000:
print(rec)
file1.close()
#main-coding
rec1=[101,'ram',10000]
rec2=[102,'sham',20000]
rec3=[103,'sita',15000]
addemployee(rec1)
addemployee(rec2)
addemployee(rec3)
reademployee() #line-6

50 Name the module he should import in Line 1.


a) import csv b) import CSV c) import csv module d) import Csv

51 Fill in the blank in Line 2 to create CSV object for writing.


a) writer b) writerow c) writerows d) write

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

54 Fill in the blank in Line 5 to read data from CSV file.


a) reader b) read c) readlines d) readline

55 Write the output Sakshi will obtain while executing line 6


a) (102,'sham',20000)
b) [102,'sham',20000]
c) [103,'sita',15000]
d) (103,'sita',15000)

********** End of Question Paper **********

Page 9 of 9

You might also like