0% found this document useful (0 votes)
202 views10 pages

Class XII Computer Science Pre-Board Exam

This document is a computer science pre-board exam with 3 sections (A, B, C). Section A has 25 multiple choice questions to attempt 20. Section B has 24 multiple choice questions to attempt 20. Section C has 5 case study questions to attempt. The questions cover topics like Python identifiers, data types, files, dictionaries, tuples, and more.

Uploaded by

Kavin Satya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
202 views10 pages

Class XII Computer Science Pre-Board Exam

This document is a computer science pre-board exam with 3 sections (A, B, C). Section A has 25 multiple choice questions to attempt 20. Section B has 24 multiple choice questions to attempt 20. Section C has 5 case study questions to attempt. The questions cover topics like Python identifiers, data types, files, dictionaries, tuples, and more.

Uploaded by

Kavin Satya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

HOSUR SAHODAYA SCHOOLS COMPLEX SET-3

Common Pre-Board Examination (2021-’22)


TERM-1

Class: XII Marks: 35


Subject: Computer Science (083) Duration: 90 mins

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 Questions (50-55). Attempt any 5questions.
• All questions carry equal marks.

Q.No. Section-A
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option.
1 Choose the invalid identifier : -
a. age
b. 1age
c. Age
d. _age
2 Which one of the following is a jump statement:
a. break
b. continue
c. pass
d. all the above
3 Which of the following is a mutable sequence data type:
a. string
b. list
c. tuple
d. all the above
4 Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a. print(t[3])
b. t[3] = 45
c. print(max(t))
d. print(len(t))
5 Which of the following is not a proper file access mode?
a. append
b. read
c. write
d. close
6 csv stands for:
a. comma separated value
b. common shift value
c. chief super value
d. common separated value
7 Which of the following can be used to delete item(s) from a dictionary?
a. del statement
b. get()
c. getitem()
d. all of these
8 If no argument is given, then pop() returns and removes the element of the list.
a. middle
b. first
c. last
d. all
9 Which method can not be used to read from files?
a. read()
b. readlines()
c. readline()
d. readlines(<filename>)
10 The file mode is used when the user writes data into a binary file.
a. rb
b. r+
c. wb
d. w+
11 Which option is correct about this program?
f=open(“ss.txt”,”wb”)
print(“Name of the file:”,f.name)
f.flush()
f.c lose()
a. Compilation error
b. Runtime error
c. No output
d. Flushes the file when closing them
12 In tuples values are enclosed in
a. square brackets
b. curly brackets
c. parenthesis
d. none of the above
13 Which file can open in any text editor and is in human readable form?
a. Binary files
b. Video files
c. Data files
d. Text files
14 Which of the statements correctly explains the concept of seek() method:
a. Tells the current position within the file
b. It confirms whether you can move to the position in file or not.
c. Indicates from where next read or write will take place
d. Moves the current position of file object to a given specified position
15 A function may have: -
a. Keyword arguments
b. Default Arguments
c. Positional arguments
d. All the above
16 Write the output of the following:

a= (“Amit”, “Sumit”,”Ashish”,”Sumanta”)
print(max(a))
a. Sumanta
b. Ashish
c. Sumit
d. Amit
17 Which of the following function headers is correct?
a. def f(a = 1, b):
b. def f(a = 1, b, c = 2):
c. def f(a = 1, b = 1, c = 2):
d. def f(a = 1, b = 1, c = 2, d):
18 To open a file c:\scores.txt for writing, we use
a. outfile = open(“c:\scores.txt”, “w”)
b. outfile = open(“c:\\scores.txt”, “w”)
c. outfile = open(file = “c:\scores.txt”, “w”)
d. outfile = open(file = “c:\\scores.txt”, “w”)
19 Which of the following is not a tuple?
a. P = 1,2,3,4,5
b. Q = (‘a’, ‘b’, ‘c’)
c. R = (1, 2, 3, 4)
d. None of the above
20 Which of the following statement in python is correct after using: import csv
a. csv.error(Required Attributes)
b. csv.DictWriter(Required Attributes)
c. csv.writer(Required Attributes)
d. csv.reader(Required Attributes)
21 What will be the result of the following code?

dict = {"Jo" : 1, "Ra" : 2}


dict.update({"Ph":2})
print (dict)
a. {"Jo":1,"Ra" :2, "Ph" : 2}
b. {"Jo":1,"Ra":2}
c. {"Jo":1,"Ph" :2}
d. Error
22 The data files can be stored as:
a. text files
b. binary files
c. csv files
d. all of these
23 Which keyword is used to access a global variable in a function?
a. non local
b. global
c. def
d. return
24 Harish developed a python code to update a binary file “Stock.dat”, He opened the file
using command with open(“Stock.dat”, “rb+”) as f: later he realized that he forgot to
close the file in program, what can be the consequences?
a. file will be closed automatically
b. data written file will get deleted
c. file will not open in next run
d. unpredictable
25 To calculate 2 raised to the power 5 which of following can be used: -
a. pow(2,5)
b. 2 ** 5
c. Both A and B
d. None
Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.
26 Write the output of the following:
t1 = (1,2)
t2 = (2,1)
t1 == t2
a. True
b. False
c. Error
d. None of the above
27 You have given a file 'stu.txt'
I am the best student.
I like computer.

What will be the output of the following code?


myfile = open("stu.txt")
str = myfile.readlines()
print(str)
myfile.close()
a. read first line
b. read entire file
c. read second file
d. none of the above
28 What will be the output of the following code segment?
l=['A','a','Aa','aA']
print(max(l))
a. 'aA'
b. 'A'
c. 'a'
d. 'Aa'
29 How many times will the following code be executed?
for i in range(1,15,5):
print(i,end=’,’)
a. 3
b. 4
c. 1
d. infinite
30 What is the output of the following ?
x = 123
for i in x:
print(i)
a. 123
b. 1 2 3
c. error
d. infinite
31 What will be the output of the following code segment?
list1 =['Red', 'Green', 'Blue', 'Cyan', 'Magenta', 'Yellow', 'Black']
print(list1[-4:0:-1])

a. ['Cyan', 'Blue', 'Green', 'Red']


b. [ ]
c. ['Cyan', 'Blue', 'Green']
d. ['Cyan', 'Magenta', 'Yellow', 'Black']
32 Following code is the definition of a dictionary CINEMA, with a method in python to search
and display all contents in a pickled file Cinema.dat, where Mtype key of dictionary is
matching with the value ‘Comedy’.
What will be there in the blanks mentioned as Line1 and Line2 in the following
code: CINEMA={‘MNO’: B ,’MNAME’: , ’MTYPE’: }

import pickle
def Search( ):
file1=open(‘Cinema.dat’, ‘rb+’)
try:
while True:
CINEMA= #Line1
if #line2
print(CINEMA)
except EOFError:
file.close( )

a. Line 1: pickle.dump(file1)
Line 2: CINEMA[‘Mtype’]== ‘Comedy’:
b. Line 1: pickle.load(file1)
Line 2: CINEMA[‘Mtype’]== ‘Comedy’:
c. Line 1: load(file1)
Line 2: CINEMA[‘Mtype’]== ‘Comedy’:
d. Line 1: pickle.dump(file1)
Line 2: ‘Mtype’== ‘Comedy’:
33 Following code is written to update a record in the file opened with the following
code.
What will be there in blanks mentioned as Line1 and Line2 in the following code:

import pickle
fin=open(‘emp.dat’, ‘rb+’)
try:
while True:
=fin.tell( ) #line 1
stu=pickle.load(fin)
if emp[‘sal’] in[2000, 5000 10000]:
emp[‘sal’] +=500
fin. ( ) #line 2
pickle.dump(emp, fin)
except EOFError:
fin.close( )
a. Line 1: position= fin.tell( )
Line 2: fin.seek(position)
b. Line 1: position= fin.tell( )
Line 2: fin.tell(position)
c. Line 1: fin.seek( )
Line 2: fin.tell(position)
d. Line 1: fin.seek( )
Line 2: fin.tell( )
34 Choose the correct answer:
def fun1(num):
return num+5
print(fun1(5))
print(num)
a. Print value 10
b. Print value 5
c. Name Error
d. 25
35 What is the output of this expression, 3*1**3?
a. 27
b. 9
c. 3
d. 1
36 What will be the output of the following python code:
def A_func (x=10, y=20):
x =x+1
y=y-2
return (x+y)
print(A_func(5),A_func())
a. 24,29
b. 15,20
c. 20,30
d. 25,30
37 What will be the output of the following python code:
val = 100
def display(N):
global val
val = 50
if N%14==0:
val = val + N
else:
val = val - N
print(val, end="@")
display(40)
print(val)
a. 100@10
b. 50@5
c. 5@50
d. 100@10@
38 What are the possible outcome(s) executed from the following code?
import random
STRING=”CBSEONLINE”
NUMBER=random.randint(0,3)
N=9
while STRING[N]!=”L”:
print (STRING[N] +STRING[NUMBER] + “#”,end=””)
NUMBER=NUMBER+1
N=N-1
(i) ES#NE#IO# (ii) LE#NO#ON# (iii) NS#IE#LO# (iv) EC#NB#IS#
a. (i) and (ii)
b. (ii) and (iii)
c. (i) and (iv)
d. (iii) and (iv)
39 Predict the output of the following code :
def fun3(num1,num2):
for x in range(num1,num2):
if x%4==0:
print(x,end=’ ‘)
fun3(10,20)
a. 10 12 16 20
b. 12 16
c. 12 16 20
d. 16
40 Suppose the content of "Myfile.txt" is
Honesty is the best policy
What will be the output of the following code?

myfile = open("Myfile.txt")
x = myfile.read()
print(len(x))
myfile.close()
a. 5
b. 25
c. 26
d. 27
41 Consider the code given below and identify which message will never 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(“[email protected]”)
a. alphabet
b. digit
c. upper
d. all the best
42 Which of the following options can be used to read the 2nd line of a text file?
a. file=f.readlines()
print(file[1])
b. file=f.readline()
print(file[1])
c. file=f.read()
print(file[1])
d. file=f.readlines()
print(file[2])
43 The file “Myfile.txt” contains the following content:

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.readline().split()
print(len(record))
myfile.close()
a. 4
b. 5
c. 6
d. 7
44 Which of the following statements is not true for parameter passing to functions?
a. You can pass positional arguments in any order.
b. You can pass keyword arguments in any order.
c. You can call a function with positional and keyword arguments.
d. Positional arguments must be before keyword arguments in a function call.
45 The readlines() method returns the entire contents of the entirefile
a. a list of string
b. a list of lines
c. list of single characters
d. a list of integers
46 Which of the following options can be used to read the two lines of a text file in the form of
string from Myfile.txt. Assuming the file having two lines only.
a. myfile = open(‘Myfile.txt’); myfile.read()
b. myfile = open(‘Myfile.txt’,’r’); myfile.read(2)
c. myfile = open(‘Myfile.txt’); myfile.readline(2)
d. myfile = open(‘Myfile.txt’); myfile.readlines()
47 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()
48 Assume the content of text file, 'student.txt' is:
Ramesh is a student
Radha is a girl
What will be the data type of data_rec?
myfile = open("student.txt")
data_rec = myfile.read()
myfile.close()

a. string
b. list
c. tuple
d. dictionary
49 Given a Tuple t= (10, 20, 30, 40, 50, 60, 70, 80, 90).
What will be the output of print (t [3::2])?
a. (40,60,80)
b. (30,50,70)
c. (30,050,70,90)
d. (40,60)
Section-C
Case Study based Questions
This section consists of 6 Questions (50 to 55) Attempt any 5 questions.
Bhavesh is learning to work with Binary files in Python using a process known as Pickling/Un-
pickling. His Computer Science teacher has given him the following incomplete code, which
is creating a Binary file namely Record.dat and then opens, reads and displays the content
of this created file.

import #Statement-1
L1=list()
for i in range(4):
L.append(i+i)
f1=open(“Record.dat”, ) #Statement-2
(L1,f1) #Statement-3
f1.close()
f2=open(“Record.dat”, “rb” )
L2= (f2) #Statement-4
f2. #Statement-5
print(L2) #Statement-6
50 Which module should be imported in Statement-1?
a. pickle
b. csv
c. file
d. text
51 Which file mode to be passed to write data in file in Statement-2?
a. w+
b. w
c. wb
d. a
52 What should be written in Statement-3 to write data onto the file?
a. dump()
b. write()
c. pickle.dump()
d. writeline()
53 Which function to be used in Statement-4 to read the data from the file?
a. load()
b. readline()
c. readlines()
d. pickle.load()
54 Which function to be used in Statement-5 to close the file Record.dat?
a. dump()
b. load()
c. exit()
d. close()
55 The output after executing Statement-6 will be:
a. 0 2 4 6
b. {0, 2, 4, 6}
c. [0, 2, 4, 6
d. (0,2,4.6)

All The Best

You might also like