Python Arrays Questions and Answers

Take Exam

Python Programming - Arrays Questions with Answers explain how to store and access multiple values efficiently. These Python Arrays Questions are essential for TCS, SSC, and Infosys exams covering fundamental data structure concepts

Python Arrays

Showing 10 of 25 questions

11. How do you get the number of elements in a Python list?

  • len(list)
  • list.size()
  • list.length()
  • list.count()
Show Answer Report

12. What is list comprehension in Python?

  • A concise way to create lists
  • A method to comprehend list structure
  • A way to read lists from files
  • A technique to compress lists
Show Answer Report

13. Which method removes all elements from a list?

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

14. What is the output of [x**2 for x in range(5) if x % 2 == 0]?

  • [0, 4, 16]
  • [0, 1, 4, 9, 16]
  • [0, 4]
  • [1, 9]
Show Answer Report

15. How do you sort a list in descending order?

  • sort(reverse=True)
  • sort(descending=True)
  • sort(order="desc")
  • reverse_sort()
Show Answer Report

16. What is the difference between sort() and sorted()?

  • sort() modifies in-place, sorted() returns new list
  • sort() is faster than sorted()
  • sorted() works only for numbers
  • There is no difference
Show Answer Report

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

  • element in list
  • list.contains(element)
  • list.exists(element)
  • list.find(element) != -1
Show Answer Report

18. What does the slice notation list[1:4] return?

  • Elements from index 1 to 3
  • Elements from index 1 to 4
  • First 4 elements
  • Elements from index 0 to 3
Show Answer Report

19. How do you create a list with 5 zeros?

  • [0] * 5
  • list(5, 0)
  • zeros(5)
  • list.zeros(5)
Show Answer Report

20. What is the output of max([1, 5, 2, 8, 3])?

  • 8
  • 1
  • 5
  • 3
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test