Lists Questions and Answers
Practice ModeShowing 10 of 25 questions
Q21
How do you get a slice from index 2 to 5 (exclusive) from a list?
Answer: Option A
Explanation: Slicing uses start:stop notation, where stop is exclusive.
Q22
What does the copy() method create?
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?
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?
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?
Answer: Option A
Explanation: List comprehension allows creating new lists by applying expression to each item in iterable.