Unseen Passage

For Class 4 to Class 12

Class 12 Computer Science Sample Paper Term 1 Set B

Section A

1. What is the maximum length of an identifier? 
(a) 56
(b) 256
(c) 128
(d) Any length

Answer

D

2. Which of the following is not a bitwise operator?
(a) &
(b) ^
(c) !
(d) /

Answer

C

3. What is the output of following code?
a=3+float(8)/int(3.0)
print(a)
(a) 2.66
(b) 5.66
(c) 3.66
(d) Error

Answer

B

4. What is the output of following code?
list1=list()
print(list1)
(a) ()
(b) (,)
(c) []
(d) Error

Answer

C

5. To add a new element to the list, which of the following statement is used?
(a) list1.add(x)
(b) list1.addLast(x)
(c) list1.append(x)
(d) list1.addEnd(x)

Answer

C

6. Which of the following code does not contain any error?
(a) round()
(b) round (53.7)
(c) round (53.7345, 3, 2)
(d) round (3454.2, 1, 1)

Answer

B

7. Correct syntax of readlines () is
(a) file.readlines()
(b) file.readlines[]
(c) file.readlines(n)
(d) readlines(file)

Answer

A

8. Which function is used to read single line from file?
(a) readline()
(b) readlines()
(c) readstatement()
(d) readfullline()

Answer

A

9. Which of the following is the mode for both writing and reading in binary format in file?
(a) wb+
(b) w
(c) wb
(d) w+

Answer

A

10. Which of the following is false about “import modulename” form of import?
(a) The namespace of imported module becomes part of importing module.
(b) This form of import prevents name clash.
(c) The namespace of imported module becomes available to importing module.
(d) The identifiers in module are accessed as : modulename.identifier.

Answer

A

11. What will be the output of the following Python function?
all(0, 6, 3.2)
(a) True
(b) False
(c) Error
(d) 0

Answer

C

12. How many keyword arguments can be passed to a function in a single function call?
(a) Zero
(b) One
(c) Zero or more
(d) One or more

Answer

C

13. If return statement is not used inside the function, the function will return
(a) None
(b) 0
(c) Null
(d) Arbitrary value

Answer

A

14. ……… are the arguments passed to a function in correct positional order.
(a) Required arguments
(b) Keyword arguments
(c) Default arguments
(d) Variable-length arguments

Answer

A

15. What is the output?
Num=2+3−1*3
(a) 12
(b) 2
(c) 4
(d) 3

Answer

B

16. Choose the correct for loop statement to be repeated 50 times.
(a) for in range(50):
(b) for i in range(50):
(c) for i in range(0,50,1) :
(d) for i in range (1,50,1) :

Answer

C

17. In ………, we put values together into a new tuple.
(a) unpacking
(b) packing
(c) replication
(d) slicing

Answer

B

18. If str1=“Python Program”, then what is the output of print(str1[2:12:3])?
(a) thon
(b) toPr
(c) tnrr
(d) trrm

Answer

C

19. Which of the following is a value passed to the function during the function call?
(a) Argument
(b) Parameter
(c) Keyword
(d) Statement

Answer

A

20. Which of the following is correct code to remove the file “story.txt”?
(a) remove(“story.txt”)
(b) remove(story.txt)
(c) os.remove(“story.txt”)
(d) os.remove=“story.txt”

Answer

C

21. What is the output?
val=‘8’+2
print(val)
(a) 82
(b) 88
(c) 22
(d) Error

Answer

D

22. Which of the following is a logical error?
(a) Leaving out a keyword
(b) Division by zero
(c) Using the wrong variable name
(d) Incorrect indentation

Answer

C

23. What will be the output of following code?
a, b =12, 10
c=a//b+4*2
d=c−10
print(d)
(a) 1
(b) −1
(c) 0
(d) 2

Answer

B

24. Which type of statement specifies the order in which actions are executed?
(a) Null statement
(b) Control statement
(c) Compound statement
(d) Simple statement

Answer

B

25. What will be the output?
list1=[2, 5, 4, 7, 9, 8]
list2=list1+10
print(list2)
(a) [2, 5, 4, 7, 9, 8, 10]
(b) [10, 2, 5, 4, 7, 9, 8]
(c) [2, 5, 4, 10, 7, 9, 8]
(d) Error

Answer

D

Section B

26. What is the output of following code?
tup1=(3, 2, 5, 9)
tup2=(3, 8, 7)
t=tup1*tup2
print(t)
(a) (3, 2, 5, 9, 3, 8, 7)
(b) (3, 8, 7, 3, 2, 5, 9)
(c) (3, 2, 3, 8, 7, 5, 9)
(d) Error

Answer

D

27. What will be the output of following code?
def Func(x):
print(x+2)
x = 4
x = − 5
Func(37)
(a) 37
(b) 41
(c) 39
(d) 32

Answer

C

28. Evaluate the following expression and identify the correct answer.
A = 5 * 5 + 4 / / 5 + 15 − 9 / / 2 +10
(a) 36
(b) 46
(c) 47
(d) 56

Answer

B

29. What is the output of following code?
a = 5
def MyFunc() :
global a
a = a + 3
MyFunc()
print(a)
(a) 3
(b) 8
(c) 5
(d) Error

Answer

C

30. What is the output of the following code?
a = 70
while(a>50):
print(a)
a = a − 30
(a) 40
(b) 30
(c) 50
(d) 70

Answer

D

31. Suppose the content of file “story.txt” is What is the output of following code?
myfile=open (“story.txt”, ‘r’)
s=myfile.read(12)
print(s)
myfile.close()
(a) Honesty is
(b) Honesty is the
(c) Honesty is t
(d) Error

Answer

C

32. What will be the output of the following Python code?
a=(i for i in range(5))
for i in a:
print(i)
for i in a:
print(i)

Class 12 Computer Science Sample Paper Term 1 Set B
Answer

A

33. What will be the output of the following Python code?
def myFunc(a):
a=[‘123’, ‘abc’]
return id(a)
val=[‘abc’,‘123’]
print(id(val)= = myFunc(val))
(a) True
(b) False
(c) Flag
(d) Error

Answer

B

34. What is the output of the following Python code?
val=10
def test(a=2, b=val):
print(a,b)
val=23
test(5)
(a) 5 10
(b) 10 5
(c) 23 5
(d) 23 15

Answer

A

35. What will be the output of the following Python code?
def myFunc(a, b):
if a > b :
return a
elif a = = b:
return ‘Equal numbers’
else:
return b
print(myFunc(2, 8))
(a) 8
(b) 2
(c) Equal numbers
(d) Error

Answer

A

36. What is the output of the following Python code?
def test(i=3, j=5):
i = i + j
j = j + 1
print(i, j)
test(j = 4, i = 5)
(a) 3 5
(b) 8 8
(c) 5 4
(d) 9 5

Answer

D

37. What will be the output of the following Python code?
val=12345
for i in val :
print(i)
(a) 1 2 3 4 5
(b) 12345
(c) 1 3 5
(d) Error

Answer

D

38. What is the output of following code?
a={11 : “Hindi”, 12 : “English”, 13 : “Science”}
for i, j in a:
print(i, j)
(a) 11 12 13
(b) Hindi English Science
(c) 11 Hindi 12 English 13 Science
(d) Error

Answer

D

39. Consider a tuple tup1=(3, 7, 9, 6, 2) on a binary file ‘‘story.bin’’:
import pickle
tup1=(3, 7, 9, 6, 2)
myfile=open (“story.bin”, ‘wb’)
pickle. _______ # Statement 1
myfile.close()
Identify the missing code in Statement 1.
(a) dump(myfile,tup1)
(b) dump(tup1,myfile)
(c) write(tup1,myfile)
(d) load(myfile,tup1)

Answer

B

40. Suppose the content of file “IMP.TXT” is What is the output of following code?
def test():
f=open(“IMP.TXT”)
e=0
u=0
while True:
l=f.readline()
if not l:
break
for i in l:
if(i==‘E’ or i==‘e’):
e=e+1
elif(i==‘U’ or i==‘u’):
u=u+1
print(e)
print(u)
f.close()
(a) 5
3
(b) 7
3
(c) 3
3
(d) 5
5

Answer

B

41. What is the output of following code?
import random
X = [100, 75, 10, 125]
Go = random.randint (0, 3)
for i in range (Go):
print (X[i], “$$”)
(a) 100$$75$$10$$
(b) 75$$10$$125$$
(c) 75$$10$$
(d) 10$$125$$100

Answer

A

42. What is the output of following code?
def Findoutput ():
L = “earn”
X = “ ”
L1 = []
count = 1
for i in L :
if i in [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]:
X = X + i.swapcase ()
else:
if (count% 2 ! = 0) :
X = X + str (len (L [: count]))
else:
X = X + i
count = count + 1
print (X)
Findoutput ()
(a) eA3N
(b) EA3n
(c) EA3N
(d) Ea3n

Answer

B

43. What is the output of following code? 
l1=[1, 2, 8, 9, 5]
for i in range (1, 5):
l1[i−1] = l1[i]
for i in range(0, 5):
print(l1[i], end=“”)
(a) 5 5 1 2 8
(b) 5 1 2 8 9
(c) 2 8 9 5 1
(d) 2 8 9 5 5

Answer

D

44. What is the output of following code?
def Func():
i=11
while i>1:
if(i%2==0) :
a=i%2
i=i-1
else:
i=i−3
a=i
print(a**3)

Class 12 Computer Science Sample Paper Term 1 Set B
Answer

A

45. Suppose the content of file ‘‘story.txt’’ is What is the output of following code?
f=open(“story.txt”)
i=f.read()
print(len(i))
f.close()
(a) 20
(b) 19
(c) 15
(d) 21

Answer

B

46. Suppose the content of file ‘‘exam.txt’’ is What is the output of following code?
myfile=open(“exam.txt”, “r”)
i=myfile.read()
j=i.count(‘the’)
print(j)
myfile.close()
(a) 3
(b) 2
(c) None
(d) Error

Answer

B

47. What is the output of following code?
list1=[‘PQR’, ‘XYZ’]
for i in list1:
i.lower()
print(list1)
(a) [‘pqr’, ‘xyz’]
(b) [‘PQR’, ‘XYZ’]
(c) [None, None]
(d) Error

Answer

B

48. Identify the output of following code.
list1=[23, 45, 47, 72, 69]
L=list1.pop(72)
print(L)
(a) 72
(b) [23, 45, 47, 69]
(c) None
(d) Error

Answer

D

49. What is the output of following code?
i = 2
j = 5
value = 5 + 4 * 2 + i * *j
print(value)
(a) 45
(b) 23
(c) 50
(d) Error

Answer

A

Section C

Case Study Based Questions

Below is a program to delete the line having word (passed as argument). Answer the questions that follow to execute the program successfully.
import _____ # Statement 1
def filedel(word) :
file1 = open(“Python.txt ”,“ _____”) # Statement 2
nfile = open(“algo.txt”, “w”)
while True :
line = file1._____ # Statement 3
if not line :
break
else :
if word in line :
_____ # Statement 4
else :
print(line)
nfile. _____ (line) # Statement 5
file1.close()
_____ . close() # Statement 6
filedel(‘write’)

50. Choose the correct option to fill up the blank in line marked as Statement 1.
(a) csv
(b) bin
(c) os
(d) python

Answer

C

51. In which mode, program should open the file to delete the line in statement 2?
(a) w
(b) r
(c) r+
(d) a+

Answer

B

52. Choose the correct option to fill up the blank in line marked as Statement 3.
(a) read()
(b) read(n)
(c) readlines()
(d) readline()

Answer

D

53. Identify the missing code for blank space in line marked as Statement 4.
(a) True
(b) Flag
(c) Pass
(d) False

Answer

C

54. Choose the correct option to fill up the blank in line marked as Statement 5.
(a) read
(b) write
(c) writelines
(d) writeline

Answer

B

55. Choose the correct option to fill up the blank in line marked as Statement 6.
(a) file 1
(b) file
(c) nfile
(d) None

Answer

C

Related Posts

error: Content is protected !!