XII CS OBJ REV1 MCQ
XII CS OBJ REV1 MCQ
XII CS OBJ REV1 MCQ
(Kolathur-Maduravoyal-Mathur-Perambur-Surapet-Madurantakam-Rajamangalam-Paruthipattu)
CLASS: XII COMPUTER SCIENCE MCQ
1. Which of these in not a core data type? a) Lists b) Dictionary c) Tuples d) Class
2. Given a function that does not return any value, what value is thrown by default when executed in shell.
a) int b) bool c) void d) None
3. Following set of commands are executed in shell, what will be the output?
str=”Hello”
str[:2]
a) He b) Lo c) Olleh d) Hello
4. Which of the following will run without errors?
a) round(45.8) b) round(6352.898,2,5) c) round() d) round(7463.123,2,1)
5. What will be the output of following code if:
a = “abcde”
a [1:1 ] == a [1:2]
type (a[1:1]) == type (a[1:2])
6. What error occurs when you execute?
Apple = mango
a) SyntaxError b) NameError c) ValueError d) TypeError
7. Carefully observe the code and give the answer.
def example(a):
a = a + „2‟
a = a*2
return a
print(example(“hello”))
a) Indentation Error b) Cannot perform mathematical operation on strings c) hello2 d) hello2hello2
8. What is the average value of the code that is executed below?
>>>grade1 = 80
>>>grade2=90
>>>average = (grade1 + grade2)/2
a) 85.0 b) 85.1 c) 95 d) 95.1
9. Select all options that print
Hello-how-are-you
a) print('hello', 'how', 'are', 'you') b) print('hello', 'how', 'are', 'you' + '-' * 4)
c) print('hello-'+ 'how-are-you') d) print('hello-'+''+'how'+'are' + 'you')
10. What is the output of print 0.1+0.2 == 0.3? a) True b) Falsec) Machine dependent d) Error
11.Select the correct output of the code:
s = "Question paper 2022-23"
s= s.split('2')
print(s)
a) ['Question paper ', '0', '', '-', '3'] b) ('Question paper ', '0', '', '-', '3')
c) ['Question paper ', '0', '2', '', '-', '3'] d) ('Question paper ', '0', '2', '', '-', '3'
12. Write the output of the following code:
>>> 7+2//1**2 > 5+2**2//3
a) True b) False c) Error d) None of the above
13. Predict the output for the following code.
A = 27
B = 98.7
Sum = A + B
print(type(Sum))
14. What will be correct output for the following expression?
not((True and False) or True) a) True b) False c) None d) Error
15. What will the following expression be evaluated to in python?
print(round(100.0/4 + (3+2.55),1)) a) 30.7 b) 13.6 c) 30.6 d) 3.06
16. Find the invalid identifier from the following. a) Mylord b) false c) 77data d) My_lord
17. Which of the following is not a keyword? a) eval b) nonlocal c) pass d) assert
18. Consider the given expression:
not 5 or 4 and 10 and „bye‟
Which of the following will be correct output if the given expression is evaluated?
a) True b) False c) 10 d) „bye‟
19. Write the output of the following code.
D = [3,5,7]
for A in D:
A = A + 10
print(D)
a) [3,5,7] b) [30,50,70] c) [70,50,30] d) [7,5,3]
20. What will be the output of the following string operation.
STR = „python@language‟
print(STR[2:12:2])
a) thon@ b) t@ng c) ngae d) to@ag
21. Which of the following datatype in python is used to represent any real number:
a) int b) complex c) float d) bool
22. What will the following expression be evaluated to in python?
print((-33//13)*(35% (-2))*15/3) a) 12.0 b) 15 c) 15.2 d) 15.0
23. Consider the string State = „Jharkhand‟. Identify the appropriate statement that will display the last five
characters of the string State? a) State[-5: ] b) State[4: ] c) State[ : 4] d) State[ : -4]
24. What will be the output of the following statement: print(3-2**2**3+99/11)
a) 244 b) -244.0 c) 244.0 d) Error
25.. Select the correct output of the following code:
>>>str1 = „India is a Great Country‟
>>>str1.split(„a‟)
a) [„India‟, ‟is‟, ‟a‟,‟ Great‟, ‟Country‟] b) [„India‟, ‟is‟, ‟Great‟, ‟Country‟]
c) [„Indi‟, ‟is‟, ‟Gre‟, ‟t Country‟] d) [„Indi‟, ‟is‟, ‟Gre‟, ‟t‟, „Country‟]
26. What will the following code print?
print(max("zoo 145 com"))
a) 145 b) 122 c) z d) zoo
27. Which of the following statement(s) would give an error after executing the following code?
D = {„rno‟:32, „name‟ : „MsArchana‟, „subject‟: [„hindi‟,‟english‟,‟cs‟], „marks‟:
(85,75,89)}
print(D) # S1
D[„subject‟][2] = „IP‟ #S2
D[„marks‟][2] = 80 # S3
print(D) #S4
a) S1 b) S3 c) S4 d) S3 and S4
28. Given is a python string declaration:
Msg = „FirstPreBoardExam@2024-2025‟
print(Msg[ : : -3].upper()) # Write the output for the given code.
a) 22@XRB b) 52@RBPR c) 522@XRBPR d) XRBPR
29. Write the output for the following code.
for I in „CBSE‟:
print([I.lower()], end = „#‟)
a) [„c‟]#[„b‟]#[„s‟]#[„e‟]# b) [„c‟]#[„b‟]#[„s‟]#[„e‟] c) „c‟#‟b‟#‟s‟#‟e‟# d) c#b#se#
30. Predict the output.
Marks = {'Ashok':98.6, 'Ramesh': 95.5}
print(list(Marks.keys()))
a) „Ashok‟, „Ramesh‟ b) 98.6, 95.5 c) [„Ashok‟, „Ramesh‟] d) („Ashok‟, „Ramesh‟)
31. Write the output:
Tuple = ("john", 'peter','vicky')
x = '##'.join(Tuple)
print(x)
a) john##peter##vicky b) john##peter##vicky## c) ##john##peter##vicky d) ##johnpetervicky##
32. Select the correct output of the code:
c=0
while True:
if c %3 ==0:
print(c,end = „ „)
if c > 15:
break
c += 1
a) 0 1 2 …….. 15 b) Infinite loop c) 0 3 6 9 12 15 d) 0 3 6 9 12
33. Write the output of the code given below:
Dict = {„title‟:‟you can win‟, „copies‟:15}
Dict[„Author‟] = „Shiv khera‟
Dict[„genre‟] = „Motivation‟
print(Dict.items())
a) ([(„title‟,‟you can win‟), („copies‟,15), („Author‟,„Shivkhera‟), („genre‟,„Motivation‟)])
b) dict_items([(„title‟,‟you can win‟), („copies‟,15), („Author‟,„Shivkhera‟), („genre‟,„Motivation‟)])
c) dict_items([(„title‟), („copies‟), („Author‟), („genre‟)])
d) dict_items([(‟you can win‟), (15), („Shiv khera‟), („Motivation‟)])
34. What will be output of the following code:
D1 = {1:2,3:4,5:6}
D2=D1.get(3,5)
print(D2)
a) 3 b) 4 c) 5 d) 2
35. Predict the output
S= „Thank you god – For Everything‟
Sub = „god‟
S.find(Sub,15,22)
a) 16 b) -1 c) ValueError d) None of these
36. Identify the output of the following code snippet:
text = "The_quick_brown_fox"
index = text.find("quick")
result = text[:index].replace("_", "") + text[index:].upper()
print(result)
a) Thequick_brown_fox b) TheQUICK_BROWN_FOX
c) TheQUICKBROWNFOX d) TheQUICKBROWN_FOX
37. Suppose a tuple T is declared as T = (29,12, 56, 77) Which of the following is incorrect?
a) print(T[1]) b) T[2] = 18 c) print(min(T)) d) print(len(T))
38. Which of the following statement(s) would give an error after executing the following code?
X = int(“Enter the value of X:”)) # Statement 1
for y in range[0,21]: # Statement 2
if X == y: # Statement 3
print(X+y) # Statement 4
else: # Statement 5
print(X-y) # Statement 6
a) Statement 4 b) Statement 5 c) Statement 4 & 6 d) Statement 1 & 2
39. Choose the most correct statement among the following –
a) A dictionary is a non-sequential collection of elements
b) A dictionary is a set of key-value pairs
c) A dictionary is a sequential set of elements
d) A dictionary is a sequential collection of elements key-value pairs
40. Select the correct output of the code:
s = “Python is fun”
L = s.split()
s_new= ”-“.join([L[0].upper(), L[1], L[2].capitalize()])
print (s_new)
a) PYTHON-IS-Fun b) PYTHON-is-Fun c) Python-is-fun d) PYTHON-Is-Fun
41. Which of the following will delete key-value pair for key = “Red” from a dictionary D1?
a) Delete D1 (“Red”) b) Del D1 [“Red”] c) Del. Dl [“Red”] d) Dl.del[“Red”]
42. What is the correct way to add an element to the end of a list in python?
a) List.append(element) b) List.add(element) c) List.insert(element) d) List.extend(element)
43. Which of the following is the use of function in python?
a) Functions are reusable pieces of programs b) You can‟t also create your own functions
c) Functions don‟t provide better modularity for your application d) All of the mentioned
44. What is the output of the below program?
x = 50
deffunc(x):
x=2
func(x)
print('x is now', x)
a) x is now 50 b) x is now 2 c) x is now 100 d) None of the mentioned
45. What is the output of the below program?
def C2F(c):
return c*9/5 + 32
print(C2F(100), end = „ „)
print(C2F(0))
a) 212.0 32.0 b) 314.0 24.0 c) 567 98 d) 212 32
46. What will be the output of the following code?
defmy_func(var1=100,var2=200):
var1 += 10
var2 = var2 – 10
return var1 + var2
print(my_func(50),my_func())
a) 300 250 b) 250 250 c) 300 305 d) 250 300
47. Consider the code given below:
b =100
def test (a):
_______ #missing statement
b=b+a
print(a,b)
test (10)
print (b)
Which of the following statements should be given in the blank for #Missing Statement, if the output produced is 110?
a) global a b) global b=100 c) global b d) global a=100
48. What is the output of the below program?
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(3, 4)
a) 4 b) 4 is maximum c) 3 d) None of the mentioned
49. Which arguments given below are skipped from function call?
a) Positional b) Default c) Keyword d) named
50. What is the order of resolving scope in Python? a) BGEL b) LEGB c) GEBL d)LBEG
51. Which of the following is equivalent to random.randint(3, 6)?
a) random.choice([3, 6]) b) random.randrange(3, 6)
c) 3 + random.randrange(3) d) 3 + random.randrange(4)
52. What is the range of values that random.random() can return?
a) [0.0, 1.0] b) (0.0, 1.0] c) (0.0,1.0) d) [0.0, 1.0)
53. Which of the following cannot be returned by random.randrange(4)?
a) 0 b) 3 c) 2.3 d) none of the above
54. The function random.randint(4) can return only one of the following values.Which? a) 4 b) 3.4 c) error d) 5
55. Consider the following code:
import math import random
print(str(int(math.pow(random.randint(2,4),2))))
print(str(int(math.pow(random.randint(2,4),2))))
print(str(int(math.pow(random.randint(2,4),2))))
What could be the possible outputs out of the given four choices? a) 2 3 4 b) 9 4 4 c) 16 16 3 d) 2 4 9
56. What possible outputs(s) are expected to be displayed on screen at the time of execution of the program from
the following code?
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):
print (AR[K], end="#")
a) 10#40#70# b) 30#40#50# c) 50#60#70# d) 40#50#70#
57. 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
VALUES [10, 20, 30, 40, 50, 60, 70, 80]
BEGIN = random.randint (1, 3)
LAST = random.randint(2, 4)
fori in range (BEGIN, LAST+1):
print (VALUES[i], end = "-")
a) 30-40-50- b) 10-20-30-40- c) 30-40-50-60- d) 30-40-50-60-70-
58. Which of the following is the primary purpose of exception handling in programming?
a) To intentionally crash the program b) To ignore errors and continue program execution
c) To gracefully manage and recover from unexpected errors d) To create errors for testing purposes
59. What is the primary role of the "try' block in a try-except construct?
a) To execute code that may raise an exception b) To handle exceptions
c) To indicate the end of the try-except construct d) To prevent exceptions from occurring
60. In a try-except block, if an exception occurs, which block is executed?
a) The try block b) The except block c) Both try and except blocks simultaneous d) None of the above
61. Which keyword is used to specify the type of exception to catch in an except block?
a) catch b) try c) except d) handle
62. What type of error does a ValueError exception typically represent in Python?
a) A network-related error b) A division by zero error
c) An error related to invalid data conversion. d) A file handling error
63. Which exception is raised when attempting to access a non-existent file?
a) FileNotFoundError b) FileNotAccessibleError c) NonExistentFileError d) InvalidFileAccessError
64. What is the purpose of the finally block in exception handling?
a) To specify the types of exceptions to catch
b) To execute code regardless of whether an exception occurred or not
c) To create custom exceptions d) To prevent exceptions from propagating
65. Which of the following functions changes the position of file pointer and returns its new position?
a) flush() b) tell() c) seek() d) offset()
66. which of the following function returns a list datatype
a) d=f.read() b) d=f.read(10) c) d=f.readline() d) d=f.readlines()
67. The correct syntax of seek() is:
a) file_object.seek(offset [, reference_point]) b) seek(offset [, reference_point])
c) seek(offset, file_object) d) seek.file_object(offset)
68. What will be the output of the following statement in python? (fh is a file handle). fh.seek(-30,2)
Options:- It will place the file pointer:-
a) at 30th byte ahead of current current file pointer position b) at 30 bytes behind from end-of file
c) at 30th byte from the beginning of the file d) at 5 bytes behind from end-of file.
69. Which Python function is used to open a text file for reading?
a) open("file.txt", "w") b) open("file.txt", "r") c) read("file.txt") d) write("file.txt")
70. Raman wants to open the file abc.txt for writing the content stored in a folder name sample of his computer d
drive help raman to tell the correct code for opening the file
a) myfile=open("d:\\sample.txt\\abc",'w') b) myfile=open("d:\\sample\\abc.txt","w")
c) myfile=open("d:\\sample\abc.txt","w") d) all of the above
71. Which type of file does not have delimiters? a) CSV b) TSV c) Binary d) Text
72. The process of converting the structure to a byte stream before writing to the file is known as____
a) Unpicking b) Pickling c) Deserialisation d) Delimitation
73. Which of the following statement is incorrect in the context of binary files?
a) Information is stored in the same format in which the information is held in memory.
b) No character translation takes place
c) Every line ends with a new line character
d) pickle module is used for reading and writing
74. The prefix ____ in front of a string makes it raw string that is no special meaning a) r b) r+ c) + d) R+
75. The default file-open mode is............. a) r b) a c) w d) w+
76. Process of inserting an element in stack is called ___ a) Create b) Push c) Evaluation d) Pop
77. Process of removing an element from stack is called____a) Create b) Push c) Evaluation d) Pop
78. In a stack, if a user tries to remove an element from empty stack it is called
a) Underflow b) Empty collection c) Overflow d) Garbage Collection
79. Entries in a stack are "ordered". What is the meaning of this statement?
a) A collection of stacks is sortable
b) Stack entries may be compared with the '<' operation
c) The entries are stored in a linked list
d) There is a Sequential entry that is one by one.
80. A stack follows the walking of principal and subject?
a) FIFO (First In First Out) list b) LIFO (Last In First Out) list c) Ordered array d) Linear tree
81. To open a file c:\scores.txt for appending data, we use
a) outfile = open("c:\\scores.txt", "a") b) outfile = open("c:\\scores.txt", "rw")
c) outfile = open(file = "c:\scores.txt", "w") d) outfile = open(file = "c:\\scores.txt", "w")
82. Which of the following statements are true?
a) When you open a file for reading, if the file does not exist, an error occurs
b) When you open a file for writing, if the file does not exist, a new file is created
c) When you open a file for writing, if the file exists, the existing file is overwritten with the new file
d) All of the mentioned
83. The readline() method returns a) str b) a list of lines c) a list of single characters d) a list of integers
84. What will the following expression be evaluated to in Python?
print(16-(3+2)*5+2**3*4) a) 54 b) 46 c) 23 d) 32
85. Assertion (A):- key word arguments are related to the function calls.
Reason (R):- when you use keyword arguments in a function call, the caller identifies the arguments by parameter
name.
ASSERTION AND REASON based questions. Mark the correct choice as-
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False d) A is false but R is True
86. Given:s="ComputerExam", What will be the output of
print(s[2]+[8] + [1:51)?
a) mEOMUU b) mEomPU c) mEompu d) MEompu
87. Raghav is trying to write a tuple t = (1,2,3,4,5) on a binary file test.bin Consider the following code written by him.
import pickle
t = (1,2,3,4,5)
myfile = open("test.bin", 'wb')
pickle. _________ #Statement 1
myfile.close()
Identify the missing code in Statement 1.
a) dump(myfile,t) b) dump(t, myfile) c) write(t, myfile) d) load(myfile,t)
88. The uniform() function is the part of ______ module. a) statistics b) random c) Pickle d) CSV
89. _______ exception is raised when input() hits an EOF without reading any data
a) NameError b) ValueError c) TypeError d) EOFError
90. If the elements "A", "B", "C" and "D" are placed in a stack with "D" on top and are deleted one at a time, what is
the order of removal? a) ABCD b) DCBA c) DCAB d) ABDC
91. The command creates an exception object and hands it over to runtime system to handle it accordingly.
a) try b) catch c) finally d) raise
92. What is the output of the following code?
t = (10, 20, 30, 40, 50, 50, 70)
print(t[5:-1])
a) Blank output() b) (50,50,70) c) (50,70) d) (50,)
93. Consider the list aList = ["SIPO", [1, 3, 5, 7] ]. What would the following code print?
print(alist[0] [1], aList[1][1]) a) S, 3 b) S, 1 c) I, 3 d) I, 1
94. Given a list L = [10, 20, 30, 40, 50, 60, 70], what would L[-3: 99] return ?
a) [20, 30, 40] b) [30, 40, 50] c) [40, 50, 60] d) [50, 60, 70]
95. Which of the following will delete key:value pair for key="tiger" in dictionary?
di = {"lion":"wild", "tiger":"wild","cat": "domestic", "dog":"domestic"}
(a) del di["tiger"] b) di["tiger"].delete() (c) delete(di.["tiger"]) (d) del(di.["tiger"])
96. What is the output of the following expression?
print([4.00/(2.0+2.0), 4.00/2.0+2.0]) a) [1.2, 1.0] b) [1.0, 4.0] c) [4.0, 4.0] d) [1.0, 4.2]
97. Given the following dictionaries
dict_exam = {"Exam": "AISSCE", "Year":2023}
dict_result = {"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
a) dict_exam.update(dict_result) b) dict_exam + dict_result
c) dict_exam.add(dict_result) d) dict_exam.merge(dict_result)
98. Identify the correct possible output for the following Python code:
import random
for N in range(2, 5, 2):
print(random.randrange (1, N), end = '#')
a) 1#3#5# b) 2#3# c) 1#4# d) 1#3#
99. If a file is opened for writing, which of the following statements are true?
a) The file must exist on the disk on the specified path.
b) If the file exists at the specified path, the file is successfully opened.
c) The file even if at a different location on disk other than the specified path, will get opened.
d) Python gives error if the file does not exist at the specified path.
100. Identify the invalid Python statement from the following:
a) d = dict() b) e = {} c) f = [] d) g = dict{}