Chennai Set2

You might also like

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

KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION

PRACTICE TEST 2021 - 22


CLASS XII (Theory: Term - 1)

Max. Marks: 35 Subject: Computer Science (083) Time: 90 Mins.

General Instructions:
 The question paper is divided into 3 Sections - A, B and C.
 Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
 Section B, consist of 24 Questions (26-49). Attempt any 20 questions.
 Section C, consist of 6 case study based Questions (50-55). Attempt any 5 questions.
 All questions carry equal marks.
Q.N. Section - A
This section consists of 25 questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option.
1. Find the invalid identifier from the following:
(a) Twelfth_C (b) _12C
(c) 12th_C (d) For
2. Consider a declaration t = [12101, 'Ashok', 17].
Which of the following represents the data type of t?
(a) list (b) tuple
(c) dictionary (d) string
3. Consider the following code and find the correct output from the given options:
t1=(12,30,44,52,36)
print(t1.index(3))
(a) 44 (b) 52 (c) 36 (d)12
4. Which option correctly explains tell () method?
(a) tells the current position within the file.
(b) tells the name of file.
(c) moves the current file position to a different location.
(d) it changes the file position only if allowed to do so else returns an error.
5. Which of the following command is used to open a file “d:\emp.txt” in read-mode only?
(a) f1 = open(“d:\emp.txt”, “r”)
(b) f1 = open(“d:\\emp.txt”, “r”)
(c) f1 = open(file = “d:\emp.txt”, “r+”)
(d) f1 = open(file = “d:\\emp.txt”, “r+”)
6. Which of the following commands can be used to read 12 characters from a file using the
file object <f1>?
(a) f1.read(12) (b) f1.read()
(c) f1.readline(12) (d) f1.readlines()

7. Which of the following statement is incorrect about the opening modes of a file?
(a) When you open a file for reading, if the file does not exist, an error occurs.
(b) When you open a file for reading, if the file does not exist, the program will
open an empty file.
(c) When you open a file for writing, if the file does not exist, a new file is
created.
(d) When you open a file for writing, if the file exists, the existing file is
overwritten with the new file.
8. Which operator is used for replication?
(a) + (b) % (c) * (d) //
9. Consider the tuple in python named sub=( “cs”, “phy”, “mat”).
Identify the invalid statement(s) from the given below statements:
(a) s=sub[1]
(b) print(sub[2])
(c) sub[0]= “ip”
(d) list=list(sub)
10. Find the output of the following:
>>> test="Comp Sc Periodic Test"
>>> print(test[:3:-1])
(a) seT cidoireP cS
(b) tseT cidoireP
(c) tseT cidoireP cS
(d) tseT cidoireP cs
11. Which of the following function is used to write data in binary mode?
(a)write (b)output
(c)dump (d)send

12. Choose the file pointer, used to go to particular position in a file:


(a)seek (b)tell
(c)read (d)write
13. In which file, no delimiters are used for line and no translations occur?
(a) Text file
(b) Binary file
(c) csv file
(d) None of the above
14. Choose the file mode used to write data into binary file.
(a) rb (b) wb
(c) r+ (d) w+
15. Choose the correct keyword to start a user defined function definition:
(a) def (b) define
(c) create (d) New
16. Choose the valid function header from the following:
(a) def interest(principal, rate=12, period)
(b) def interest(principal=30000, rate, period=2)
(c) def interest(principal=30000, rate=12, period=2)
(d) def interest(principal=30000, rate=12, period)
17. Choose the correct option with reference to below Python code?
def sum(x,y=20):
print(x+y)
a=50
b=100
sum(b)
(a) 150 (b) 70
(c) 120 (d) 100
18. In csv files, by default each field of record is separated by
(a) semicolon (b) comma
(c) space (d) hyphen
19. Which are built in functions for csv module
(a) csv.print() (b) csv.read()
(c) csv.writer() (d) csv.write()
20. Choose the correct statement?
(a) ‘r+’ opens a file for both reading and writing. File object points to its
beginning.
(b) ‘w+’ opens a file for both writing and reading. Adds at the end of the existing
file if it exists and creates a new one if it does not exist.
(c) ‘wb’ opens a file for reading and writing in binary format. Overwrites the file
if it exists and creates a new one if it does not exist.
(d) ‘a’ opens a file for appending. The file pointer is at the start of the file if the file
exists.
21. Which of the following statements correctly explain the function of seek() method?
(a) Tells the current position within the file.
(b) Determines if you can move the file position or not.
(c) Indicates that the next read or write occurs from that position in a file.
(d) Moves the current file position to a given specified position
22. Which statement is used to add new value 49 to an existing tuple named marks:
marks = (51,32,83,54,65)
(a) marks = marks + 66
(b) marks = 66
(c) marks=marks+(66,)
(d) marks=marks+(66)
23. Which statement is correct for dictionary?
(a) A dictionary is an ordered set of key:value pair
(b) each of the keys within a dictionary must be unique
(c) each of the values in the dictionary must be unique
(d) values in the dictionary are immutable

24. Which of the following function is used to read data from a binary file?
(a) write
(b) load
(c) dump
(d) scan
25. An absolute path name begins with:
(a) Leaf
(b) Stem
(c) current directory
(d) root
Section – B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.
26. Predict the output of the following code:
sub=["CS", "PHY", "CHEM", "MATHS", "ENG"]
del sub[2]
sub.remove("ENG")
sub.pop(1)
print(sub)
(a) ['CS', 'MATHS']
(b) ['CS', ‘ENG’]
(c) [‘CS’,’CHEM’]
(d) [‘PHY’,’CHEM’]
27. Suppose content of 'lang.txt' is:
It is interpreted.
It is highlevel.
Indentation is important.
What will be the output of the following code?
f1 = open("lang.txt")
res = f1.readline()
print(len(res))
f1.close()
(a) 18
(b) 19
(c) 16
(d) 17
28. Identify the output of the following Python statements.
d={2:{1:'one',2:'two'},3:{1:'one',2:'two',3:'three'},4:{1:'one',2:'two',3:'three',4:'four'}}
print(d[4][3])
(a) one (b) two (c) three (d) four
29. Identify the output of the following Python statements.
l=[10,'to']
for i in range(len(l)):
print(l[i]*2)
(a) 10 (c) 100
to toto
(b) 100 (d) 20
to*to toto

30. Identify the output of the following Python statements.


p=3
q=1
for i in range(1,p+1):
q=p+(q*i)
print(q)
(a) 33 (b) 36 (c) 30 (d) 39

31. Identify the output of the following Python statements.


l1 = [10,15,16,18,20]
l1.remove(15)
l1.insert(1,30)
print (l1[::-2])
(a) [10, 16, 20] (b) [10, 30, 16, 18, 20]
(c) 18 (d) [20, 16, 10]
32. Dima is trying to read a list l1 from a binary file ‘num’. Consider the following code
written by her.
import pickle
f1 = open("num",'rb')
l1=__________________#Statement 1
print(l1)
f1.close()
Identify the missing code in Statement 1.
(a) pickle.load(f1) (b) pickle.load(l1,f1)
(c) pickle.read(f1) (d) pickle.dump(l1,f1)
33. The following code displays the output:
1
3
5

s=1
for i in range(1,10):
if i%2!=0 and i<7:
print(i)
_______________ # Statement 1

Write appropriate jump statement from the following to obtain the above output.
(a) break (b) jump
(c) continue (d) return

34. What will be the output of the following Python code?


def div (n1, n2):
q=n1/n2
r=n1%n2
return q,r

res = div(20,3)
print(res)
(a) (6, 2) (b) [6,2] (c) 6.66 (d) 6
35. Evaluate the following expression and identify the correct answer.
51 + 13 / 2 – 4 + 3 ** 2 - 5
(a) -28 (b) 57 (c) 39 (d) 32
36. What will be the output of the following code?
def calc(a,b=2,c=3):
a=a+5
c += a * b
return c

res1 = calc(5)
res2 = calc(6,1)
print(res1, res2)
(a) (23,14) (b) (23,25) (c) (25,14) (d) (14,25)
37. What will be the output of the following code?
a = 15
def update(x):
global a
a += 2
if x%2==0:
a *= x
else:
a //= x
a=a+5
print(a, end="$")
update(5)
print(a)
(a) 20$11 (b) 15$4 (c) 20$4 (d) 22$4
38. Choose the impossible output from the given options on successful execution of the
following code:
import random
sub=["CS","Maths","Phy","Chem","Eng"]
for i in range(5):
y = random.randint(1,4)
print(sub[y],end="@")

(a) Phy@Chem@Eng@Phy@ (b) CS@Chem@Eng@Phy@


(c) Phy@Chem@Eng@Eng@ (d) Chem@Chem@Phy@Phy@

39. What is the output of the following code snippet?


def modify(x,y):
for i in range(y):
if x[i]%3 == 0:
x[i]//=2
if x[i]%2 == 0:
x[i]//=3
s = [6,8,5]
modify(s,3)
for i in s:
print(i,end="#")
(a) 3#5#2# (b) 3#5#2# (c) 5#2#3# (d) 3#2#5#
40. Suppose content of 'lang.txt' is:
It is interpreted.
It is Highlevel.
Indentation is important.
What will be the output of the following code?
f = open("lang.txt")
r = f.read()
l = r.split()
c=0
for i in l:
if i[0].isupper():
c += 1
print(c)
f.close()
(a) 3 (b) 9 (c) 4 (d) 6

41. Find the output of the following code:


Exam="CS Test_1 @ 10Am"
Res=""
t=len(Exam)
for i in range(t):
if Exam[i].isspace():
Res=Res+'-'
elif Exam[i].isdigit():
Res=Res+'$'
elif Exam[i].isupper():
Res=Res+Exam[i-1]
elif Exam[i].islower():
Res=Res+Exam[i].upper()
else:
Res=Res+"*"
print(Res)
(a) mC-EST*$-*-$$0M (b) MC- EST*$-*-$$0M
(c) mC- EST* -*-$$AM (d) mC- EST*$-*-$$0M
42. Suppose content of 'lang.txt' is:
It is interpreted.
It is highlevel.
Indentation is important.
What will be the output of the following code?
f1 = open("lang.txt",'r')
t = f1.read()
r = t.split()
c=0
for i in r:
if (len(i)<3):
c += 1
print(c)
f1.close()
(a) 3 (b) 4 (c) 5 (d) 9
43. Suppose content of 'lang.txt' is:
It is interpreted.
This is highlevel.
Indentation Is important.
What will be the output of the following code?
f1 = open("lang.txt",'r')
p = f1.read()
w = p.count('is')
print(w)
f1.close()
(a) 3 (b) 2 (c) 4 (d) 5
44. What will be the output of the following code?
n = 25
def test(n):
n+=5
print(n, end=' ')
n-=5
print(n,end=' ')
test(10)
print(n, end=' ')

(a) 25 20 25 (b) 15 10 25 (c) 25 20 10 (d) 15 10 10


45. Suppose content of 'msg.txt' is
Satyameva Jayathe

What will be the output of the following code?


f1 = open("msg.txt",'r')
t = list("yethi")
c=0
n = f1.read()
for i in n:
if(i in t):
c+=1
print(c)
f1.close()
(a) 6 (b) 5 (c) 7 (d) 4
46. Suppose content of 'legend.txt' is:
Diego Maradona.
Argentinian soccer legend.
celebrated Hand of God scorer.
dies at 60.
What will be the output of the following code?
f1 = open("legend.txt")
c=0
d = f1.readlines()
for i in d:
if i[0].isupper():
c += 1
print(c)
f1.close()
(a) 1 (b) 3 (c) 4 (d) 2
47. Consider the following directory structure.
What will be the absolute path of infrastructure?

(a) Final\Infrastructure
(b) D:\Data\Final\Infrastructure
(c) ..\Final\Infrastructure
(d)..\Shapefiles\Final\Infrastructure
48. Assume the content of text file, 'legend.txt' is:
Diego Maradona.
Argentinian soccer legend.
celebrated Hand of God scorer.
dies at 60.
What will be the data type of res?
f1 = open("legend.txt")
res = f1.readline()
f1.close()
(a) tuple (b) string (c) list (d) dictionary
49. What will be the output of the following code?
msg2=""
msg1="All the very best"
msg2=msg1
msg2 +=" for the exam"
print(msg1)
(a) All the very best for the exam (b) for the exam
(c) All the very best (d) Error Message
Section - C
Case Study based Questions
This section consists of 6 Questions (50 - 55) Attempt any 5 questions.
Pinki of Class 12 is writing a program to add 10 more records to an existing CSV file
“payroll.csv” which will contain employee id, employee name, designation and salary
fields. She has written the following code. As a programmer, help her to successfully
execute the given task.
Incomplete Code
__________________ #Statement-1
f1 = open(_____, _____, newline='') #Statement-2
empw = csv._____ #Statement-3
details = [ ]
for i in range(10):
empid = int(input("Enter Employee Id : "))
empname = input("Enter Employee Name : ")
designation = input("Enter Designation : ")
salary = int(input("Enter Salary : ") )
record = [ _____ ] #Statement-4
details.___________ (record) #Statement-5
empw. dump ( ___________ ) #Statement-6
f1.close()
50. Identify the suitable code for blank space in the line marked as Statement-1.
(a) load CSV (b) read csv
(c) import csv (d) import CSV
51. Identify the missing code for blank space in line marked as Statement-2.
(a) "payroll.csv","wb"
(b) "payroll.csv","a"
(c) "payroll.csv","w"
(d) "payroll.cvs","a"
52. Choose the function name (with argument) that should be used in the blank space of line
marked as Statement-3.
(a) writer(f1) (b) reader(f1)
(c) read(f1) (d) write(f1)
53. Identify the suitable code for blank space in line marked as Statement-4.
(a) “empid”,”empname”,”designation”,”salary”
(b) empid,empname,designation,salary
(c) EMPID,NAME,DESIGNATION,SALARY
(d) empid,name,designation,salary
54. Identify the suitable code for blank space in the line marked as Statement-5.
(a) load (b) write
(c) append (d) dump
55. 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) record (b) details
(c) empw (d) csv

You might also like