Sample Paper 3: Computer Science

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

68 CBSE Sample Paper Computer Science Class XII (Term I)

SAMPLE PAPER 3
COMPUTER SCIENCE
A Highly Simulated Practice Questions Paper
for CBSE Class XII (Term I) Examination

Instructions
1. This question paper is divided into three sections.
2. Section - A contains 25 questions (1-25). Attempt any 20 questions.
3. Section - B contains 24 questions (26-49). Attempt any 20 questions.
4. Section - C contains 6 case study based questions (50-55). Attempt any 5 questions.
5. Each question carries 0.77 mark.
6. There is no negative marking.

Maximum Marks : 35
Roll No. Time allowed : 90 min

Section A
This section consists of 25 questions (1 to 25). Attempt any 20 questions from this section. Choose the best
possible option.

1. Which of the following is/are character set?


(a) Alphabets (b) Digits (c) White space (d) All of these

2. Which of the following are the most obvious kind of constants?


(a) Keywords (b) Literals (c) Variables (d) Identifiers

3. These operators are used to make a decision on two conditions.


(a) Logical (b) Arithmetic
(c) Relational (d) Assignment
SAMPLE PAPER 3

4. String literals in Python are enclosed by ............ .


(a) double quotes (b) single quotes
(c) Both (a) and (b) (d) None of these

5. Which index number is used to represent last character of string?


(a) − 1 (b) 1 (c) 0 (d) n − 1

6. ……… operator checks whether the left value is greater than the one on the right.
(a) Greater than or equal to (b) Greater than
(c) Less than or equal to (d) Less than
CBSE Sample Paper Computer Science Class XII (Term I) 69

7. file. mode attribute is used to


(a) store access mode (b) traverse mode
(c) return access mode (d) All of these

8. This method is used to write a string into the file.


(a) writelines() (b) write()
(c) writerow() (d) writer()

9. Which of the following is/are used as line termination for readline()?


(a) ‘\n’ (b) EOF
(c) Either (a) or (b) (d) None of these

10. Serialization process is also called


(a) pickling (b) unpickling
(c) dump() method (d) load() method

11. This character is used in CSV file.


(a) rb (b) wb (c) rb + (d) x

12. Which of the following is related to working directory?


(a) Relative (b) Absolute (c) Both (a) and (b) (d) None of these

13. The def keyword is followed by the function name and


(a) parameter (b) argument (c) parenthesis (d) classes

14. To add a new element to a list, which command will we use?


(a) list1.add(8) (b) list1.append(8)
(c) list1.addLast(8) (d) list1.addEnd(8)

15. What will be the output of the following Python code snippet?
d = {“Neha”:140, “Paras”:145}
print(list(d.keys())
(a) [“Neha”, “Paras”] (b) [“Neha”:140, “Paras”:145]
(c) (“Neha”, “Paras”) (d) (“Neha”:140, “Paras”:145)

16. If a=(11,12,13,14), a[1:−1] is………


(a) (12,13) (b) [12,13]
(c) (12,13,14) (d) error, tuple slicing does not exist

17. Which one of the following has the same precedence level?
(a) Addition and Subtraction
(b) Multiplication, Division and Addition
(c) Multiplication, Division, Addition and Subtraction
(d) Addition and Multiplication
SAMPLE PAPER 3

18. What will be the value of x in the following Python expression?


x=int(43.55+2/2)
(a) 43 (b) 44
(c) 22 (d) 23

19. Which of the following will run without error?


(a) round(65.8) (b) round(1265.983,2,4)
(c) round() (d) round(6529.123,2,l)
70 CBSE Sample Paper Computer Science Class XII (Term I)

20. Which of these definitions correctly describe a module?


(a) Denoted by triple quotes for providing the specification of certain program elements
(b) Design and implementation of specific functionality to be incorporated into a program
(c) Defines the specification of how it is to be used
(d) Any program that reuses code

21. Which of the following is not a valid namespace?


(a) Global namespace (b) Public namespace (c) Built-in namespace (d) Local namespace

22. What is the use of tell() method in Python?


(a) Tells you the current position within the file
(b) Tells you the end position within the file
(c) Tells you the file is opened or not
(d) None of the above

23. Which of the following mode will refer to binary data?


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

24. Correct syntax of file.writelines() is


(a) file.writelines(sequence) (b) fileObject.writelines()
(c) fileObject.writelines(sequence) (d) None of these

25. Which of the following is not a valid attribute of a file object (fp)?
(a) fp.name (b) fp.closed
(c) fp.mode (d) fp.size

Section B
This section consists of 24 questions (26 to 49). Attempt any 20 questions.

26. Find the output of the following code.


dict = {}
a, b, c = 15, 25, 35
dict[a, b, c] = a + b – c
a, b, c = 25, 20, 40
dict[a, b, c] = a + b – c
print(dict)
(a) {(15, 25, 35) : 5, (25, 20, 40) : 5}
(b) {(15, 25, 35), (25, 20, 40)}
(c) {15, 25, 35, 25, 20, 40}
(d) Error
SAMPLE PAPER 3

27. What will be printed on the console by the below code?


x, y, z, k, j = 9, 7, 2, 2, 1
m = 5
if (x > y):
if (y > z and y > k):
m = m – 1
else:
k = k + 1
CBSE Sample Paper Computer Science Class XII (Term I) 71

else:
j = j + 1
print(“m =”, m)
print(“k =”, k)
print(“j =”, j)
(a) m = 2 (b) m = 4 (c) m = 1 (d) m = 2
k=4 k=2 j=2 k=4
j=1 j=1 k=4 j=3

28. Write the output of the following code.


number = 2
def Fun ():
number = 5
print(“Number(s):”)
print(number)
Fun()
print(number)
(a) 5 (b) Number (c) Number(s) (d) number(s)
2 5 5 2
2 2 5

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


i = 1
while True:
if i%5 == 0:
break
print(i)
i += 1
(a) 1 (b) 1 (c) 1 (d) Error
2 2 2
3 3
4

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


str1 = “be honest”
for i in str1.split():
print(i, end=“, ”)
(a) b, e, , h, o, n, e, s, t, (b) b, e,, h, o, n, e, s, t
(c) be, honest, (d) Error

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


SAMPLE PAPER 3

a=[13,6,77]
a.append([87])
a.extend([45,67])
print(a)
(a) [13,6,77, [87], 45, 67] (b) [13,6,77,87,45,67]
(c) [13,6,77,87,[ 45,67]] (d) [13,6,77, [87], [45,67]]
72 CBSE Sample Paper Computer Science Class XII (Term I)

32. What will be display by this file?


import os
f=‘computer.txt’
p=os.path.abspath(f)
print(p)
(a) File name
(b) Complete path
(c) File name with directory name
(d) File name with folder name

33. What will be the output of following code?


def count():
v=0
f=open(“para.txt”, “r”)
N=f.read()
M=N.split()
for i in M:
if (i!=“a” or i!= “e” or i!=“i” or i!=“o” or i!=“u”):
print(i)
v=v+1
f.close()
print(v)
If content of file ‘‘para.txt’’ is
Arihant Publication

(a) 11 (b) 7 (c) 18 (d) 19

34. What will be the output of following code?


def Readfile():
i=open(“Employee.dat”,“rb+”)
x=i.readline()
while(x):
l=x.split(‘:’)
if(20000>=float(l[2])<=40000):
print(x)
x=i.readline()
(a) Display details of employees who are earning between 20000 and 40000 (both are
exclusive)
(b) Display details of employees who are earning between 20000 and 40000 (both are
SAMPLE PAPER 3

inclusive)
(c) Display details of employees who are earning between 20000 and 40000 (only 20000
inclusive)
(d) Display details of employees who are earning between 20000 and 40000 (only 40000
inclusive)

35. Evaluate the following expression and identify the correct answer.
15 − ( 2 + 7) * 5 + 3 * *2 * 6 − 4 + 2
(a) 18 (b) 20 (c) 22 (d) 35
CBSE Sample Paper Computer Science Class XII (Term I) 73

36. What will be the output of the following Python code snippet?
a = ‘hello’
for i in range(len(a)):
a[i].upper()
print(a)
(a) hello (b) HELLO
(c) Hello (d) Error

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


tup1=[(56, 89),(36,66),(88, 69)]
s = tup1.sort()
print(s)
(a) [(36, 66), (56, 89), (88, 69)]
(b) [(56, 89),(36,66),(88, 69)]
(c) Error because tuples are immutable
(d) Error because tuple has no sort attribute

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


def sum(*args):
‘‘‘Function returns the sum of all values’’’
r = 0
for i in args:
r += i
return r
print(sum._doc)
print(sum(5, 8, 3))
print(sum(2, 6, 3, 4, 1))
(a) None (b) 16 (c) None (d) Error
16 16 16
16

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


x=2
def test():
global x
x=x+1
test()
print(x)
(a) 2 (b) 1 (c) 0 (d) 3
SAMPLE PAPER 3

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


i = 0
while i < 10:
print(i)
i += 2
if i == 8:
break
else:
print(0)
74 CBSE Sample Paper Computer Science Class XII (Term I)

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


2 2 2 2
4 4 4 3
6 6 6 4
8 5
6
7
8

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


import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print(AR[K],end=“#”)
(a) 10#40#70# (b) 30#40#50#
(c) 50#60#70# (d) 40#50#70#

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


To=5
for K in range(O,To) :
if K%4==0:
print (K*4)
else:
print (K+3)
(a) 4 (b) 0 (c) 0 (d) 5
5 4 4 6
6 6 5 16
16 16 6
16

43. Find and write the output of the following Python code.
a=10
def call():
global a
a=15
b=20
print(a)
call()
SAMPLE PAPER 3

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

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


def DISPLAYWORDS():
c=O
file=open(‘STORY.TXT’,‘r’)
line = file.read()
word = line.split()
for w in word:
CBSE Sample Paper Computer Science Class XII (Term I) 75

if len(w)<4:
print(w)
file.close()
If the content of file “Story.txt” is
A computer is a machine that can be programmed to carry out
sequences of arithmetic or logical operations automatically.

(a) 9 (b) 10
(c) 19 (d) 11

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


a=[18,23,69,[73]]
b=list(a)
a[3][0]=110
a[1]=34
print(b)
(a) [18,34,69,[110]] (b) [18,23,69,[73]]
(c) [18,23,69,[110]] (d) [18,34,69,[73]]

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


list1=[9, 5, 3, 5, 4]
list1[1:2]=[7,8]
print(list1)
(a) [9,5, 3, 7, 8] (b) [9, 7, 8, 3, 5, 4]
(c) [9,[ 7, 8], 3, 5,4] (d) Error

47. What will be the output of the following Python code snippet?
dic1 = {1:‘One’, 2:‘Two’, 3:‘Three’}
del dic1[1]
dic1[1] = ‘Four’
del dic1[2]
print(len(dic1))
(a) 0
(b) 2
(c) 1
(d) Error as the key-value pair of 1:‘One’ is already deleted

48. What will be the output of following code?


f=open(“student.txt”,“r”)
str=f.read()
s=len(str)
SAMPLE PAPER 3

print (s)
f.close()
If the content of file “student.txt” is
Welcome to Arihant!
(a) 20 (b) 18 (c) 19 (d) 17
76 CBSE Sample Paper Computer Science Class XII (Term I)

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


t1=(2, 5,[1,2], 9)
t1[2][1]=11
print(t1)
(a) (2, 5, [11, 2], 9) (b) (2, 5, [1, 2], 11) (c) (2, 5, [1, 11], 9) (d) Error

Section C
(Case Study Based Questions)
This section consists of 6 questions (50 to 55). Attempt any 5 questions.
Riya write a program to open a file ‘status.txt’ to read each character and print the
occurrence of alphabets A and N.
def countAN():
f = open(“status.txt”, “r”)
a = 0
n = 0
while ____ : #line 1
l = f.readline( )
if not l :
____ #line 2
for i in ____ : #line 3
if (i = = ‘A’ or i = = ‘a’):
a = + 1
elif (____): #line 4
n = ____ #line 5
print (“A :”, a)
print (“N :”, n)
____ . close () #line 6

50. Which condition will be satisfy in while loop in line 1 as marked?


(a) Flag (b) False (c) True (d) None

51. Choose the correct option to fill the blank in line 2 as marked.
(a) continue (b) break (c) False (d) True

52. Choose the correct option to fill the blank in line 3 as marked.
(a) l (b) f (c) n (d) a

53. Which condition will be used in elif ?


(a) i == N or i == n (b) i == ‘N’ or i == ‘n’
SAMPLE PAPER 3

(c) i = ‘N’ or i = ‘n’ (d) i == ‘N’ and i == ‘n’

54. Which value will be assign to variable n in line 5 as marked?


(a) n − 1 (b) n + 1 (c) n (d) n * n

55. Identify the missing code to close the file in line 6 as marked.
(a) l (b) n (c) f (d) file

You might also like