Xii Computer Science
Xii Computer Science
Xii Computer Science
General Instructions:
This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
Which of the following statements should be given in the blank for #Missing
statement, if the output produced is 110?
Page 1 of 8
7. Select the correct output of the following code: 1
S="Amrit Mahotsav @ 75"
A=S.partition(" ")
9. What is the default return value for a function that does not return any value 1
explicitly?
a. None b. int c. double d. null
11. Which of the following is not a component of the math module in Python? 1
a. ceil() b. mean() c. fabs() d. pi
12. How do you get the current position within the file? 1
a. fp.seek() b. fp.tell() c. fp.loc() d. fp.pos()
13. State True of False 1
“ While handling exceptions in Python, name of the exception has to be
compulsorily added with except clause”
14. Which of the following mode in file opening statement results or generates an 1
error if the file does not exist?
a. a+ b. r+ c. w+ d. None of these
15. Fill in the blank: 1
If you want to transfer data from buffer to file forcefully then ________ function
is used.
a. close() b. submit() c. write() d. flush()
16. Consider the following Python statement: 1
F=open(‘CONTENT.TXT’)
Which of the following is an invalid statement in python
a. F.seek(1,0) b. F.seek(0,1) c. F.seek(0,-1) d. F.seek(0,2)
17 What will be the output of the following code snippet? 1
str= "World Peace"
print(str[-2::-2])
a. ce ld b. ce lo c. lo ce d. ce or
18 Which of the following statements will cause an error? 1
a. t=1, b. t=(1,) c. t=(1) d. t=tuple(1)
19 Identify the output of the following code snippet: 1
text = "PYTHONPROGRAM"
Page 2 of 8
text=text.replace('PY','#')
print(text)
a. #THONPROGRAM c. #THON#ROGRAM
b. ##THON#ROGRAM d. #YTHON#ROGRAM
Q 20 and 21 are ASSERTION and REASONING based questions. Mark the correct choice as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
20. Assertion(A):- To use a function from a particular module, we need to import 1
the module.
OR
Page 3 of 8
Predict the output of the following program:
v=50
def Change(n):
global v
v,n=n,v
print(v,n,sep="#",end="@")
Change(20)
print(v)
[Learning outcome: Student will be able to understand global and local variables]
24. Predict the output of the following code: 2
LS=["HIMALAYA","NILGIRI","ALASKA","ALPS"]
D={}
for S in LS:
if len(S)%4==0:
D[S]=len(S)
for K in D:
print(K,D[K],sep="#")
[Learning outcome: Student will be able to understand operations on string]
25. Find and write the output of the following python code: 2
Data=["P",20,"R",10,"S",30]
Times=0
Alpha=""
Add=0
for C in range(1,6,2):
Times=Times+C
Alpha=Alpha+Data[C-1]+"$"
Add=Add+Data[C]
print(Times, Add, Alpha)
[Learning outcome: Student will be able to use concept of List and Loops ]
30. What is difference between local scope and global scope of variable? Explain 3
with suitable example.
OR
What is default argument explain with suitable example.
[Learning outcome: Student will be able to use concepts of function ]
31. Write a function INDEX_LIST(L), where L is the list of elements passed as 3
argument to the function. The function returns another list named ‘indexList’ that
stores the indices of all Non-Zero Elements of L.
For example: If L contains [12,4,0,11,0,56]
The indexList will have - [0,1,3,5]
[Learning outcome: Student will be able to apply logic on List ]
SECTION – D (4 x 4 = 16 Marks)
32. a. What is the default file-open mode in file handling? (1) 4
Page 5 of 8
b. Write a Python function named showg5 that finds and displays all the words
longer than 5 characters from a text file "Words.txt". (3)
OR
a. Which module is used to read and write in the binary file? (1)
b. Write a Python function named showmemy to count the words “Me” and
“My” present in a text file ”story.txt”. (3)
import random
NAV=["LEFT", "FRONT","RIGHT","BACK"]
NUM=random.randint(1,3)
NAVG=""
for C in range(NUM,1,-1):
NAVG=NAVG+NAV[C]
print(NAVG)
Page 7 of 8
print (row[0],row[1])
newFile.______________ # Line 4
addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)
readCsvFile() #Line 5
Page 8 of 8