0% found this document useful (0 votes)
14 views7 pages

Test Code Thinker

The document contains a series of multiple-choice questions (MCQs) related to Python programming concepts, including lists, tuples, sets, and control flow. Each question presents a code snippet followed by four answer options, testing the reader's understanding of Python's behavior and syntax. The questions cover a range of topics such as indexing, type errors, and built-in functions.

Uploaded by

Nitin Ojha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

Test Code Thinker

The document contains a series of multiple-choice questions (MCQs) related to Python programming concepts, including lists, tuples, sets, and control flow. Each question presents a code snippet followed by four answer options, testing the reader's understanding of Python's behavior and syntax. The questions cover a range of topics such as indexing, type errors, and built-in functions.

Uploaded by

Nitin Ojha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

🧠 Output-Based MCQs

1.

x = [1, 2, 3]
x.append([4, 5])
print(x)

A) [1, 2, 3, 4, 5]​
B) [1, 2, 3, [4, 5]]​
C) [1, 2, 3, 4, [5]]​
D) TypeError

2.

x = (1, 2, 3)
x[1] = 5
print(x)

A) (1, 5, 3)​
B) [1, 5, 3]​
C) TypeError​
D) None

3.

x = {1, 2, 3}
x.add(2)
print(x)
A) {1, 2, 3}​
B) {1, 2}​
C) {1, 2, 3, 2}​
D) Error

4.

x = [1, 2, 3]
print(x[::-1])

A) [1, 2, 3]​
B) [3, 2, 1]​
C) Error​
D) [1, 3, 2]

5.

for i in range(3):
print(i, end=" ")

A) 0 1 2​
B) 1 2 3​
C) 0 1 2 3​
D) 1 2

6.

if 0:
print("Yes")
else:
print("No")
A) Yes​
B) No​
C) 0​
D) Error

7.

a = [1, 2, 3]
b = a
b[0] = 5
print(a)

A) [1, 2, 3]​
B) [5, 2, 3]​
C) [1, 2, 5]​
D) Error

8.

x = (1, 2, 3)
print(2 in x)

A) True​
B) False​
C) 2​
D) Error

9.

s = set()
s.add(1)
s.add("1")
print(len(s))

A) 1​
B) 2​
C) 0​
D) 3

10.

a = [1, 2, 3]
print(a * 2)

A) [1, 2, 3, 1, 2, 3]​
B) [2, 4, 6]​
C) Error​
D) [1, 2, 3, 2, 4, 6]

11.

x = [1, 2, 3]
print(x[3])

A) IndexError​
B) 3​
C) None​
D) 0

12.

x = ()
print(type(x))

A) <class 'tuple'>​
B) <class 'list'>​
C) <class 'set'>​
D) Empty

13.

a = (1,)
print(len(a))

A) 0​
B) 1​
C) Error​
D) 2

14.

a = [1, 2, 3]
a.remove(2)
print(a)

A) [1, 3]​
B) [2, 3]​
C) [1, 2]​
D) Error

15.

a = {1, 2, 3}
a.discard(5)
print(a)

A) {1, 2, 3}​
B) Error​
C) {1, 2}​
D) None

16.

for i in range(5, 1, -1):


print(i, end=" ")

A) 5 4 3 2​
B) 1 2 3 4 5​
C) 5 4 3​
D) 5 4 3 2 1

17.

a = (1, 2, 3)
b = a + (4,)
print(b)

A) (1, 2, 3, 4)​
B) [1, 2, 3, 4]​
C) Error​
D) None

18.
a = ""
print(a[1:4])

A) yth​
B) Pyt​
C) ytho​
D) Error

19.

x = [1, 2, 3]
x.insert(1, 5)
print(x)

A) [1, 5, 2, 3]​
B) [5, 1, 2, 3]​
C) [1, 2, 3, 5]​
D) Error

20.

x = [1, 2]
y = x + [3]
print(y)

A) [1, 2, 3]​
B) [3, 2, 1]​
C) [1, 2]​
D) Error

You might also like