Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

THE

QUALIFIERSChapter wise Set of MCQs to Check Preparation


Level of Each Chapter

Python Revision Tour-I


Direction (Q. Nos. 1-15) Each of the question has four options out of which only one is
correct. Select the correct option as your answer.
1. Which of the following is not a valid identifier?
(a) _Num (b) Sum123 (c) num^2 (d) name_1

2. Which of the following is a keyword that has pre-defined meaning?


(a) Python (b) data type (c) global (d) variable
3. What is the output of following code?
i=2
while (i<10):
if(i==6):
break
print(i)
i=i+2
(a) 2 (b) 2
4 3
4
(c) 2 (d) 2
3 4
4 6
6
THE QUALIFIERS

4. Which statement is used for the condition a loop is to be repeated 30 times?


(a) for i in range (0, 30) : (b) for i in range (0, 30, +1):
(c) for i in range (1, 31, 1): (d) All of these

5. What is the output of following code?


mul=3
value=10
for i in range (1, 6, 2):
CBSE Sample Questions Computer Science Class XII

if (value% mul==0):
print(value*mul)
else:
print(value+mul)
(a) 13 (b) 13
14 13
15 13
(c) 3 (d) Error
10
13

6. Evaluate the expression and identify the correct answer.


A = 5 * 3 / /4 + 6 / /8 + 7 − 3 + 9 / /3 + 7
(a) 17 (b) 20
(c) 27 (d) 14

7. What is the output of following code?


n=4
f=1
while (n>0):
f=f*n
n=n−1
print(f)
(a) 24 (b) 120
(c) 10 (d) Error

8. What is the output of following code?


n = 156
f = 0
x = 0
while (n > 3) :
r = n% 100
if (r % 2 ! = 0):
f + = r
else :
x + = r
n/=100
print(f − x)
(a) 56 (b) − 56
(c) 55 (d) 155

9. Identify the output of following code.


THE QUALIFIERS

a=3
while (a<12) :
print(a, end= ‘ ’)
a = a + 2
(a) 3 4 5 6 7 8 9 10 11 12 (b) 3 4 5 6 7 8 9 10 11
(c) 3 5 7 9 11 (d) 5 7 9 11
CBSE Sample Questions Computer Science Class XII

10. Identify the output of following code.


for i in range (− 7, − 20, − 2):
print (i+2)
(a) −7 (b) − 20
−9 − 18
− 11 − 16
− 13 − 14
− 15 − 12
− 17 − 10
−8

(c) None (d) Error

11. What is the output of following code?


x=1
for i in range (1, 7, 2)
:x + = i + 2
print(x)
(a) 16 (b) 9
(c) 25 (d) Error

12. Identify the output of following code.


i=1
while (i < 10) :
print(i)
i= i*3
(a) 3 (b) 0
9 3
9
(c) 1 (d) Error
3
9

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


i = 1
while (i < 6):
print(i)
i+= 2
if i = = 4:
break
else:
THE QUALIFIERS

print(2)
(a) 1 (b) 1 (c) 1 (d) 1
3 2 3 2
5 3 5 3
2 5
2
14. What will be the output of the following Python code?
for i in range(8):
if i = = 4:
break
else:
print(i+3)
else:
print(1)
(a) 2 (b) 3 (c) 3 (d) Error
4 4 4
6 5 5
8 6 6
1

15. What will be the output of the following Python code snippet?
x = ‘ARIHANT’
for i in range(len(x)):
x[i].lower()
print(x)
(a) ARIHANT (b) arihant (c) Arihant (d) Error

2. Python Revision Tour-II


Direction (Q. Nos. 1-15) Each of the question has four options out of which only one is correct.
Select the correct option as your answer.
1. Which of the following is/are example(s) of logical error?
(a) Identing a block to the wrong level (b) Getting operator precedence wrong
(c) Making a mistake in a boolean expression (d) All of these

2. Which of the following is false?


(a) String is mutable.
(b) capitalize() function in string is used to return a string by converting first character of
the string into uppercase.
(c) lower() function in string is used to return a string by converting the whole given string
into lowercase.
THE QUALIFIERS

(d) None of the above

3. Choose the correct option with respect to Python.


(a) Both tuples and lists are immutable.
(b) Tuples are immutable while lists are mutable.
(c) Both tuples and lists are mutable.
(d) Tuples are mutable while lists are immutable.
CBSE Sample Questions Computer Science Class XII

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


str1=“hello”
(a) print(str1[1]) (b) str1[2]=“a”
(c) print(str1[0:7]) (d) Both (b) and (c)

5. Syntax error in python is detected by................. at .............. .


(a) compiler, compile time (b) interpreter, run-time
(c) compiler, run-time (d) interpreter, compile time

6. Suppose list1 is [2, 33, 222, 14, 25], what is list1[− 1] ?


(a) Error (b) None (c) 25 (d) 2

7. Suppose list1 is [3,5, 25, 1, 3], what is min(list1) ?


(a) 3 (b) 5 (c) 25 (d) 1

8. Which of the following option will not result in an error when performed on tuple in
Python, where tup1=(5, 6, 8, 9)?
(a) tup1[1]=12 (b) tup1.append(2) (c) tup=tup1+tup1 (d) tup1.sort()

9. dic1={“A”:15,“B”:16,“C”:17}
print(dic1[1])
What will be the output of above Python code?
(a) B (b) 16 (c) {“B”:16} (d) Error
10. What will be the output of below Python code?
tup1=(1, 2, 3)
tup=tup1*2
print(tup)
(a) (2,4,6) (b) (1,2,3,1,2,3) (c) (1,1,2,2,3,3) (d) Error
11. Which of the following two Python codes will give same output?
>>> tup1=(1, 2, 3, 4, 5)
(i) print(tup1[:-1]) (ii) print(tup1[0:5])
(iii) print(tup1[0:4]) (iv) print(tup1[-4:])
(a) i, ii (b) ii, iv
(c) ii, v (d) i, iii
12. What will be the output of the following Python code?
x=[1, 3, 6, [18]]
y=list(x)
x[3][0]=15
x[1]=12
print(y)
THE QUALIFIERS

(a) [1,3,6, [15]] (b) [1,3,6,[12]] (c) [1,3,15,[18]] (d) [1,12,15,[18]]


13. What will be the output of the following Python code?
num = { }
num[(1,3,5)] = 18
num[(5,3,1)] = 16
num|(1,3)] = 22
sum = 0
CBSE Sample Questions Computer Science Class XII

for i in num:
sum += num[i]
print(len(num) + sum)
(a) 54 (b) 38
(c) 33 (d) 59
14. What will be the output of following Python code?
list1=[1,2,3,4,5]
str1=“6”
for i in list1:str1=str1+i
print(str1)
(a) 654321 (b) 123456
(c) 123645 (d) Error
15. What will be the output of following Python code?
dict1={“A”:15,“B”:23,“C”:21}
str1=“ ”
for i in dict1:
str1=str1+str(dict1[i])+“ ”
str2=str1[:−1]
print(str2[::−1])
(a) 12 32 51 (b) 12 32 15 (c) 32 21 15 (d) Error

***************************************************************************************************************************** ******

You might also like