iGET

Python Programming - MCQ Practice Questions

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

119 questions | 100% Free

Q.81Hard

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

Q.82Hard

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

Q.83Hard

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

Q.84Hard

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

Q.85Easy

Which of the following is NOT a valid Python variable name?

Q.86Easy

What is the output of: print(10 // 3 + 10 % 3)?

Q.87Easy

What will be the data type of x after executing: x = ?

Q.88Medium

Consider the code: x = [1, 2, 3]; y = x; y.append(4). What is x?

Q.89Easy

What is the output of: print(len('Python'))?

Q.90Medium

What will be printed: print(3 2 2)?

Q.91Medium

Consider: a = 'Hello'; b = 'Hello'. Are a and b the same object?

Q.92Medium

Consider the code: def func(x, y=5): return x + y. What is func(3)?

Q.93Easy

What will be the output of: print(10 if 5 > 3 else 20)?

Q.94Medium

Consider: x = [1, 2, 3, 4, 5]; y = x[1:4]. What is y?

Q.95Easy

What is the output of: print('a' in 'banana')?

Q.96Medium

Consider: d = {'a': 1, 'b': 2}; d['c'] = 3. What is d?

Q.97Easy

What will be the output of: x = 5; x += 3; print(x)?

Q.98Medium

Consider the code: x = (1, 2, 3); x[0] = 5. What happens?

Q.99Medium

What is the output of: print(None == False)?

Q.100Medium

Consider the following code snippet: python x = [1, 2, 3] y = x y.append(4) print(x) What will be the output?