iGET

Python Programming - MCQ Practice Questions

Core Python MCQs — syntax, data types, OOP, libraries for placements & IT exams.

119 questions | 100% Free

Q.1Hard

What will be the output of the following code? x = [1, 2, 3] x.append([4, 5]) print(len(x))

Q.2Hard

What is the output of: print(2 3 2)?

Q.3Hard

What will be the output of: x = [1, 2, 3] y = x x.append(4) print(y)

Q.4Hard

Which of the following will raise an IndexError?

Q.5Hard

Consider the following code: x = [1, 2, 3] y = x[::-1] print(y) What will be the output?

Q.6Hard

What will be the output of: print({1, 2, 3} | {3, 4, 5})?

Q.7Hard

Which of the following will raise a TypeError in Python?

Q.8Hard

What will be the output of: d = {'a': 1, 'b': 2}; print(list(d.items()))

Q.9Hard

Consider: x = [i**2 for i in range(4)]. What is x?

Q.10Hard

What will be the output of: print(any([False, False, True]))

Q.11Hard

Consider: try: int('abc'); except: print('error'). What will be printed?

Q.12Hard

What is the output of: print(*[1, 2, 3])?

Q.13Hard

Consider: f = lambda x: x**2. What is f(5)?

Q.14Hard

What will be the result of: set([1, 2, 2, 3, 3, 3])?

Q.15Hard

Consider: *a, b = [1, 2, 3]. What is a?

Q.16Hard

What is the output of: print(eval('2+3*4'))?

Q.17Hard

Consider the code: with open('file.txt') as f: data = f.read(). What happens when the block exits?

Q.18Hard

What will be the output of: print({x: x**2 for x in range(3)})?

Q.19Hard

Consider: class A: x = 5. What is A.x and how can it be modified?

Q.20Hard

What is the output of: print(type(lambda x: x))?