Lists Questions and Answers
Python Programming - Lists Questions with Answers explore the most flexible and commonly used data structure. These Python Lists Questions are helpful for Infosys, SSC, and Wipro exams focusing on sequence and iteration concepts
Lists
Showing 10 of
25 questions
21. How do you get a slice from index 2 to 5 (exclusive) from a list?
- list[2:5]
- list[2:4]
- list[2-5]
- list.slice(2,5)
22. What does the copy() method create?
- Deep copy
- Shallow copy
- Reference to original
- Compressed copy
23. How do you concatenate two lists?
- list1 + list2
- list1.append(list2)
- list1.merge(list2)
- concat(list1, list2)
24. What is the time complexity of accessing an element by index in a list?
- O(n)
- O(1)
- O(log n)
- O(n²)
25. How do you create a list of squares for numbers 1-5 using list comprehension?
- [x*x for x in range(1,6)]
- [x^2 for x in [1,2,3,4,5]]
- list(square(x) for x in range(5))
- [for x in range(5): x*x]