0% found this document useful (0 votes)
182 views8 pages

Sample Paper 5: Computer Science

This document is a sample paper for the CBSE Class XII Computer Science exam with 3 sections. Section A has 25 multiple choice questions to attempt 20. Section B has 24 multiple choice questions to attempt 20. Section C has 6 case study based questions to attempt 5. The paper is divided into sections with instructions for each section, has questions ranging in topics of computer science, and provides the maximum marks and time allowed.

Uploaded by

Scary Peeps
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)
182 views8 pages

Sample Paper 5: Computer Science

This document is a sample paper for the CBSE Class XII Computer Science exam with 3 sections. Section A has 25 multiple choice questions to attempt 20. Section B has 24 multiple choice questions to attempt 20. Section C has 6 case study based questions to attempt 5. The paper is divided into sections with instructions for each section, has questions ranging in topics of computer science, and provides the maximum marks and time allowed.

Uploaded by

Scary Peeps
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/ 8

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

SAMPLE PAPER 5
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. Each key value pair in a dictionary is separated by a .............


(a) : (b) ; (c) – (d) =

2. Dictionaries are also called


(a) mappings (b) hashes (c) associative arrays (d) All of these

3. This method is used to delete key and respective value from dictionary.
(a) del() (b) delete() (c) pop() (d) remove()

4. Which of the following errors will result the abnormal termination of program?
(a) Run-time (b) Compile-time (c) Semantic (d) Syntax
SAMPLE PAPER 5

5. Which exception classes raised when a generated error does not fall into any category?
(a) RuntimeError (b) TypeError (c) KeyError (d) AttributeError

6. What is the output of following code?


a=10
b=2
print(a+10*2+b)
(a) 32 (b) 40 (c) 42 (d) 30
CBSE Sample Paper Computer Science Class XII (Term I) 93

7. Identify the keyword from the following used in Python.


while, value, file, Lvalue, Rvalue
(a) value (b) file (c) while (d) Lvalue

8. User can also add elements into an empty dictionary by


(a) dictionary_name=value (b) dictionary_name[key]=value
(c) dictionary_name(key)=value (d) dictionary_name{key}=value

9. Observe the output.


c=‘7’+2
print(c)
(a) 9 (b) 72 (c) 27 (d) Error

10. Find the output of the following code.


>>>complex (4, 8)
(a) 4+8j (b) 4j+8 (c) 4j+8j (d) Error

11. Which access mode can be used for opening a file for both appending and reading in a
text file?
(a) a (b) a+ (c) r (d) r+

12. Which method specifies 6 characters the string should return?


(a) read(5+1) (b) readline(6) (c) readlines(6) (d) read(6)

13. To display elements from beginning to a range use


(a) [: index] (b) [index :] (c) [index : 0] (d) [: : index]

14. Which one of the following has the highest precedence in the expression?
(a) Exponential (b) Addition (c) Multiplication (d) Parenthesis

15. Which are the two built-in functions to read a line of text from standard input, which
by default comes from the keyboard?
(a) raw_input() and input() (b) input() and scan()
(c) scan() and scanner() (d) scanner()

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


for i in range(1, int(3.0)):
print(i)
(a) 1 (b) 0 (c) 1 (d) 0
2 1 2 1
3 2

17. What will be the output of the following Python code snippet?
d1 = {“Siya”:86, “Naman”:75}
SAMPLE PAPER 5

d2 = {“Siya”:99, “Naman”:75}
d1 == d2
(a) True (b) False (c) None (d) Error

18. To open a file ‘‘D:\Story.txt’’ for appending data, we use ………


(a) f = open(“D:\Story.txt”, “a”)
(b) f = open(“D:\Story.txt”, “rw”)
(c) f = open(file = “D:\Story.txt”, “w”)
(d) f = open(file = “D:\Story.txt”, “w+”)
94 CBSE Sample Paper Computer Science Class XII (Term I)

19. Which of the following expressions results in an error?


(a) int(1101) (b) int(‘1101’,23)
(c) int(1101,2) (d) int(‘1101’)

20. Is the following Python code valid?


>>>tup1=(56, 25,36, 15)
>>> result=tup1.update(4,)
(a) Yes, tup1=(56, 25, 36, 15,4) and result=(56, 25, 36, 15,4)
(b) Yes, tup1=(56, 25, 36,15) and result=(56, 25, 36, 15,4)
(c) No, because tuples are immutable
(d) No, because wrong syntax for update() method

21. Which of the following is an invalid variable name?


(a) Add_num_3 (b) 1st_number (c) test (d) _num2

22. Observe the following code and identify the type of file.
File=open(“Mydata”, “a”)
File.write(“ABC”)
File.close()
(a) Binary file (b) CSV file
(c) Text file (d) None of these

23. Consider the declaration a=[2, 3, ‘Hello’, 23.0]. Which of the following represents the
data type of ‘a’?
(a) string (b) tuple (c) dictionary (d) list

24. Find the output from the following code.


list1=[2, 5, 4, 7, 7, 7, 8, 90]
del list1[2 : 4]
print(list1)
(a) [2, 5, 7, 7, 8, 90] (b) [5, 7, 7, 7, 8, 90] (c) [2, 5, 4, 8, 90] (d) Error

25. What is the output of following code?


>>> dic={‘A’ : ‘One’, ‘B’ : ‘Two’, ‘C’ : ‘Three’}
>>>dic.keys()
(a) [‘B’, ‘C’, ‘A’] (b) dict_keys [(‘B’, ‘C’, ‘A’)]
(c) dict_keys ([‘B’, ‘C’, ‘A’]) (d) keys ([‘B’, ‘C’, ‘A’])

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

26. What will be the output of following code?


l=[]
for i in range (20,40):
if (i% 7==0) and (i% 5 ! =0) :
l.append (str(i))
print(‘,’.join (l))
(a) 21 (b) 21 (c) 35 (d) Error
28 28
35
CBSE Sample Paper Computer Science Class XII (Term I) 95

27. What is the output of following code?


def str (*a):
for i in a:
print(i)
str (* [“Hello”])
(a) Hello (b) ‘‘Hello’’ (c) ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ (d) Error

28. Identify the output of the following Python statement.


x = [[1, 2, 3, 4], [5, 6, 7, 8]]
y = x [0] [2]
print(y)
(a) 3 (b) 4 (c) 6 (d) 7

29. What is the output of following code?


def fun(Hello, n=2):
print(Hello * n)
fun(‘World’)
(a) World (b) WorldWorld (c) HelloHello (d) HelloWorld

30. What is the output of following code?


a=10
def value(i):
c=0
c=a+i
return c
value(5)
(a) 5 (b) 10 (c) 15 (d) 105

31. What is the output of following code?


str1=“ARIHANT”
final=“ ”
for i in range(len(str1)):
if(i%2==0):
final=final+str1[i]
print(final)
(a) RHNT (b) AIAT (c) ARIH (d) HANT

32. Siya is trying to write a list l1=[2, 5, 4, 3] on a binary file ‘hello.bin’. Consider the
following code written by her.
import pickle
l1=[2, 5, 4, 3]
f=open (“hello.bin”,‘wb’)
SAMPLE PAPER 5

pickle. —————— # Statement 1


f.close()
Identify the missing code in Statement 1.
(a) dump(f,l1) (b) dump(l1,f) (c) write(l1,f) (d) write(f,l1)

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


x = “123456”
i = “a”
while i in x:
96 CBSE Sample Paper Computer Science Class XII (Term I)

x = x[:− 1]
print(i, end = “”)
(a) i i i i i i (b) a a a a a a
(c) a a a a a (d) None of the mentioned

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


def test(): a=25
a=5
test()
a
(a) Error (b) 25 (c) Junk value (d) 5

35. What is the output of the following Python code?


a = 20
def test(a):
print(a)
a=5
test(a)
print(a)
(a) 20 (b) 20 (c) 20 (d) Error
20 5 40

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


str1=“H#E#L#L#O”
b=list(str1.split( “#”,2))
print(b)
(a) [‘H’, ‘E’, ‘L#L#O’] (b) [‘H’, ‘E’, ‘L’, ‘L’, ‘O’]
(c) [‘H#E’, ‘L#L#O‘] (d) Error

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


myfile = None
for i in range (4):
with open(“data.txt”, “w”) as my file
if i > 3:
break
print(myfile.closed)
(a) True (b) False (c) None (d) Error

38. Evaluate the following expression and identify the correct answer.
25 + ( 6 − 4) * 2 + 4 / /3 * 4 − 1
(a) 32 (b) 42 (c) 22 (d) 33

39. What is the output of following code?


SAMPLE PAPER 5

def work (a=10, b=20) :


s=a+b
print(s)
return
x=23
y=62
work(x, y)
(a) 30 (b) 85 (c) 33 (d) 82
CBSE Sample Paper Computer Science Class XII (Term I) 97

40. What will be the output of following code?


import random
X=3
N=random.randint(1, X)
for i in range(N):
print (i, ‘#’, i+1)
(a) 3#4 (b) 4#5 (c) 5#6 (d) 2#3

41. Suppose the content of file ‘‘para.txt’’ is


Welcome to study corner!
How are you students?
What are you doing now?

What will be the output of following code?


def count( ):
f=open (“para.txt”, “r”)
lines=0
l=f.readlines()
for i in l:
if i[0] ! = ‘W’ :
lines+=1
print(lines)
(a) 3 (b) 1 (c) 2 (d) Error

42. Consider the following code :


f=open(“Story”, “w+”)
f.write(“abcdefgh@#”)
f.seek(4, 3)
print(f.read(3))
What will be the correct output?
(a) def (b) cde (c) efg (d) fgh

43. What is the output of following code?


list1=[4, 3, 7, 6, 4, 9, 5, 0, 3, 2]
l1=list1[1:10:3]
print(l1)
(a) [3, 7, 6] (b) [3, 4, 0] (c) [3, 6, 9] (d) [7, 9,2]

44. What is the output of following code?


dic1={11, 12, 13}
for i in dic1:
SAMPLE PAPER 5

print(i)
(a) 11 12 13 (b) {11, 12, 13} {11, 12, 13} {11, 12, 13}
(c) Error (d) None

45. What is the output of following code?


x=15
globals() [‘x’]=63
print(x)
(a) 15 (b) 78 (c) 63 (d) Error
98 CBSE Sample Paper Computer Science Class XII (Term I)

46. What will be the data type of s?


myfile=open(‘arihant’, ‘r’)
s=myfile.read()
print(s)
myfile.close()
(a) string (b) list (c) dictionary (d) tuple

47. Observe the following code:


def fun(num):
—————— # Statement 1
print(fun(25))
Choose the correct option to fill up the blank in Statement 1.
(a) return 0 (b) return 1
(c) return num (d) None of these

48. What is the output of following code?


t1=(3, 4, (6, 1), 7)
t=t1*2
print(t)
(a) (6, 8, (12, 2), 14) (b) (3, 4, (6, 1), 7, 3, 4, (6, 1), 7)
(c) (3, 4, (6, 1), (6, 1), 7) (d) Error

49. Identify the line which has an error.


i=0 # Line 1
while(i<25) # Line 2
print(“Hello”) # Line 3
i=i+1 # Line 4
(a) Line 1 (b) Line 2 (c) Line 3 (d) Line 4

Section C
(Case Study Based Questions)
This section consists of 6 questions (50 to 55). Attempt any 5 questions.
Riya wrote a program to search any string in text file “school”. Help her to execute the
program successfully.
def check() :
datafile = open (_______) #Line 2
found = input(“Enter any string to be searched : ”)
f = False
for line in _______ : #Line 5
SAMPLE PAPER 5

if found in line :
f = _______ #Line 7
_______ #Line 8
return f
f = check ()
if(f = = _______) : #Line 11
print (“True”)
else :
print (_______) #Line 14
CBSE Sample Paper Computer Science Class XII (Term I) 99

50. Riya should open which file to search any string?


(a) school.bin (b) school.txt (c) school.bat (d) school.csv

51. Choose the correct option to fill up the blank in Line 5.


(a) f (b) found (c) datafile (d) check()

52. Which value will be assign to f in Line 7?


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

53. Choose the correct option to fill up the blank in Line 8.


(a) break (b) continue (c) goto (d) label

54. Choose the correct option to fill up the blank in Line 11.
(a) 0 (b) 1 (c) False (d) True

55. Which variable or value will be print by last line?


(a) “True” (b) “False” (c) True (d) False

SAMPLE PAPER 5

You might also like