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
1. Which method is used to add an element to the end of a list in Python?
- add()
- append()
- insert()
- push()
2. How do you access the last element of a list called "my_list"?
- my_list[0]
- my_list[last]
- my_list[-1]
- my_list[end]
3. Which method removes and returns the last element from a list?
- remove()
- delete()
- pop()
- cut()
5. Which method is used to reverse a list in-place?
- reversed()
- reverse()
- flip()
- invert()
6. How do you create a shallow copy of a list?
- list.copy()
- list[:]
- copy(list)
- Both A and B
7. What does the extend() method do?
- Adds a single element to the list
- Adds multiple elements from an iterable
- Increases the list size by a fixed amount
- Creates a new extended list
8. How do you find the index of the first occurrence of an element in a list?
- find()
- search()
- index()
- locate()
9. Which method removes the first occurrence of a value from a list?
- delete()
- remove()
- pop()
- discard()
10. What is the difference between append() and extend()?
- No difference
- append() adds elements, extend() removes elements
- append() adds single element, extend() adds multiple elements
- append() works only with strings