1. MAYO INTERNATIONAL SCHOOL
PRE-BOARD-II (2021-22)
CLASS: XII
SUBJECT: COMPUTER SCIENCE (083)
TIME: 90 MINS. MAX MARKS: 35
GENERAL INSTRUCTIONS:
1. The paper is divided into 3 Sections- A, B and C.
2. Section A consists of Question 1 to 25 and students need to attempt 20
questions.
3. Section B, consists of Question number 26 to 49 and students need to
attempt 20 questions.
4. Section C, consists of Question number 50 to 55 and students need to
attempt 5 questions.
5. All questions carry equal marks (0.77 mark per question)..
SECTION A.
SECTION A CONSISTS OF 25 QUESTIONS,
ATTEMPT ANY 20 QUESTIONS
1. What Does strip() function do?
(A) Removes the trailing or leading spaces, if any.
(B) Deletes the file
(C) Remove the file object
(D) Removes all the spaces between words
2. Write the output of the following.
a=(23,34,65,20,5)
print(a[0]+a.index(5))
(A) 28 (B) 29
(C) 27 (D) 26
3. Which of the following will NOT raise an error if the given key is
not found in the dictionary?
(A) del statement (B) pop()
(C) get () (D) All of these
4. Delimiter in csv file may be changed.
(A) True (B) False
(C) Both True and False (D) None
5. In the following question a statement of Assertion (A) is followed by
a statement of Reason (R). Mark the correct choice as:
Assertion (A): Required arguments are the arguments passed to a
function in correct positional order
Reason (R): The number of arguments in the function call should
match exactly with the function definition.
(A) Both Assertion (A) and reason (R) are true and reason (R) is the
correct explanation of Assertion (A).
(B) Assertion (A) and reason (R) are true and reason (R) is not the
correct explanation of Assertion (A).
(C) Assertion (A) is true but reason (R) is false.
(D) Assertion(A) is false but reason (R) is true.
6. Which statement does not show any error after execution?
Given L=[1,2,3,4]
(A) print(L+L) (B) print(L*L)
(C) print(L-L) (D) All of the mentioned
7. Observe the following code carefully and find which statement will
never get executed in the code:
counter=1 #statement1
while counter<=15: #statement2
if counter<15: #statement3
print(“Jump”) #statement4
else: #statement5
print(“Stop”) #statement6
counter+=4 #statement7
(A) Statement 3 (B) Statement 7
(C) Statement 2 (D) Statement 6
8. Evaluate the expression given below if A = 16 and B = 15.
A%B//6*2-5**2
(A) -25 (B) 25
(C) -25.0 (D) 25.0
9. What is the return type of function id?
(A) int (B) float
(C) bool (D) dict
Page 1 of 7
NAME: ______________________ CLASS & SEC.:
_____
SET
2. 10. Which of the following statements is False?
Statement 1: The del keyword removes the specified index from the
given list.
Statement 2: uniform () is a method of statistics module.
Statement 3: In case you have a local variable with the same name
in a function, use the global keyword to access and modify global
variable
Statement 4: The list of identifiers used in a function call is called
formal parameter(s).
(A) Statement 1, Statement 2, Statement 4
(B) Statement 1 and Statement 3
(C) Only Statement 2 and Statement 3
(D) Statement 2, Statement 3, Statement 4
11. Which line of code produces an error?
(A) "one" + 'two' (B) 1+ 2
(C) "one"+ "2" (D) '1'+2
12. Aditi wrote a code to open file as
myfile=open(“contact.dat”,”rb”)
Now she wants to read a list named as FriendList from the file.
Which command she must use to read data from the file:
(A) pickle.dump(myfile,FriendList)
(B) pickle.load(“FriendList,”myfile)
(C) Friendlist=pickle.load(myfile)
(D) myfile=pickle.load(FriendList)
13. Identify the error in the following code:
import pickle
mix_data=[‘hundred’,2, [3,4,5]]
with open (‘mixeddata.dat’, ‘rb’) as fout:
pickle.dump(mix_data , fout)
(A) Not any error is there
(B) with open (‘mixeddata.dat’, ‘w’)
(C) with open (‘mixeddata.dat’, ‘wb’)
(D) None of these
14. Which instances or objects return by the writer function?
(A) writerows (B) writerow
(C) writer (D) None of above
15. Which statement(s) are true about the pickle module in data file
handling?
(A) It is used for serialization and deserialization of any python
object structure
(B) It provides two methods dump( ) and load( )
(C) It provides two methods seek( ) and tell( )
(D) Both (A) and (B)
16. Identify correct output for the following code.
def fun4(a,b=100):
total=a+b
return total
print(total)
print(fun4(fun4(50,20)))
(A) 100 (B) 170
(C) 20 (D) 70
17. Which of the following is not a function of csv module?
(A) readline() (B) writerow()
(C) reader() (D) writer()
18. Write the output of the following:
a=(1, 2, 3, 2, 3, 4, 5)
print(min(a) + max(a) + a.count(2))
(A) 13 (B) 6
(C) 8 (D) Error
19. Consider the following code and choose the correct answer.
def nameage(name="kishan", age=20):
return age,name
t=nameage(age=20,name="kishan")
print(t[1][-2::-2])
(A) kishan (B) ask
(C) (ask, 20) (D) (20,ask)
20. Which of the following function will return the first three characters
of a string s?
(A) S[3:] (B) S[:3]
(C) S[-3:] (D) S{:-3]
Page 2 of 7
3. 21. Which of the following represents mode of both writing and reading
binary format in file?
(A) wb+ (B) wb
(C) w (D) w+
22. Which of the following statement will return an error? T1 is a tuple.
(A) T1 + (23)
(B) T1 + [3]
(C) Both of the above
(D) None of the above
23. A loop becomes infinite loop if a condition never becomes ______.
(A) TRUE (B) FALSE
(C) Null (D) Both A and C
24. If you are opening a binary file in read mode, then file must exist
otherwise what happens?
(A) Compile time error occur (B) Run-time error raises
(C) Not any error raises (D) None of these
25. In which mode if the file does not exist, then the file is created?
(A) read write mode (B) write mode
(C) read mode (D) All of these
SECTION B .
SECTION B CONSISTS OF 24 QUESTIONS,
ATTEMPT ANY 20 QUESTIONS.
26. Identify the Output for the below code:
z=5
def A_func (x=10, y=20):
z=30
x =x+z
y=y-z
return(x+y)
print(A_func(5),A_func(),z)20 25
(A) 25 30 5 (B) 10 20 5
(C) 15 25 5 (D) Error in Return statement
27. 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) 46 (B) 45
(C) 41 (D) 42
28. Which of the following expressions results in an error?
(A) float('12') (B) int('12')
(C) float('12.5') (D) int('12.5')
29. When the function ABLINES() is executed, it read contents from a
text file LINES.TXT, to display those lines, which are either starting
with an alphabet ‘A’ or starting with alphabet ‘B’.
def ABLINES():
file=open(‘LINES.TXT’,’r’)
lines = file.readlines()
for w in lines:
if _______________: #statement 1
print (w)
file.close()
Select the appropriate statement to fill the statement 1.
(i) w[0]= =”A” or w[0]= =”B”
(ii) w[0] in [“A”,”B”]
(iii) w[0]= =”A” and w[0]= =”B”
(iv) w[0]= =”A”,”B”
(A) (i) and (ii) (B) (ii) and (iv)
(C) (i) and (iv) (D) (ii) and (iii)
30. Considering the following function/method in python which read
lines from a text file “INDIA.TXT”, to find and display the
occurrence of the word “India”. Find the missing statement in
following code:
def countword():
f=open("INDIA.TXT", 'r')
Page 3 of 7
4. count=0
data=___________
word=data.split()
for i in word:
if i.lower()=='india':
count=count+1
print("no of words=",count)
f.close()
(A) f.read() (B) f.readline()
(C) f.readlines (D) f.write()
31. 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
Achievements.jpg?
(A) School/Achievements.jpg
(B) School/Sports/Achievements.jpg
(C) School/Sports/../Achievements.jpg
(D) School/Examination/Achievements.jpg
32. Give the output
lt=[1,0,5,8,10,15]
lt2=[[‘one’,’two’,’three’],[4,5,6]]
lt[2]=lt[3]
lt[0]=lt[1]
lt2[-1][0]=lt[2]+3
print(lt2[1])
(A) [“two”] (B) [4,5,6]
(C) [11,5,6] (D) [“two’,”three”]
33. What will be the output of the following python code:
val = 50
def display(N):
global val
val=89
print(val)
if N%14==0:
val = val + N
else:
val = val - N
print(val, end="@")
display(40)
print(val,val+4,sep='*')
A) 50@89
49*53
B) 89@89
49*53
C) 50@89
49,49
D) 50@89
49,53
34. In the following question a statement of Assertion (A) is followed by
a statement of Reason (R). Mark the correct choice as:
Assertion (A): Data types are used to identify the type of data.
Reason (R): Data types are two types as numbers and strings.
(A) Both Assertion (A) and reason (R) are true and reason (R) is the
correct explanation of Assertion (A).
(B) Assertion (A) and reason (R) are true and reason (R) is not the
correct explanation of Assertion (A).
(C) Assertion (A) is true but reason (R) is false.
(D) Assertion(A) is false but reason (R) is true.
35. Consider the code given below and Identify how many times the
message “all the best” will be printed?
def prog(name):
for x in name:
if x.isalpha():
print(“alphabet”)
elif x.isdigit():
print(“digit”)
elif x.isupper():
print(“upper”)
else:
print(“all the best”)
prog(“vishal123@gmail.com”)
(A) 0 (B) 2
(C) 1 (D) 3
36. What is the length of the given tuple? t1=(1,2,(3,4,5))
(A) 1 (B) 2
Page 4 of 7
5. (C) 3 (D) 4
37. Suppose content of 'Myfile.txt' is
Stay positive and happy
Work hard and don't give up hope
Be open to criticism and keep learning
Surround yourself with happy, warm and genuine people
What will be the output of the following code?
myfile = open ("Myfile.txt")
record=myfile.readline()
record = myfile.readline().split()
print(len(record))
myfile.close()
(A) 4 (B) 7
(C) 11 (D) 10
38. What will be the output of the following code segment?
L='good'
L=[1,2,3]
n=2
print(L*n)
(A) goodgood (B) [1, 2, 3, 1, 2, 3]
(C) Error (D) None
39. The file “new.txt” contains the following content:
my poem
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
Poem is good but do not like
Considering the above file, what output will be produced by the
following code?
f=open("new.txt",'r')
a=f.readline()
b=f.read(4)
c=f.readline()
d=f.readline()
print(c)
f.close()
(A) a great fall (B) ty Dumpty sat on a wall
(C) Dumpty sat on a (D) Humpty together again
40. What will be the output when the following code is executed?
digits = [0, 1]
for i in digits:
print(i)
else:
print("final")
(A) 0 1 (B) 0 1 final
(C) 0 final (D) 0 0
41. Which of the following Python codes will give same output
tupl=(1,2,3,4)
(i) print(tupl[:-1])
(ii) print(tupl[0:5])
(iii) print(tupl[0:4])
(iv) print(tupl[-4:])
(A) i, ii (B) ii, iv
(C) i, iv (D) ii,iii,iv
42. Give the output
def sum(*a):
s=0
for i in a:
s=s+i
print(s,end='')
sum(2,3)
sum(2,6,3)
sum(1,2,3,4)
(A) 25281113610 (B) 2 5 2 8 11 13 6 10
(C) 25 28 11 13 61 0 (D) Error
43. What is the possible outcomes executed from the following code?
import random
string="CBSEONLINE"
number=random.randint(0,3)
n=9
Page 5 of 7
6. while string[n] != 'L' :
print(string[n]+string[number]+'#',end=' ')
number=number+1
n=n-1
(1) EE# NO# IN#
(2) EC# NB# IS#
(3) EB# NS# IE#
(4) ES# NE# IO#
(A) 1 and 2 (B) 2 and 4
(C) 1, 2 and 4 (D) 1, 2, 3 and 4
44. myfile=open(“class.txt”,”r”)
Str=myfile.read(12)
The above code will be equal to:
(A) file(“class.txt”,”r”).read(12)
(B) Myfile(“class.txt”,”r”).read(12)
(C) file(“class.txt”,”r”).myfile.read(12)
(D) myfile(“class.txt”,”r”).read(12)
45. In order to check whether the key 2 is present in the dictionary Book,
Ramesh uses the following command:
2 in Book
He gets the answer 'True'. Now to check whether the name 'Madras
Diaries' exists in the dictionary Library, he uses the following
command: 'Madras Diaries' in Library But he gets the answer as
'False'. Select the correct reason for this:
(A) We cannot use the in operator with values. It can be used with
keys only.
(B) We must use the function Library, values() along with the
operator
(C) We can use the Library items() function instead of the in operator
(D) Both B and C above are correct
46. What would be the output of the following program code?
def func(S):
k=len(S)
m=""
for i in range(0,k):
if S[i].islower( ):
m=m+S[i].upper( )
elif S[i].isdigit( ):
m=m+'*'
elif S[i].isupper():
m=m+S[i].lower()
else:
m=m+'@'
print(m)
func('CS WORKSHOP 2021')
(A) cs@workshop@**** (B) CS WORKSHOP 2021
(C) cs*workshop*@@@@ (D) cs*WORKSHOP*@@@@
47. Which of the following is correctly evaluated for this function?
pow(x,y,z)
(A) (x**y) / z (B) (x / y) * z
(C) (x**y) % z (D) (x / y) / z
48. Yashi wants to check whether her name is listed in Shortlisted.dat or
not. Which command she can write to open and check the file:
(A) a=open(“Shortlisted.dat”,”r+”)
(B) with open (“Shortlisted.dat’,’rb”) as a:
(C) with open (“Shortlisted.dat’,’r”) as a:
(D) All of these
49. Choose correct output for the following code:
def check(x,y):
if x != y:
x=10
for i in range(x):
if x==5:
break
else:
print(i,end='')
pass
print(x)
else:
pass
print(check(10,5))
(A) 012345678910
None
(B) 0123456789
10
None
Page 6 of 7
7. (C) 012345678910
(D) 0123456789
10
SECTION C .
SECTION C CONSISTS OF 06 QUESTIONS,
ATTEMPT ANY 05 QUESTIONS.
Your teacher has given you a method/function FilterWords() in
python which read lines from a text file NewsLetter.TXT, and
display those words, which are lesser than 4 characters. Your
teachers intentionally kept few blanks in between the code and asked
you to fill the blanks so that the code will run to find desired result.
Do the needful with the following python code.
def FilterWords():
file=open('NewsLetter.TXT', '________')
#Statement-1
line=file.________________ #Statement-2
word=__________________ #Statement-3
for c in _______________ : #Statement-4
if _____________ : #Statement-5
print(c)
______________ #Statement-6
FilterWords()
50. Fill in the blank in statement-3 to read data word by word.
(A) Line.Split() (B) Line.split()
(C) line.split() (D) split.word()
51. Fill in the blank in statement-5, which display the word having lesser
than 4 characters.
(A) len(c) ==4 (B) len(c)<4
(C) len()==3 (D) len(4)<c
52. Fill in the blank in statement-4, which retrieve each word.
(A) Line (B) File
(C) word (D) None of the above
53. Fill in the blank in Statement-6 to close the file
(A) file.close() (B) File.Close()
(C) Close() (D) end()
54. Fill in the blank in statement-2 to read the data from the file.
(A) File.Read() (B) file.read()
(C) read.lines( ) (D) readlines( )
55. Write mode of opening the file in statement-1?
(A) a (B) ab
(C) w (D) r
Page 7 of 7