Class 1 Class 2 Class 3 Class 4 Class 5 Class 6 Class 7 Class 8

Python Class 12 Computer Science Board Paper MCQ

← Back to Class 12 CS Main Page

Prepare for the Class 12 Computer Science Board Exam with these Python MCQs based on important concepts and question patterns commonly asked in board examinations. This collection covers topics such as Python functions, strings, lists, tuples, dictionaries, file handling, exception handling, and other important programming concepts.

These questions are useful for quick revision, self-assessment, and exam practice. Students can solve the MCQs to check their understanding and improve their accuracy before the board examination.

Python Class 12 Computer Science Board Paper MCQ

Q. Which of the following is a keyword in Python?
(A) Break
(B) None
(C) For
(D) Class

Answer: (B) None

Q. What will be the output of the following statement?

print(18/3 == 18//3)

(A) 0
(B) False
(C) 1
(D) True

Answer: (D) True

Q. Consider the statements given below and then choose the correct output from the given options :

D={"A":"MUMBAI", "B":"CHENNAI"}
print("C" in D)

(A) False
(B) 0
(C) True
(D) 1

Answer: (A) False

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

try:
 num = 5
 text = "15"
 result = str(num) + text
 print(result)
except:
 print("Error")

(A) Error
(B) 515
(C) 20
(D) 75

Answer: (B) 515

Q. What will be the output of the following statement?

print("X"* 2,"Y",end = 2 * "X", sep = "#")

(A) Error
(B) YY#XX
(C) XXYY#
(D) XX#YXX

Answer: (D) XX#YXX

Q. If L is an empty list, then which of the following expressions are invalid?
(A) L +’Hello’
(B) L + []
(C) L + [2]
(D) L * 2

Answer: (A) L +’Hello’

Q. Which of the following statements will return the substring “STR” (i.e. the first 3 characters) from the string “STRING”?
(A) “STRING”[:-3]
(B) “STRING”[-3::-1]
(C) “STRING”[:3]
(D) “STRING”.startswith(3)

Answer: (C) “STRING”[:3]

Q. Consider the statements given below and then choose the correct output from the given options :

K=('A','B')
V='TEST'
D = dict.fromkeys(K, V)
print(D)

(A) {‘A’:’TEST’, ‘B’: None}
(B) {‘A’: None, ‘B’:’TEST’}
(C) {‘A’:’TEST’, ‘B’:’TEST’}
(D) Error

Answer: (C) {‘A’:’TEST’, ‘B’:’TEST’}

Q. Which of the following is true about clear() in Python?
(A) It deletes the dictionary itself with all its elements.
(B) It deletes all items of the dictionary resulting in an empty dictionary.
(C) If D is a dictionary, then clear (D) is the correct statement.
(D) No such function/method exists in Python.

Answer: (B) It deletes all items of the dictionary resulting in an empty dictionary.

Q. Consider the statements given below and then choose the correct output from the given options :

L = ["A", "B"]
S=['C','D']
L.extend(S)
print(L)

(A) [‘A’, ‘B’, ‘C’, ‘D’]
(B) [‘A’, ‘B’, ‘CD’]
(C) [‘A’, ‘B’, [‘CD’]]
(D) [‘A’, ‘B’, [‘C’,’D’]]

Answer: (A) [‘A’, ‘B’, ‘C’, ‘D’]

Q. Which of the following options is the correct mode to open a binary pickled file to add more data in a previously existing binary pickled file?
(A) ‘rb’
(B) ‘ab’
(C) ‘w’
(D) ‘r’

Answer: (B) ‘ab’

Q. Assertion (A) : The upper() function/method in Python returns the string with all lowercase letters of the given string converted to uppercase.
Reason (R) : Strings are mutable objects in Python.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (C) Assertion (A) is true, but Reason (R) is false.

Q. State True or False : In Python, data type of 74 is same as the data type of 74.0.

Answer: False (74 is int, while 74.0 is float)

Q. Identify the output of the following code snippet :

s = "the Truth"
print(s.capitalize())

(A) The truth
(B) THE TRUTH
(C) The Truth
(D) the Truth

Answer: (A) The truth

Q. Which of the following expressions in Python evaluates to True?
(A) 2>3 and 2<3
(B) 3>1 and 2
(C) 3>1 and 3>2
(D) 3>1 and 3<2

Answer: (C) 3>1 and 3>2

Q. What is the output of the following code snippet?
s=’War and Peace by Leo Tolstoy’
print(s.partition(“by”))

(A) (‘War and Peace ‘, ‘by’, ‘ Leo Tolstoy’)
(B) [‘War and Peace ‘, ‘by’, ‘ Leo Tolstoy’]
(C) (‘War and Peace ‘, ‘ Leo Tolstoy’)
(D) [‘War and Peace ‘, ‘ Leo Tolstoy’]

Answer: (A) (‘War and Peace ‘, ‘by’, ‘ Leo Tolstoy’)

Q. What will be the output of the following statement?
print(“PythonProgram”[–1:2:–2])

Answer: mroP

Q. What will be the output of the following code snippet?

t = tuple('tuple')
t2 = t[2],
t += t2
print(t)

(A) (‘tuple’)
(B) (‘tuple’,’p’)
(C) (‘t’, ‘u’, ‘p’, ‘l’, ‘e’, ‘p’)
(D) (‘t’, ‘u’, ‘p’, ‘l’, ‘e’)

Answer: (D) (‘t’, ‘u’, ‘p’, ‘l’, ‘e’)

Q. Which of the following statements is true about dictionaries in Python?
(A) A dictionary is an example of sequence datatype.
(B) A dictionary cannot have two elements with same key.
(C) A dictionary cannot have two elements with same value.
(D) The key and value of an element cannot be the same.

Answer: (B) A dictionary cannot have two elements with same key.

Q. If L is a list with 6 elements, then which of the following statements will raise an exception?
(A) L.pop(1)
(B) L.pop(6)
(C) L.insert(1,6)
(D) L.insert(6,1)

Answer: (B) L.pop(6)

Q. What will be the output of the following code?

def f1(a,b=1):
 print(a+b,end='–')
 c=f1(1,2)
print(c,sep='*')

(A) 3–2
(B) 3–2*
(C) 3–None
(D) 3*None–

Answer: (C) 3–None

Q. Consider the statement given below :

f1 = open("pqr.dat","________")

Which of the following is the correct file mode to open the file in read only mode?
(A) a
(B) rb
(C) r+
(D) rb+

Answer: (B) rb

Q. State whether the following statement is True or False : In Python, Logical errors can be handled using try……except……finally statement.

Answer: False (Logical errors are not handled by try-except-finally)

Q. Assertion (A) : [1,2,3]+’123′ is an invalid expression in Python.
Reason (R) : In Python, a list cannot be concatenated with a string.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).

(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).

Q. Assertion (A) : The PRIMARY KEY constraint in SQL ensures that each value in the column(s) is unique and cannot be NULL.
Reason (R) : Candidate keys are not eligible to become a primary key.

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (C) Assertion (A) is true, but Reason (R) is false.

Q. State if following statement is True or False : If T is a tuple and L is a list, then T+L is a valid statement in Python.

Answer: False (A tuple cannot be concatenated directly with a list)

Q. Identify the output of the following code segment :

s = "an apple. a toy."
s=s.find('a',2)
print(s)

(A) 0
(B) 1
(C) 3
(D) ‘a’

Answer: (C) 3

Q. What is the value of the following expression?

3 + 3·00, 3**3·0

(A) [6·0, 27·0]
(B) (6·0, 9·0)
(C) (6, 27)
(D) (6·0, 27·0)

Answer: (A) [6·0, 27·0]

Q. What is the output of the following expression?

Sports="Paralympic Games"
print (Sports.split("m"))

(A) [‘Paraly’,’m’,’pic Ga’,’m’,’es’]
(B) (‘Paraly’,’m’,’pic Games’)
(C) (‘Paraly’,’pic Ga’,’es’)
(D) [‘Paraly’,’pic Ga’,’es’]

Answer: (D) [‘Paraly’,’pic Ga’,’es’]

Q. What will be the output of the following code segment?

p=list("Session 2024–25")
print(p[10:20:])

Answer: [‘2’, ‘0’, ‘2’, ‘4’, ‘–’, ‘2’, ‘5’]

Q. Which of the following is a mapped data type?
(A) List
(B) Sets
(C) Dictionary
(D) Boolean

Answer: (C) Dictionary

Q. If the dictionary D1 is defined as :

D1={1:'a',2:'b'}

then which of the following statements is incorrect and hence will result in an error?
(A) D1.get(1)
(B) D1.get(3)
(C) D1.del(1)
(D) D1.clear()

Answer: (C) D1.del(1)

Q. Which of the following list methods accepts exactly 2 parameters?
(A) append()
(B) extend()
(C) insert()
(D) pop()

Answer: (C) insert()

Q. A text file song.txt contains the following contents in it :
Life goes on as it never ends
What will be the output of the following code snippet?

f1=open("song.txt","r")
s1=f1.read(5)
s2=f1.readline(4)
s3=f1.read(3)
print(s1,s3,sep="#")

(A) goes# on
(B) Life #goes# on
(C) Life # on
(D) Error

Answer: (C) Life # on

Q. State whether the following statement is True or False.
In Python, the print() evaluates the expression before displaying it on the screen.

Answer: True

Q. What will be the output of the following code segment?

a=5
def func_1(b=10):
      global a
       a=b–10
       b+=a
       print(a,b)
func_1(a)

(A) 0 5
(B) 5 0
(C) 0 –5
(D) –5 0

Answer: (A) 0 5

Q. Assertion (A) : Every object in Python is assigned a unique identity (ID).
Reason (R) : ID remains the same for the lifetime of that object.

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).

Q. State True or False : “In Python, tuple is a mutable data type”.

Answer: False

Q. What will be the output of the following statement?

print(6+5/4**2//5+8)

(A) –14.0
(B) 14.0
(C) 14
(D) –14

Answer: (B) 14.0

Q. Select the correct output of the code :

S = "text#next"
print(S.strip("t"))

(A) ext#nex
(B) ex#nex
(C) text#nex
(D) ext#next

Answer: (D) ext#next

Q. Which of the following output will never be obtained when the given code is executed?

import random
Shuffle = random.randrange(10)+1
Draw = 10*random.randrange(5)
print ("Shuffle", Shuffle, end="#")
print ("Draw", Draw)

(A) Shuffle 1 # Draw 0
(B) Shuffle 10 # Draw 10
(C) Shuffle 10 # Draw 0
(D) Shuffle 11 # Draw 50

Answer: (D) Shuffle 11 # Draw 50

Q. What will be the output of the given code?

a=10
def convert(b=20):
a=30
c=a+b
print(a,c)
convert(30)
print(a)

Answer: First line: 60 60; second line: 10

Q. For the following Python statement :

N = (25)

What shall be the type of N?
(A) Integer
(B) String
(C) Tuple
(D) List

Answer: (A) Integer

Q. Identify the valid Python identifier from the following :
(A) 2user
(B) user@2
(C) user_2
(D) user 2

Answer: (C) user_2

Q. Consider the statements given below and then choose the correct output from the given options :

Game="World Cup 2023"
print(Game[-6::-1])

(A) CdrW
(B) ce o
(C) puC dlroW
(D) Error

Answer: (C) puC dlroW

Q. Predict the output of the following Python statements :

>>>import statistics as s
>>>s.mode ([10, 20, 10, 30, 10, 20, 30])

(A) 30
(B) 20
(C) 10
(D) 18.57

Answer: (C) 10

Q. Assertion (A) : Global variables are accessible in the whole program.
Reason (R) : Local variables are accessible only within a function or block in which it is declared.

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).

Q. Assertion (A) : If numeric data are to be written to a text file, the data needs to be converted into a string before writing to the file.
Reason (R) : write() method takes a string as an argument and writes it to the text file.

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).

Q. State True or False. “Comments are not executed by interpreter.”

Answer: Ture

Q. Which of the following is not a sequential datatype in Python?
(a) Dictionary
(b) String
(c) List
(d) Tuple

Answer: (a) Dictionary

Q. Given the following dictionary

Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}

Which statement will return “Tuesday”.
(a) Day.pop()
(b) Day.pop(2)
(c) Day.pop(1)
(d) Day.pop(“Tuesday”)

Answer: (b) Day.pop(2)

Q. Consider the given expression :

7<4 or 6>3 and not 10==10 or 17>4

Which of the following will be the correct output if the given expression is evaluated?
(a) True
(b) False
(c) NONE
(d) NULL

Answer: (a) True

Q. Select the correct output of the code :

S="Amrit Mahotsav @ 75"
A=S.split(" ",2)
print(A)

(a) (‘Amrit’, ‘Mahotsav’, ‘@’, ’75’)
(b) [‘Amrit’, ‘Mahotsav’, ‘@ 75’]
(c) (‘Amrit’, ‘Mahotsav’, ‘@ 75’)
(d) [‘Amrit’, ‘Mahotsav’, ‘@’, ’75’]

Answer: (b) [‘Amrit’, ‘Mahotsav’, ‘@ 75’]

Q. Which of the following modes in Python creates a new file, if file does not exist and overwrites the content, if the file exists?
(a) r+
(b) r
(c) w
(d) a

Answer: (c) w

Q. Fill in the blank : ___________ is not a valid built-in function for list manipulations.
(a) count()
(b) length()
(c) append()
(d) extend()

Answer: (b) length()

Q. Which of the following is an example of identity operators of Python?
(a) is
(b) on
(c) in
(d) not in

Answer: (a) is

Q. Which of the following statement(s) would give an error after executing the following code?

S="Happy" # Statement 1
print(S*2) # Statement 2
S+="Independence" # Statement 3
S.append("Day") # Statement 4
print(S) # Statement 5

(a) Statement 2
(b) Statement 3
(c) Statement 4
(d) Statement 3 and 4

Answer: (c) Statement 4

Q. The correct syntax of tell() is :
(a) tell.file_object()
(b) file_object.tell()
(c) tell.file_object(1)
(d) file_object.tell(1)

Answer: (b) file_object.tell()

Q. Which of the following functions is a valid built-in function for both list and dictionary datatype?
(a) items()
(b) len()
(c) update()
(d) values()

Answer: (b) len()

Q. fetchone() method fetches only one row in a ResultSet and returns a __________.
(a) Tuple
(b) List
(c) Dictionary
(d) String

Answer: (a) Tuple

Q. Assertion (A) : In Python, a stack can be implemented using a list.
Reasoning (R) : A stack is an ordered linear list of elements that works on the principle of First In First Out (FIFO).

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (C) Assertion (A) is true, but Reason (R) is false.

Q. Assertion (A) : readlines() reads all the lines from a text file and returns the lines along with newline as a list of strings.
Reasoning (R) : readline() can read the entire text file line by line without using any looping statements.

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

Answer: (C) Assertion (A) is true, but Reason (R) is false.

Q. State True or False : “A Python List must always contain all its elements of same data type.”

Answer: False (Lists can contain different data types)

Q. What will be the output of the following statement?

print (14%3**2*4)

(A) 16
(B) 64
(C) 20
(D) 256

Answer: (B) 64

Q. Identify the correct output of the following code snippet:

game="Olympic2024"

print(game.index(“C”))
(A) o
(B) 6
(C) -1
(D) ValueError

Answer: (D) ValueError

Q. Which of the following is the correct identifier?
(A) global
(B) Break
(C) def
(D) with

Answer: (B) Break

Q. Identify the invalid Python statement out of the following options:
(A) print(“A”,10,end=”“)
(B) print(“A”,sep=”
“,610)
(C) print(“A”,10,sep=”*”)
(D) print(“A”*10)

Answer: (B) print(“A”,sep=”*”,610)

Q. Consider the statements given below and then choose the correct output from the given options:

L=['TIC', 'TAC']
print(L[::-1])

(A) [‘cIT’, ‘CAT’]
(B) [‘TIC’, ‘TAC’]
(C) [‘caT’, ‘CcIT’]
(D) [‘TAC’, ‘TIC’]

Answer: (D) [‘TAC’, ‘TIC’]

Q. Which of the following operator evaluates to True if the variable on either side of the operator points towards the same memory location and False otherwise?
(A) is
(B) is not
(C) and
(D) or

Answer: (A) is

Q. Consider the statements given below and then choose the correct output from the given options:

D={'S01':95, 'S02':96 }
for I in D :
print(I,end="#")

(A) s01#s02#
(B) 95#96#
(C) s01,95#s02,96#
(D) SO1#95#S02#964#

Answer: (A) s01#s02#

Q. Consider the statements given below and then choose the correct output from the given options:

def Change (N) :
N=N+10
print(N,end='$$")
N=15
Change (N)
print(N)

(A) 25%%$15
(B) 15%$$25
(C) 25$$25
(D) 25$$15

Answer: (D) 25$$15

Q. Consider the statements given below and then choose the correct output from the given options:

N='5"
try:
print ('WORD' + N, end='#"')
except:
print ('ERROR' ,end='#")
finally:
print('OVER')

(A) ERROR#
(B) WORDS5#OVER
(C) WORDS#
(D) ERROR#OVER

Answer: (D) ERROR#OVER

Q. Which of the following built-in function/method returns a dictionary?
(A) diet()
(B) keys()
(C) values()
(D) pickle.dump()

Answer: (D) pickle.dump()

Q. Assertion (A) : For a binary file opened using ‘rb’ mode, the pickle.dump () method will display an error. 1
Reason (R) : The pickle.dump () method is used to read from a binary file.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A).
(B) Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A).
(C) Assertion (A) is true but, Reason (R) is false.
(D) Assertion (A) is false but, Reason (R) is true.

Answer: (C) Assertion (A) is true but, Reason (R) is false.

Disclaimer: We have taken an effort to provide you with the accurate handout of “Computer Science Class 12“. If you feel that there is any error or mistake, please contact me at anuraganand2017@gmail.com. The above CBSE study material present on our websites is for education purpose, not our copyrights. All the above content and Screenshot are taken from Computer Science Class 12 CBSE Textbook, Sample Paper, Old Sample Paper, Board Paper and Support Material which is present in CBSEACADEMIC website, This Textbook and Support Material are legally copyright by Central Board of Secondary Education. We are only providing a medium and helping the students to improve the performances in the examination. 

Images and content shown above are the property of individual organizations and are used here for reference purposes only.

For more information, refer to the official CBSE textbooks available at cbseacademic.nic.in

← Back to Class 12 CS Main Page

Leave a Comment