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? my_list = [1, 2, 3] my_list.append(4) print(len(my_list))
Which of the following is NOT a valid Python data type?
What will be the type of x after executing: x = [1, 2.5, 'hello']?
Which method removes and returns the last element from a list?
What will be the output? my_list = [1, 2, 3, 4, 5] print(my_list[1:3])
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)
What will be the output? my_list = [1, 2, 3] my_list_copy = my_list my_list[0] = 99 print(my_list_copy[0])
What is the correct way to create a true copy of a list?
What will be the output? my_list = [1, 2, 3, 4, 5] print(my_list[-2])
What will be the result of executing this code? my_list = [1, 2, 3] my_list.insert(1, 99) print(my_list)
What will be printed? my_list = [1, 2, 3, 4, 5] print(my_list[::-1])