Python Programming - MCQ Practice Questions
Core Python MCQs — syntax, data types, OOP, libraries for placements & IT exams.
119 questions | 100% Free
What will be the output of the following code? x = [1, 2, 3] x.append([4, 5]) print(len(x))
What is the output of: print(2 3 2)?
What will be the output of: x = [1, 2, 3] y = x x.append(4) print(y)
Which of the following will raise an IndexError?
Consider the following code: x = [1, 2, 3] y = x[::-1] print(y) What will be the output?
What will be the output of: print({1, 2, 3} | {3, 4, 5})?
Which of the following will raise a TypeError in Python?
What will be the output of: d = {'a': 1, 'b': 2}; print(list(d.items()))
Consider: x = [i**2 for i in range(4)]. What is x?
What will be the output of: print(any([False, False, True]))
Consider: try: int('abc'); except: print('error'). What will be printed?
What is the output of: print(*[1, 2, 3])?
Consider: f = lambda x: x**2. What is f(5)?
What will be the result of: set([1, 2, 2, 3, 3, 3])?
Consider: *a, b = [1, 2, 3]. What is a?
What is the output of: print(eval('2+3*4'))?
Consider the code: with open('file.txt') as f: data = f.read(). What happens when the block exits?
What will be the output of: print({x: x**2 for x in range(3)})?
Consider: class A: x = 5. What is A.x and how can it be modified?
What is the output of: print(type(lambda x: x))?