You are on page 1of 16

AIR FORCE SCHOOLS

COMMON PRE-BOARD EXAMINATION: 2021-22


TERM 1
CLASS – XII

• Please check that this question paper contains 16 printed pages.

• Please check that this question paper contains 55 questions.

SUBJECT: COMPUTER SCIENCE (083)


Time: 90 Minutes Max Marks: 35

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 consists of 6 case study based (50-55). Attempt any 5 questions.
• All questions carry equal marks.

Q. N. Section – A
This section consists of 25 questions (1-25). Attempt any 20 questions
from this section. Choose the best possible option
1. Which of the following is a valid identifier?
(a) Match One
(b) 1Match
(c) Match#
(d) In_Match

2. Which of the following is correct function header?

(a) def test(pal ; sal):


(b) def test(pal=12,sal):
(c) def test(pal,sal):
(d) def test(pal=12 ; sal=12):

Page 1 of 16
3. Which of the following is NOT a relational operator?

(a) !=
(b) **=
(c) ==
(d) <=

4. Which of the following parameter needs to be added with open() to avoid having
blank row after writing each record in a csv file?

(a) delimiter
(b) newline
(c) Either (a) or (b)
(d) Neither (a) nor (b)

5. How many times will the following loop iterate?

freddy=3
while freddy!=0:
print(freddy)
print("Move to next question")

(a) 3
(b) 4
(c) Infinite
(d) Not even once

6. What will be the output if the following expression is evaluated in Python?


24%3> 2**3 or not 45

(a) True
(b) False
(c) Compilation Error
(d) None

7. What is the valid syntax to write an object onto a binary file opened in write
mode?
(a) pickle.dump(<object to be written>, <file handler>)
(b) dump.pickle(<file handler>,<object to be written>)
(c) dump.pickle(<object to be written>, <file handler>)
(d) pickle.dump(<file handler>,<object to be written>)

8. Fill in the blanks from the options given below


When you read a csv file using csv.reader(), it returns the values in

Page 2 of 16
_______________ object.

(a) Dictionary
(b) List
(c) String
(d) Integer

9. Consider the code given below and select the correct output. (Assume the
required modules have been imported)
myString="I am my own boss and my own creator"
print(myString.split('my'))

(a) ['I', 'am', 'my', 'own', 'boss', 'and', 'my', 'own', 'creator']
(b) ('I', 'am', 'own', 'boss', 'and', 'own', 'creator')
(c) ['I am ', ' own boss and ', ' own creator']
(d) ('I am ', 'my', ' own boss and my own creator')

10. Assume tag="CoVer and & UnCOVER"


Which is the correct statement to display COVER?

(a) tag[5:]
(b) tag[-5:0]
(c) tag[0:-5]
(d) tag[-5:]

11. Consider the following function header


def PotLuck(coin, coupon=3,draw='y'):

Which of the following function call statements will result in an error?

(a) PotLuck(12)
(b) PotLuck("no")
(c) PotLuck()
(d) PotLuck('no',10,20)

12. Consider the statement given below:


L=list("Term 1 PREboard")

Choose the correct match out of the options given below with respect to the
given statement:
(i) print(L[1:12:3]) a. ['r', 'a', 'o']
(ii) print(L[-2:-5:-1]) b. []
(iii) print(L[:-10]) c. ['T', 'e', 'r', 'm', ' ']
(iv) print(L[-10:0]) d. ['e', ' ', 'P', 'b']

(a) (i)-c , (ii) – b, (iii) – a , (iv) – d


Page 3 of 16
(b) (i)-d , (ii) – b, (iii) – c , (iv) – a
(c) (i)-d , (ii) – a, (iii) – c , (iv) – b
(d) (i)-c , (ii) – d, (iii) – a , (iv) – b

13. Consider the given list


L=[["Red","Green"],255,0,150,['R', 'G', 'B'], 100,120,250]
What will be the value of L[4][2]?

(a) B
(b) G
(c) 150
(d) E

14. Rimjhim has created a tuple using the following statement


T=(‘aaa’,’bbb’,’ccc’)
Now, she wants to add a new element, ‘ddd’, to the tuple. Which of the following
statements should she use?

(a) T+(‘ddd’)
(b) T+(‘ddd’,)
(c) T+ ‘ddd’
(d) T+(ddd,)

15. Which of the following built-in function returns the string with first letter of every
word in the string in uppercase and rest in lowercase?

(a) Sentence()
(b) sentence()
(c) Title()
(d) title()

16. Which of the following statements will delete the key value pair for key ,
”English” from the following dictionary?
Subjects={"Hindi”:111, "English":222,"Maths":3000}

(a) del Subjects["English"]


(b) del.Subjects[“English”]
(c) del Subjects[English]
(d) delete Subjects

17. Which of the following is not True about tuples in Python?

(a) A tuple is an ordered data type


(b) A tuple is an unordered data type
(c) A tuple can have a tuple as its element
(d) A tuple is enclosed in parenthesis
Page 4 of 16
18. Consider the statements given below:
>>>t1=(1,2)
>>>t1=(2,3)
>>>t3=t1*t2
>>>print(t3)

Which of the following statements is True with respect to the given code?

(a) No error will be generated and no output will be displayed


(b) No error will be generated and output will be (1,2,2,3)
(c) An error will be generated as t1 * t2 is not possible
(d) An error will be generated as t3 cannot be assigned any value

19. Which built-in function returns the entire file content in the form of a list with
each line as one element of the list?

(a) read()
(b) readline()
(c) readlines()
(d) write()

20. Which of the following is NOT an example of a text file?

(a) .txt
(b) .csv
(c) .py
(d) .bin

21. Which file open mode overwrites the contents of an already existing file?

(a) w
(b) ab
(c) a
(d) r

22. What will be the output of the following code?


F=open("aaaa.txt","wb")
print(F.mode)
F.close()

(a) wb
(b) w
(c) Compilation Error
(d) Runtime Error

Page 5 of 16
23. Which function is used to read all characters in a text file? (assume the file
object as F)
(a) F.readline()
(b) F.read()
(c) F.readall()
(d) F.readlines()

24. Which of the following statements is not True?


(a) tell() returns an integer
(b) seek() positions the file pointer in a data file
(c) seek() always takes 2 arguments
(d) tell() never takes any argument

25. Fill in the blanks with the correct option.


The process of converting byte stream to Python object is called
______________________.

(a) Pickeling
(b) Unpickeling
(c) Objectifying
(d) Unobjectifying

Section - B
This section consists of 24 questions (25-49). Attempt any 20 questions
from this section. Choose the best possible option
26. Select the correct output for the code given below:

def exam(var1,var2=-2):
var1=var1//var2
var2+=var1
print(var1,var2,sep="@")
return var1,var2
num1=10
num2=exam(num1)
print(num1,num2,sep="@")

(a) -5@-7
10@(-5, -7)

(b) -5@-7
10@ -5 @ -7

(c) -7@-5
10@(-7, -5)

Page 6 of 16
(d) -7@-5
10@ -7 -5

27. Which of the given outputs is correct for the code given below:
import random
Cities=["Singapore","Paris","Tokyo","Delhi", "New
York","Sydney"]
option1=random.randint(2,4)
option2=random.randint(3,5)
for x in range(option1,option2+1):
print(Cities[x], end="#")

(a) Singapore#Delhi#New York#


(b) Delhi#New York#
(c) Paris#Delhi#New York#
(d) Paris#Delhi#New York#Sydney#

28. What will be the output of the following code?


Limit=0
for P in range(5,15,4):
Limit+=pow(P,2)
print(Limit,end=' ')

(a) 25 106 275


(b) 25 81 169
(c) 25 106 275 564
(d) 25 81 169 289

29. What will be output of the following code?


myList=[-1,0,1]
newList=myList*2
newList.insert(1,-1)
value=newList.index(1)
print(value)

(a) 0
(b) 1
(c) 2
(d) 3

30. Observe the following code carefully and then choose the correct option to
complete Statement 1. Assume all the required modules have been imported.

L=["I01","Pencil",10,5]
with _______________________ as f: # Statement 1
Page 7 of 16
R=csv.writer(f,delimiter=',')
R.writerow(L)

(a) open("abc.txt",'r')
(b) open("abc.csv",'r')
(c) open("abc.txt",'w')
(d) open("abc.csv",'w')

31. What will be the output of the given code?


slogan="#LonG lIVe OUR COUNtry INdia!!"
sub=slogan[-3:3:-2]
print(sub.count('I',1,4))

(a) 0
(b) 1
(c) 2
(d) None

32. Suppose the content of text file, ‘goodManners.txt’ is : ( all sentences on a new
line)

What will be the output of the following code?

F=open("goodManners.txt","r")
Data=F.readlines()
print(len(Data))
F.close()

(a) 2
(b) 3
(c) 4
(d) 5

33. What will be the output of the code given below:


points=25
def code(N):
global points
points=50
if N%10==0:
points=points+N

Page 8 of 16
else:
points=points-N
print(points, end="^")
code(100//5**2)
print(points)

(a) 25^54
(b) 54^25
(c) 25^46
(d) 46^25

34. Choose the correct output for the given code


Data =['Dad',100,'Mom',200,'Sis',300, 'Bro', 400]
Alpha=' '
Beta=0
Final=0
for C in range(1,7,2):
Beta=Beta+C
Alpha=Alpha+Data[C-1]+'!!'
Final=Final+Data[C]
print(Beta, Alpha, Final)

(a) 16 Dad!!Mom!!Sis!! 1000


(b) 9 Sis!!Mom!!Dad!! 600
(c) 16 Dad!!Mom!!Sis!! 600
(d) 9 Dad!!Mom!!Sis!! 600

35. What will be the output of the following code?


import string
startString="ICT No 1*"
finalString=" "
L=0
Val=1
while L<len(startString):
if startString[L]>='0' and startString[L]<='9':
Val=int(startString[L])
Val=Val-1
finalString=finalString+startString[Val]
elif startString[L].isupper():
if startString[L] not in "AEIOU":
finalString=finalString+'$'
else:
finalString=finalString+startString[L+1]
else:
finalString=finalString+'*'

Page 9 of 16
L=L+1
print(finalString)

(a) C$*$$**I*
(b) C$$*$**I*
(c) $T**o**I*
(d) $T *o**I**

36. Consider the following code:


def count(K1):
f=open("countFile.txt","r")
num=0
N=f.readlines()
for m in N:
if m[0]==K1:
num+=2
print("The answer is ", num)
ch='K'
count(ch)

If the contents of countFile.txt is as given in the image, what will be the output of
the given program?

(a) The answer is 4


(b) The answer is 2
(c) The answer is 8
(d) The program will flash an error

37. Select the output for the given code:


D1={"Veg":1,"Non-Veg":2,"Vegan":3}
print("Non-Veg" in D1, end='**')
D1.get("Vegan")

(a) False** 3
(b) 3** False
(c) 3** True
(d) True**3

38. Select the correct output for the given code:


Page 10 of 16
L1=[5,10,20]
L2=[1,2]
L1.append(L2)
L1.pop()
print(L1,L2)

(a) [5, 10, 20,1, 2]


(b) [[5, 10, 20] [1, 2]]
(c) [5, 10, 20] [1, 2]
(d) [1,2] [5,10,20]

39. Consider the code given below:


import math
mod1=50
while mod1>=10:
mod=mod1//10
if mod%2==0:
___________________ # Statement 1
else:
print(math.factorial(mod))
mod1=mod1-5

Which of the following is the correct statement that is missing in the code
(Statement 1), if the output is 105?

(a) break
(b) jump
(c) continue
(d) pass

40. Consider the following code:

import pickle
__________________________ # Statement 1
T=("T1010","Sunny","Chandigarh","Nagpur",15000)
pickle.dump(T,f)
f.close()

Which of the following statements ( to complete Statement 1) will open the file,
result.dat, to add the new record at the end of the file?

(a) f.open("result.dat","ab")
(b) pickle.open("result.dat","ab")
(c) open.pickle("result.dat","ab")
(d) f=open("result.dat","ab")

Page 11 of 16
41. The program given below reads the contents of a binary file, result.dat. Out of
the options given below, which should be used for Statement 1? Assume the
required modules are already imported.

f=open("result.dat","rb")
count=0
rec=0
try:
while True:
rec=rec+1
______________________ # Statement 1
print("Record No", rec)
print(L1)
except:
print("Records Over")
f.close()

(a) L1=pickle.load(f)
(b) pickle.load(f,L1)
(c) pickle.load(L1,f)
(d) f.load(L1)

42. What will be the output of the code given below:


F1=open("pledge.txt","r")
content=F1.read().split()
count=0
print(content)
for words in content:
if words[0]== "a":
count+=1
print(words.upper(), count, sep='$')
F1.close()

(a) AND$1
ARE$2

(b) ARE$1
AND$2

(c) ARE$1
AND$1

(d) AND$1
ARE$1
Page 12 of 16
43. Sangini was to read 4th line from the text file, try.txt. Which of the following is the
correct statement? Assume the file object is F.

(a) L4=F.readlines() ; print(L4[3])


(b) L4=F.read(4) ; print(L4[3])
(c) L4=f.readline(4) ; print(L4[3])
(d) L4=readlines(4) ; print(L4[3])

44. What will be the output for the given code?


T=(1,2,5,6)
T=T*2
print(T[2:len(T)-3])

(a) (5,6, 1, 2, 5, 6)
(b) (5, 6, 1, 2)
(c) (5, 6, 1)
(d) (5, 6, 1, 2, 5)

45. Consider the code given below:


str="ONline and OFFline"
for x in str[2:-9]:
print("Classes")

How many times the word ‘ Classes ‘ will be printed?

(a) 6
(b) 7
(c) 8
(d) 9

46. The following code counts the number of digits in a text file, digits.txt. Select the
correct option to complete Statement 1.

File=open("digits.txt","r")
count=0
data=File.read()
for ch in data:
if___________________: # Statement 1
count+=1
print("No of digits ", count)
File.close()

(a) ch = "0123456789"
(b) ch not in "0123456789"
Page 13 of 16
(c) ch != "0123456789"
(d) ch in "0123456789"

47. What will be the output if following statements are executed on the interpreter?
>>> import math
>>> Z=math.ceil(12.909)-math.floor(12.909)
>>> not bool(Z)

(a) 1
(b) 0
(c) True
(d) False

48. Consider the following statements:


>>> L=[21,22,31,32]
>>> id(L)
32160989528761
>>> L[2]=10
>>> id(L)
_______________________

What will be the output?

(a) [1,2,10,4]
(b) 32160989528761
(c) 10
(d) 32160989528771

49. What will be the output of the following Python snippet?

import math
num1=divmod(25,4)
num2=int(math.fmod(15,4))
num1=num1+(num2,)
print(num1)

(a) (6, 1, 3)
(b) [6, 1, 3]
(c) (1,6, 3)
(d) [1, 6, 3]

Section – C
Case Study Based Questions
This section contains 6 questions (50-55). Attempt any 5 questions
Salman is learning to store data in a csv file through a Python program. He has
been assigned the following code which is incomplete. Help him in completing
Page 14 of 16
the code.

___________________ # Statement 1
Account1={'Acc No':1234,'Name':'Aditya','Balance':500000}
Account2={'Acc No':5678,'Name':'Geet','Balance':250000}
with open("myBank.csv",'a', newline='') as C1:
colheadings=['Acc No','Name','Balance']
wr=_____________________________ #Statement 2
________________________________ # Statement 3
wr.writerow(Account1)
wr.writerow(Account2)
with open("myBank.csv",'r') as C1:
rr=csv._______________ (C1) # Statement 4
print('Acc No','Name','Balance')
__________________ # Statement 5
print(row['Acc No'],row['Name'],row['Balance'])

50. Identify the statement ( Statement 1) to include the relevant module in the
program.

(a) import pickle


(b) import csv
(c) pickle import
(d) csv import

51. Which is the correct option to complete Statement 2?


(a) csv.Writer(C1, fieldnames=colheadings)
(b) csv.dictwriter(C1, fieldnames=colheadings)
(c) csv.DictWriter(C1, fieldnames=colheadings)
(d) csv.writer(C1, fieldnames=colheadings)

52. While executing the code for the first time, if the file does not exist, what will
happen?
(a) A syntax error will be displayed
(b) A new file will be created
(c) File will not open
(d) A runtime error will be displayed

53. Which of the following is the correct option for Statement 3?


(a) wr.writeheader()
(b) csv.writeheader()
(c) wr.writedictheader()
(d) csv.writedictheader()

54. Which of the following built-in functions should be used to complete Statement
Page 15 of 16
4?
(a) Reader()
(b) dictReader()
(c) reader()
(d) DictReader()

55. Out of the options given below, identify the correct loop statement to complete
Statement 5.
(a) for rr in row:
(b) for row in range(rr):
(c) for row in rr:
(d) for row in rr[0:]:

Page 16 of 16

You might also like