Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

ProgramsPython

List Programs

sum, sort, slice, duplicates. Most interview warm-ups are this file.

25 programs · open one, then the next

The matching chapter is Day 5: Lists and List Methods in the Python course. For a short check, try the Python quiz (300 questions). Every topic is listed on Python exercises.

Start with Sum of List Elements
  1. 01Sum of List ElementsBeginnerRead a row of Python numbers, convert each token, and sum the list. New programmers follow split, map, and float while handling blank or malformed responses.Open example →
  2. 02Largest Element in ListBeginnerFind a Python list maximum without sorting the input. A beginner numeric example explains empty-list protection, repeated maxima, and all-negative collections.Open example →
  3. 03Smallest Element in ListBeginnerPick the least Python numeric value without changing list order. Beginners follow parsing, guard empty input, and avoid comparing number-like tokens as strings.Open example →
  4. 04Count Occurrences in ListBeginnerCount complete Python list items rather than substrings inside them. A beginner list.count exercise explains repeated matches, missing targets, and text equality.Open example →
  5. 05Remove Duplicates from ListBeginnerKeep first appearances while removing Python list duplicates. Beginners give a set the lookup job and a result list the ordering job, without sorting the input.Open example →
  6. 06Merge Two ListsBeginnerJoin two Python lists end to end with + and keep every occurrence. New programmers distinguish a new outer list from mutation, deduplication, or a sorted merge.Open example →
  7. 07Intersection of ListsBeginnerKeep values shared by two Python lists with set &. Beginner membership practice removes repeated copies and explains why the printed result order can change.Open example →
  8. 08Union of ListsBeginnerCombine distinct Python values from either list with set |. A beginner contrast with concatenation explains lost duplicates and the lack of a guaranteed order.Open example →
  9. 09Sort ListBeginnerSort Python numbers in place without assigning the None result. Beginners compare list.sort with sorted and see how conversion prevents text-order mistakes.Open example →
  10. 10Reverse ListBeginnerReverse Python list positions with a slice instead of sorting values. Beginner examples retain the source order and explain why the new list is a shallow copy.Open example →
  11. 11Check if List is SortedBeginnerTest Python non-decreasing order by comparing with a sorted copy. Beginners allow equal neighbors, include empty lists, and keep the original sequence untouched.Open example →
  12. 12Find Second Largest ElementBeginnerRepeated maxima should not fill both ranks in a distinct Python runner-up task. Beginners combine set, sorted, a length check, and negative indexing safely.Open example →
  13. 13Find N Largest ElementsBeginnerTake a prefix of a descending Python sorted list to select N largest entries. Beginners retain duplicates and handle requests longer than the available input.Open example →
  14. 14Clone / Copy ListBeginnerAssignment is not a Python list copy. Compare full slicing with list construction in a beginner example that explains aliasing and shared nested mutable objects.Open example →
  15. 15Rotate ListBeginnerMove the final K Python list items to the front with two slices. Beginners wrap large steps with modulo and test zero, negative steps, and an empty collection.Open example →
  16. 16Remove Empty ListsBeginnerFilter empty Python sublists with truthiness rather than manual deletion. Beginners parse literal data without eval and learn why [0] still belongs in the result.Open example →
  17. 17Flatten Nested ListIntermediateRead a Python nested comprehension in outer-then-inner order. A beginner flattening example parses literal data and removes one nesting level, not every level.Open example →
  18. 18Find Common Elements of Two ListsBeginnerPreserve Python first-list order while keeping entries also present in a second list. Beginners compare duplicate-preserving filtering with set intersection.Open example →
  19. 19List Slicing ProgramsBeginnerTry first-N, last-N, and stepped Python list slices in one beginner exercise. See exclusive stops, safe oversized bounds, and zero-count and zero-step traps.Open example →
  20. 20Replace List ElementsBeginnerChoose a replacement for each matching Python list entry with a conditional expression. Beginners keep nonmatches, list length, and the original list.Open example →
  21. 21Remove Element by ValueBeginnerDelete one matching Python list entry, not every duplicate, with remove. Beginners check membership first and avoid assigning the method’s None return value.Open example →
  22. 22Count Prime Numbers in ListIntermediateReuse a Python primality helper to count list occurrences. Beginners reject values below two, stop at a divisor, and keep repeated primes in the final total.Open example →
  23. 23Pair Sum ProblemIntermediateFind a Python pair sum by remembering earlier values in a set. Beginners check the missing partner before insertion so one entry cannot pair with itself.Open example →
  24. 24Unique Elements from Both ListsIntermediateKeep Python values belonging to exactly one list with set ^. Beginners distinguish symmetric difference from union and one-way filtering without assuming order.Open example →
  25. 25List DifferenceBeginnerFilter Python first-list entries that never appear in the second list. A beginner directional-difference exercise preserves unmatched repeats and input order.Open example →