Lists Questions and Answers

Take Exam

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")
Show Answer Report

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
Show Answer Report

13. How do you check if an element exists in a list?

  • contains()
  • exists()
  • in
  • has()
Show Answer Report

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
Show Answer Report

15. How do you count occurrences of an element in a list?

  • occurrences()
  • count()
  • frequency()
  • find_all()
Show Answer Report

16. What does the insert() method do?

  • Adds element at beginning
  • Adds element at specified index
  • Replaces element at index
  • Inserts a new list
Show Answer Report

17. How do you remove all elements from a list?

  • delete()
  • remove_all()
  • clear()
  • empty()
Show Answer Report

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
Show Answer Report

19. How do you create a list with numbers from 0 to 9?

  • list(0,9)
  • list(range(10))
  • [0-9]
  • list(10)
Show Answer Report

20. What is the result of "python" in ["java", "python", "c++"]?

  • True
  • False
  • Error
  • None
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test