Lists Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q21
How do you get a slice from index 2 to 5 (exclusive) from a list?
  • A list[2:5]
  • B list[2:4]
  • C list[2-5]
  • D list.slice(2,5)
Answer: Option A
Explanation: Slicing uses start:stop notation, where stop is exclusive.
Q22
What does the copy() method create?
  • A Deep copy
  • B Shallow copy
  • C Reference to original
  • D Compressed copy
Answer: Option B
Explanation: copy() creates a shallow copy of the list, containing references to the same objects as the original.
Q23
How do you concatenate two lists?
  • A list1 + list2
  • B list1.append(list2)
  • C list1.merge(list2)
  • D concat(list1, list2)
Answer: Option A
Explanation: The + operator concatenates two lists, creating a new list with elements from both.
Q24
What is the time complexity of accessing an element by index in a list?
  • A O(n)
  • B O(1)
  • C O(log n)
  • D O(n²)
Answer: Option B
Explanation: Python lists are implemented as arrays, allowing O(1) constant time access by index.
Q25
How do you create a list of squares for numbers 1-5 using list comprehension?
  • A [x*x for x in range(1,6)]
  • B [x^2 for x in [1,2,3,4,5]]
  • C list(square(x) for x in range(5))
  • D [for x in range(5): x*x]
Answer: Option A
Explanation: List comprehension allows creating new lists by applying expression to each item in iterable.
Questions and Answers for Competitive Exams Various Entrance Test