Python Programming - MCQ Practice Questions
Core Python MCQs — syntax, data types, OOP, libraries for placements & IT exams.
119 questions | 100% Free
Consider: a = 'Hello'; b = 'Hello'. Are a and b the same object?
Consider the code: def func(x, y=5): return x + y. What is func(3)?
Consider: x = [1, 2, 3, 4, 5]; y = x[1:4]. What is y?
Consider: d = {'a': 1, 'b': 2}; d['c'] = 3. What is d?
Consider the code: x = (1, 2, 3); x[0] = 5. What happens?
What is the output of: print(None == False)?
Consider the following code snippet: python x = [1, 2, 3] y = x y.append(4) print(x) What will be the output?
What is the output of: len([1, [2, 3], 4, [5, [6, 7]]])?
Which statement correctly creates a list of numbers from 1 to 5?
What will be printed? my_list = [10, 20, 30] my_list[1] = 25 print(my_list)
Which of the following will return True? my_list = [1, 2, 3] result = 2 in my_list
What is the difference between list and tuple in Python?
What will be the output? my_list = [1, 2, 3] my_list.extend([4, 5]) print(my_list)
How many times will the value 2 appear in the output? my_list = [1, 2, 2, 3, 2, 4] print(my_list.count(2))
What will be the output? my_list = [[1, 2], [3, 4], [5, 6]] print(my_list[1][0])
What will this code produce? my_list = [3, 1, 4, 1, 5] my_list.sort() print(my_list)