Lists Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q1
Which method is used to add an element to the end of a list in Python?
  • A add()
  • B append()
  • C insert()
  • D push()
Answer: Option B
Explanation: The append() method adds a single element to the end of a list.
Q2
How do you access the last element of a list called "my_list"?
  • A my_list[0]
  • B my_list[last]
  • C my_list[-1]
  • D my_list[end]
Answer: Option C
Explanation: Negative indexing starts from the end of the list, with -1 representing the last element.
Q3
Which method removes and returns the last element from a list?
  • A remove()
  • B delete()
  • C pop()
  • D cut()
Answer: Option C
Explanation: The pop() method without any index removes and returns the last element.
Q4
What is the output of len([1, 2, 3, [4, 5]])?
  • A 4
  • B 5
  • C 6
  • D Error
Answer: Option A
Explanation: The len() function counts the total number of elements in the outer list, including the nested list as one element.
Q5
Which method is used to reverse a list in-place?
  • A reversed()
  • B reverse()
  • C flip()
  • D invert()
Answer: Option B
Explanation: The reverse() method modifies the original list and reverses its elements in-place.
Q6
How do you create a shallow copy of a list?
  • A list.copy()
  • B list[:]
  • C copy(list)
  • D Both A and B
Answer: Option D
Explanation: Slicing with [:] creates a shallow copy of the entire list.
Q7
What does the extend() method do?
  • A Adds a single element to the list
  • B Adds multiple elements from an iterable
  • C Increases the list size by a fixed amount
  • D Creates a new extended list
Answer: Option B
Explanation: extend() adds all elements from an iterable to the end of the list, extending it.
Q8
How do you find the index of the first occurrence of an element in a list?
  • A find()
  • B search()
  • C index()
  • D locate()
Answer: Option C
Explanation: The index() method returns the position of the first occurrence of the specified value.
Q9
Which method removes the first occurrence of a value from a list?
  • A delete()
  • B remove()
  • C pop()
  • D discard()
Answer: Option B
Explanation: The remove() method searches for and removes the first occurrence of the specified value.
Q10
What is the difference between append() and extend()?
  • A No difference
  • B append() adds elements, extend() removes elements
  • C append() adds single element, extend() adds multiple elements
  • D append() works only with strings
Answer: Option C
Explanation: append() adds its argument as a single element, while extend() iterates over its argument adding each element.
Questions and Answers for Competitive Exams Various Entrance Test