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
11. How do you sort a list in descending order?
- list.sort(reverse=True)
- list.descend()
- list.reverse_sort()
- sorted(list, order="desc")
12. What is list comprehension in Python?
- A method to understand list contents
- A way to document lists
- A concise way to create lists
- A list analysis tool
13. How do you check if an element exists in a list?
- contains()
- exists()
- in
- has()
14. What is the result of [1, 2, 3] * 3?
- [3, 6, 9]
- [[1,2,3], [1,2,3], [1,2,3]]
- [1, 2, 3, 1, 2, 3, 1, 2, 3]
- Error
15. How do you count occurrences of an element in a list?
- occurrences()
- count()
- frequency()
- find_all()
16. What does the insert() method do?
- Adds element at beginning
- Adds element at specified index
- Replaces element at index
- Inserts a new list
17. How do you remove all elements from a list?
- delete()
- remove_all()
- clear()
- empty()
18. What is the difference between sort() and sorted()?
- No difference
- sort() works on strings, sorted() on numbers
- sort() modifies original, sorted() returns new list
- sorted() is faster
19. How do you create a list with numbers from 0 to 9?
- list(0,9)
- list(range(10))
- [0-9]
- list(10)
20. What is the result of "python" in ["java", "python", "c++"]?
- True
- False
- Error
- None