[go: up one dir, main page]

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

Sample Paper 1: Computer Science

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

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

SAMPLE PAPER 1
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. …… is a logical instructions, which Python interpreter can read and execute.


(a) Expression (b) Statement (c) Comment (d) Identation

2. Which comments start with # symbol?


(a) Double line (b) Multi-line (c) Single line (d) All of these

3. Which data type contains only numeric value in Python?


(a) Numbers (b) Strings (c) Lists (d) Tuples

4. Index of ……… refers to first element.


(a) 1 (b) − 1 (c) 0 (d) n+1
SAMPLE PAPER 1

5. This function is used to calculate total occurrence of given elements of list.


(a) len() (b) sum() (c) count() (d) extend()

6. Which of the following is a collection of Python objects separated by commas


represent as (,)?
(a) List (b) Tuple (c) Dictionary (d) String

7. ……… a tuple is a technique to access an individual element of that tuple.


(a) Comparing (b) Accessing (c) Concatenation (d) Traversing
44 CBSE Sample Paper Computer Science Class XII (Term I)

8. You can repeat the elements of the tuple using which operator?
(a) * (b) + (c) ** (d) %

9. …… are used to pass the value of a variable to a function.


(a) Arguments (b) Parentheses (c) Classes (d) Objects

10. non-void functions are also known as


(a) non functions (b) valid functions (c) fruitful functions (d) invalid functions

11. A variable declared in a block is local to that block and is known as


(a) global variable (b) local variable (c) multi variable (d) single variable

12. What is the mean of L in LEGB rule for scope resolution?


(a) Local (b) Last (c) Least (d) Library

13. In which file, no delimiters are used for line and no translations occur?
(a) Text file (b) Binary file (c) CSV file (d) None of these

14. Which attribute is used to return access mode with that file was opened?
(a) mode.file (b) mode.file.name (c) file.mode (d) file.mode.type

15. ……… method takes a string and writes it in the file.


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

16. For readline(), a line is terminated by


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

17. Which of the following is true regarding lists in Python?


(a) Lists are immutable.
(b) Size of the lists must be specified before its initialisation.
(c) Elements of lists are stored in contagious memory location.
(d) size(list1) command is used to find the size of lists.

18. Suppose list1 is [56, 89, 75, 65, 99], what is the output of list1 [− 2]?
(a) Error (b) 75 (c) 99 (d) 65

19. Which one of the following is correct?


(a) In Python, a dictionary can have two same keys with different values.
(b) In Python, a dictionary can have two same values with different keys.
(c) In Python, a dictionary can have two same keys or same values but cannot have two
same keys-value pair.
(d) In Python, a dictionary can neither have two same keys nor two same values.

20. dl={“abc”:5,“def”:6,“ghi”:7}
SAMPLE PAPER 1

print(d1[0])
What will be the output of above Python code?
(a) abc (b) 5 (c) {“abc”:5} (d) Error

21. Which of these about a dictionary is false?


(a) The values of a dictionary can be accessed using keys.
(b) The keys of a dictionary can be accessed using values.
(c) Dictionaries are not ordered.
(d) Dictionaries are mutable.
CBSE Sample Paper Computer Science Class XII (Term I) 45

22. str1=“659.31”
print(“str1”)
What will be the output of above Python code?
(a) 1 (b) 6/4 (c) 1.5 (d) str1

23. Which of the following will result in an error?


str1=“python”
(a) print(str1[3]) (b) str1[1]=“xyz” (c) print(str1[1:5]) (d) Both (b) and (c)

24. Which of the following is false?


(a) String is immutable.
(b) capitalize() function in string is used to return a string by converting the whole given
string into uppercase.
(c) lower() function in string is used to return a string by converting the whole given string
into lowercase.
(d) None of the above

25. What will be the following Python code return?


str1=“Stack of books”
print(len(str1))
(a) 13 (b) 14 (c) 15 (d) 16

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

26. What is the output of following code?


L = [34, 89]
print(L*3)
(a) Syntax error (b) [34, 89, 34, 89, 34, 89] (c) [102, 267] (d) [37, 92]

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


Hello…How are you?
Hi…I am fine.
What are you doing now?
Hmm… nothing special.
What will be the output of following code?
myfile = open(“para.txt”,“r”)
s = myfile.read(15)
print(s)
myfile.close()
SAMPLE PAPER 1

(a) Hello…How are (b) Hello…How are you?


(c) Hello…How are yo (d) Hello…How are you?
Hi
28. Identify the output of the following Python statement.
def test(a,b):
s = a+b*2
print(s)
test(12,5)
(a) 34 (b) 17 (c) 22 (d) 29
46 CBSE Sample Paper Computer Science Class XII (Term I)

29. How many times will the given loop iterate?


i = 0
while(i<25):
print(“Python”)
i = i + 1
(a) 24 (b) 25 (c) 26 (d) None of these

30 Find the output of the following code.


i=1
while (i<15):
print(i)
i = i*2
(a) 1 (b) 2 (c) 1 (d) 2
2 4 2 4
4 6 4 8
6 8 8
8 10
10 12
12 14
14

31. Identify the output of the following Python statement.


list1=[4,3,7,9,15,0,3,2]
s = list1[2:5]
print(s)
(a) [7,9,15,0] (b) [3,7,9,15] (c) [7,9,15] (d) [7,9,15,0,3]

32. Observe the following code and answer the question that follow.
File = open(“Mydata”, “a”)
_______#Blank
File. close()
Fill in the blank with statement to write “ABC” in the file “Mydata”.
(a) File.write() (b) File.write(ABC) (c) write(ABC) (d) File.write(“ABC”)

33. Observe the code.


def insert():
import pickle
file1 = open(‘college.txt’.‘a’)
while True:
y = input(“Enter something”)
pickle.dump(y,file1)
SAMPLE PAPER 1

ans = input(“Want to enter more data Y/N”)


if(ans.upper()= = ‘N’):
_______ #Line1
file1.close()
insert()
Above code is used to insert element or data into an existing text file.
Write appropriate jump statement from the following to insert the element and
terminate the program whenever is need.
(a) jump (b) continue (c) goto (d) break
CBSE Sample Paper Computer Science Class XII (Term I) 47

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


a = 3
b = 4
c = a**b+5
print(c)
(a) 17 (b) 86 (c) 14 (d) None of these

35. Evaluate the following expression, when a = 10, b = 5 and identify the correct answer.
x = a*3//4+b//4+4−a+5//6
(a) 12 (b) 4 (c) 2 (d) 6

36. Identify the output of following code.


List1=[1, 2, 3, 7, 9]
L=List1.pop(9)
print(L)
(a) Syntax error (b) 9 (c) [1, 2, 3, 7] (d) None of these

37. What possible output(s) are expected to be displayed on screen at the time of execution
of the program from the following code?
import random
ar = [2, 3, 4, 5, 6, 7]
minn = random.randint (1, 3)
maxn = random.randint (2, 4)
for i in range (minn, maxn + 1):
print (ar [i], end = ‘#’)
(a) 3# 4# 5# (b) 5# 6# 7# (c) 1# 4# 7# (d) 4# 5# 7#

38. What is the output of the following code?


def compute(a,b):
if a > b:
smaller = b
else:
smaller = a
for i in range (1, smaller+1):
if((a%i= = 0) and (b% i ==0)):
val = i
return val
compute(54,24)
(a) 216 (b) 108 (c) 6 (d) 3

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


def test(a):
SAMPLE PAPER 1

for i in a:
print(i)
test((3,4,5,3,7))
(a) 3 (b) 3, 4, 5, 3, 7 (c) 3 4 5 3 7 (d) None of these
4
5
3
7
48 CBSE Sample Paper Computer Science Class XII (Term I)

40. Find the output of following code.


def display (num) :
num.append ([27])
return (num[1], num[2], num[3])
list1= [6, 12, 27]
n1, n2, n3 = display (list1)
print (list1)
(a) [6,12,27] (b) [6,12, 27, [27]] (c) [[27], 6, 12, 27] (d) [6, 12, [27], 27]

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


x = [‘ab’, ‘cd’]
for i in x:
i.upper()
print(x)
(a) [‘ab‘, ‘cd’] (b) [‘AB’, ‘CD’]
(c) [None, None] (d) None of the mentioned

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


Hello…How are you?
Hi…I am fine.
What are you doing now?
Hmm…nothing special.

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] = = ‘H’:
lines+=1
print(lines)
(a) 4 (b) 2 (c) 3 (d) None of these

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


If life were predictable it would cease to be life, and be without flavor.

What will be the output of following code?


file = open(“para.txt”, “r”)
a = file.read()
b = a.count(‘life’)
print(b)
SAMPLE PAPER 1

file.close()
(a) 2 (b) 3 (c) 4 (d) 5

44. Observe the code and identify the output.


x =5
def func2 ():
x =3
global x
x =x + 1
CBSE Sample Paper Computer Science Class XII (Term I) 49

print (x)
print (x)
(a) 5 (b) 5 (c) 6 (d) 6
3 4 4 3

45. The content of file ‘arihant.txt’ is as follows:


Welcome to Arihant!
Welcome to your one-step solutions for all your study, practice and assessment
needs for various competitive & recruitment examinations and school segment.

What will be the output of following code?


myfile = open(‘arihant.txt’,‘r’)
s = myfile.read(15)
print(s)
myfile.close()
(a) Welcome to Arihan (b) Welcome to Arih
(c) Welcome to Arihant (d) Welcome to Arihant!

46. Observe the code given below and find the output, if the content of file ‘‘student.txt’’ is
S01, Rahul Verma, First division
S02, Reetesh Deshmukh, First division
S03, Aaditya Mishra, Second division
S04, Aradhaya Sinha, Third division
S05, Manish Sharma,Third division

What will be the output of following code?


f = open(‘student.txt’,‘r’)
s = f.readlines()
lcount = len(s)
print(lcount)
f.close()
(a) 4 (b) 3 (c) 2 (d) 5

47. Consider the following directory structure.


ABC

Hello

Mode. png

Identify the root directory.


SAMPLE PAPER 1

(a) Hello (b) ABC


(c) Mode.png (d) None of these

48. Assume the content of text file ‘‘student. txt’’ is


Sumita Sharma
Abhinav
Naman Kumar
Neha Verma
Khushi Sinha
50 CBSE Sample Paper Computer Science Class XII (Term I)

What will be the datatype of s?


file = open(“student.txt”)
s = file.readlines()
file.close()
(a) list (b) string (c) tuple (d) dictionary

49. What will be the output of following code?


sub = “PYTHON”
for i in sub:
print(i, ‘ ’, end = “ ”)
(a) P (b) PYTHON (c) P Y T H O N (d) P, Y, T, H, O, N
Y
T
H
O
N

Section C
(Case Study Based Questions)
This section consists of 6 questions (50 to 55). Attempt any 5 questions.
Shreya write a program to check if elements of a list are same or not, it read from front or
back.
a = [1, 2, 3, 3, 2, 1]
i = ______ #line 1
mid = (len (a))/2
same = True
while ______ #line 2
if a[i] ! = ______ : #line 3
print (“No”)
same = False
______ #line 4
______ #line 5
if same = = ______ : #line 6
print (“Yes”)

50. Which value will be assign to variable i in line 1 as marked ?


(a) 1 (b) 0 (c) True (d) False
51. Choose the correct option to fill up the blank in line 2 as marked.
(a) i == mid: (b) i > mid: (c) i < mid: (d) i < = mid:
SAMPLE PAPER 1

52. Choose the correct option to fill up the blank in line 3 as marked.
(a) a[len(a)] (b) a[len(a) − i] (c) a[len(a) − 1] (d) a[len(a)− i − 1]

53. Choose the correct option to fill up the blank in line 4 as marked.
(a) continue (b) label (c) goto (d) break

54. Choose the correct option to fill up the blank in line 5 as marked.
(a) i = i + 1 (b) i = i − 1 (c) i = i * i (d) i = i + mid
55. What value will be equal to ‘‘same’’ in if condition in line 6 as marked?
(a) False (b) True (c) 0 (d) 1

You might also like