Class 12 Computer Science Sample Paper Term 1 With Solutions Set C

Sample Papers for Class 12

Section A

1. Which is a way to convey a Python object into a character stream. 
(a) Pickling
(b) Unpickling
(c) dump() method
(d) load() method

Answer

A

2. Which character is used to create a new file in csv?
(a) r
(b) w
(c) r+
(d) x

Answer

D

3. Which path does not start with a leading forward slash?
(a) Relative
(b) Absolute
(c) Both (a) and (b)
(d) None of these

Answer

A

4. Which of the following operators in Python are used to determine whether a value is of a certain class or type?
(a) Identity operators
(b) Membership operators
(c) Comparison operators
(d) All of these

Answer

A

5. This function converts all uppercase letters in string to lowercase letters.
(a) upper()
(b) lower()
(c) isupper()
(d) islower()

Answer

B

6. List can be created to put the elements in
(a) []
(b) {}
(c) ()
(d) None of theseC

Answer

A

7. Which of the following are sequence of character data?
(a) Lists
(b) Tuples
(c) Strings
(d) Dictionaries

Answer

C

8. List, dictionary and sets are
(a) mutable
(b) immutable
(c) Both
(a) and (b)
(d) None of these

Answer

A

9. The process of converting a data type into another data type is known as ………… .
(a) expression
(b) operator
(c) type conversion
(d) comparison

Answer

C

10. In complex number a + ib, b represents as
(a) real part
(b) imaginary part
(c) special part
(d) None of these

Answer

B

11. To print all elements of tuple in reverse order using …………
(a) [: – 1]
(b) [: : – 1]
(c) [1 : : ]
(d) [: : 1]

Answer

B

12. Which function is used to convert string into tuple?
(a) string()
(b) tup()
(c) tuple()
(d) str_tuple()

Answer

C

13. Which statement is a sequence of more than one statements?
(a) Control statement
(b) Compound statement
(c) Single statement
(d) Sequence statement

Answer

B

14. Which of the following is a step-by-step process of solving a well defined computational problem?
(a) Algorithm
(b) Pseudocode
(c) Flowchart
(d) Decision table

Answer

A

15. ………… are drawn using certain special purpose symbols.
(a) Algorithm
(b) Pseudocode
(c) Flowchart
(d) Decision table

Answer

C

16. Which of the following function is a built-in function in Python?
(a) myFunc()
(b) test()
(c) def()
(d) print()

Answer

D

17. What will be the output of the following Python expression?
round(8.695)
(a) 8.6
(b) 9
(c) 8
(d) 8.7

Answer

B

18. What will be the output of the following Python code?
x = [‘AB’, ‘CD’]
for i in x:
i.lower()
print(x)
(a) [‘ab’, ‘cd’]
(b) [‘AB’, ‘CD’]
(c) [None, None]
(d) None of the mentioned

Answer

B

19. Suppose list1 is [2445,133,12454,123], what is max(list1)?
(a) 2445
(b) 133
(c) 12454
(d)123

Answer

C

20. What will be the output of the following Python code?
x = “abcdef”
i = “a”
while i in x:
print(‘i’, end = “ ”)
(a) No output
(b) i i i i i i …
(c) a a a a a a…
(d) a b c d e f

Answer

B

21. Which of the following operators has its associativity from right to left?
(a) +
(b) //
(c) %
(d) **

Answer

D

22. What will be the output of the following Python code?
>>> a=(l,2,(4,5))
>>> b=(l,2,(3,4))
>>> a<b
(a) False
(b) True
(c) Error, < operator is not valid for tuples.
(d) Error, < operator is valid for tuples but not if there are sub-tuples.

Answer

A

23. What will be the output of the following Python code snippet?
d1 = {“Neha”:86, “Yash”:92}
d2 = {“Neha”:86, “Yash”:88}
d1 > d2
(a) True
(b) False
(c) Error
(d) None

Answer

C

24. What will be the output of the following Python code? 
Dic1={}
Dic1[2]=85
Dic1[1]=[22,23,24]
print(Dic1[1][1])
(a) [22,23,24]
(b) 23
(c) 22
(d) Error

Answer

B

25. What will be the output of the following Python code?
dic1 = {0: ‘One’, 1: ‘Two’, 2: ‘Three’}
for x, y in dic1:
print(x, y)
(a) 0 1 2
(b) One Two Three
(c) 0 One 1 Two 2 Three
(d) Error

Answer

D

Section B

26. What is the output of the following code?
t1=(70, 56, ‘Hello’, 22, 2, ‘Hi’, ‘The’, ‘World’, 3)
print(t1 [2:4])
(a) (56, ‘Hello’)
(b) (‘Hello’, 22)
(c) (‘Hello’, 22,2)
(d) (56, ‘Hello’, 22)

Answer

B

27. Suppose the content of file ‘‘arihant.txt’’ is What will be the output of the following code?
myfile=open(“arihant.txt”,“r”)
s=myfile.read(10)
print(s)
s1=myfile.read(15)
print(s1)
myfile.close()
(a) Welcome to Welc
(b) Welcome to Arihant!
(c) Welcome to Arihant! Welc
(d) Welcome to Arihant

Answer

C

28. Identify the output of following code.
for i in range(4):
if i == 4:
break
else:
print(i)
else:
print(“Welcome”)

Class 12 Computer Science Sample Paper Term 1 With Solutions Set C
Answer

A

29. What will be the output of the following Python code snippet?
x = ‘abcd’
for i in range(len(x)):
print(x)
x = ‘a’
(a) a
(b) abcd abcd abcd abcd
(c) a a a a
(d) None of the mentioned

Answer

D

30. Identify the output of the following Python statement.
x=0
for i in range (1, 12, 3):
x+=i+3
print(x)
(a) 31
(b) 32
(c) 33
(d) 34

Answer

D

31. Identify the output of the following Python code.
def test(val):
val[1]=20
a=[2, 3, 4]
test(a)
print(a)
(a) [2, 20]
(b) [20, 3]
(c) [2, 3, 20, 4]
(d) [2, 20, 4]

Answer

D

32. Sohan is a student of Class 12th. He got an assignment on Python language, in which one question is Write a tuple test = (3, 4, 8, 11, 2) on a binary file hello.bin. Consider the following code written by him.
import pickle
test=(3, 4, 8, 11, 2)
file=open(“hello.bin”, “wb”)
pickle. —————————— # line 1
file.close()
Identify the missing code in line 1.
(a) dump (file, test)
(b) dump (test, file)
(c) write (test, file)
(d) load (file, test)

Answer

B

33. Suppose the content of file “vowel.txt” is What will be the output of following code?
def count():
vow=0
f=open(“vowel.text”, “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”):
vow=vow+1
f.close()
(a) 60
(b) 58
(c) 59
(d) 54

Answer

C

34. Find the output of the following code.
def Func (a = 1, b = 2):
a = a + b
b + = 1
print (a, b)
Func (b = 4, a = 5)
(a) 9 5
(b) 4 5
(c) 4 9
(d) Error

Answer

A

35. Evaluate the following expression and identify the correct answer.
2*3//4 + 4//4 + 8 − 2 + 5//8
(a) 14
(b) 8
(c) 10
(d) 12

Answer

B

36. What will be the output of the following Python code?
def power(a, b=4):
r = 1
for i in range(b):
r = r * a
return r
print power(5)
print power(5, 5)
(a) 625
3125
(b) 625
625
(c) 3125
3125
(d) Error

Answer

A

37. What will be the output of the following Python code?
def printMax(a, b):
if a> b:
print(a, ‘is maximum’)
elif a == b:
print(a, ‘is equal to’, b)
else:
print(b, ‘is maximum’)
printMax(33,94)
(a) 33 is maximum
(b) 94
(c) 94 is maximum
(d) Error

Answer

C

38. What will be the output of following code?
import random
AR=[20,30,40,50,60,70]
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print(AR[K],end=“#”)
(a) 10#40#70#
(b) 30#40#50#
(c) 50#60#70#
(d) 40#50#70#

Answer

B

39. What will be the output of the following Python code?
list1 = [11, 12, 13, 14, 15]
for i in range(1, 5):
list1[i−1] = list1[i]
for i in range(O, 5):
print(list1[i] ,end = “ ”)
(a) 15 15 1112 13
(b) 15 1112 13 14
(c) 12 13 14 15 11
(d) 12 13 14 15 15

Answer

D

40. What will be the output of the following Python code?
myFile = open(“story.txt”, “wb”)
print (“Name of the file:”, myFile.name)
myFile.flush()
myFile.close()
(a) Compilation error
(b) Runtime error
(c) No output
(d) Flushes the file when closing them

Answer

D

41. Find the output of the following code from given options.
def calcresult ():
i=9
while i > 1 :
if (i% 2 = = 0):
x = i% 2
i = i − 1
else:
i = i − 2
x = i
print (x * *2)

Class 12 Computer Science Sample Paper Term 1 With Solutions Set C
Answer

D

42. Suppose the content of file ‘‘para.txt’’ is What will be the output of the following code?
file = open(“para.txt”)
val = file.read()
print(len(val))
file.close()
(a) 44
(b) 39
(c) 45
(d) Error

Answer

A

43. What will be the output of following code?
def mean (* args):
total = 0.0
for v in args :
total + = v
return (total / len (args))
mean (* [1, 2, 3, 4])
(a) 2
(b) 3
(c) 2.5
(d) 3.5

Answer

C

44. A text file “Quotes.txt” has the following data written in it.
What will be the output of the following code?
def COUNT ( ):
s=open (“Quotes.txt”, “r”)
f=s.read( )
z=f.split( )
count=0
for i in z:
count=count+1
print (count)
(a) 14
(b) 15
(c) 16
(d) 29

Answer

C

45. What will be the output of the following Python code snippet?
a={}
a[1] = 1
a[‘1’] = 2
a[1]=a[1]+1
count = 0
for i in a:
count+= a[i]
print(count)
(a) 1
(b) 2
(c) 4
(d) Error, the keys cannot be a mixture of letters and numbers

Answer

C

46. What will be the output of the following Python code?
i=0
def change(i):
i=i+1
return i
change(1)
print(i)
(a) 1
(b) Nothing is displayed
(c) 0
(d) Error

Answer

C

47. What is the output of the code?
z = 100
def f():
global z
print(‘z is:’, z)
z=50
print(‘New value of global z is:’, z)
f()
print(‘Value of z is:’, z)
(a) z is : 100
New value of global z is: 100
Value of z is : 100
(b) z is : 100
New value of global z is: 100
Value of z is : 50
(c) z is : 100
New value of global z is: 50
Value of z is : 100
(d) z is : 100
New value of global z is: 50
Value of z is : 50

Answer

D

48. Suppose the content of text file ‘‘para.txt‘’ is What will be the data type of s?
file=open (“para.txt”, “r”)
s=file.read()
file.close()
(a) string
(b) list
(c) tuple
(d) sets

Answer

A

49. What will be the output of the following code?
dic1= {‘One’ :1, ‘Two’ : 2, ‘Three’:3}
s=(list(dic1.values())
print(s)
(a) [‘One’, ‘Two’, ‘Three’]
(b) [1, 2, 3]
(c) [3]
(d) [‘One’ : 1, ‘Two’ : 2, ‘Three’ : 3]

Answer

B

Section C

Case Study Based Questions

def makenew (mystr):
newstr = “ ”
count = 0
for i in ____ : # line 1
if count % 2 ! = 0 :
newstr = newstr + str (____) # line 2
else:
if ____ (i): # line 3
newstr = newstr + upper(i)
else:
newstr = newstr + ____ # line 4
count + = 1
newstr = ____ + mystr[: 1] # line 5
print (“The new string is:”, newstr)
____ (“sTUdeNT”) # line 6

50. Choose the correct option to fill up the blank in line 1 as marked.
(a) mystr
(b) newstr
(c) mystr +1
(d) mystr −1

Answer

A

51. Choose the correct option to fill up the blank in line 2 as marked.
(a) i
(b) count
(c) i + 1
(d) count +1

Answer

B

52. Choose the correct option to fill up the blank in line 3 as marked.
(a) lower
(b) upper
(c) islower
(d) isupper

Answer

C

53. Choose the correct option to fill up the blank in line 4 as marked.
(a) 1
(b) i * 2
(c) i/2
(d) i

Answer

D

54. Choose the correct option to fill up the blank in line 5 as marked.
(a) newstr
(b) count
(c) i
(d) str

Answer

A

55. Choose the correct option to fill up the blank in line 6 as marked.
(a) newstr
(b) str
(c) makenew
(d) mystr

Answer

C