🔹 If-Else & Loop Based (6)
1. Write a program to check if a given year is a leap year without using Python’s built-
in calendar module.
2. Given an integer, determine if it is a Harshad number (divisible by sum of digits).
3. Print a diamond star pattern of size n using loops.
4. Write a program to reverse an integer without converting it to a string.
5. Find the nth Fibonacci number using iteration (no recursion).
6. Write a program to check whether a number is an Armstrong number.
🔹 Lists (7)
7. Rotate a list by k positions to the right without using slicing.
8. Find the second largest element in a list without using max() twice.
9. Given a list of numbers, return a list of numbers that appear more than once.
10. Merge two sorted lists into a single sorted list without4 using sorted().
11. Write a program to check if two lists are cyclic permutations of each other.
12. Rearrange a list so that positive and negative numbers alternate, preserving order.
13. Find the longest increasing subsequence in a list (not just consecutive).
🔹 Strings (8)
14. Check if two strings are anagrams without using [Link].
15. Find the longest substring without repeating characters.
16. Implement a function to check if a string is a valid palindrome ignoring case and
non-alphanumeric characters.
17. Count how many times each character appears in a string without using
[Link].
18. Find the longest common prefix among a list of strings.
19. Write a function to perform run-length encoding of a string (e.g., "aaabbc" →
"a3b2c1").
20. Given a string of parentheses ()[]{}, check if it is balanced.
21. Find the minimum window substring containing all characters of another string.
🔹 Tuples (4)
22. Write a program to sort a list of tuples by the second element.
23. Given a list of tuples (name, score), return the name(s) with the highest score.
24. Swap two tuples without using a temporary variable.
25. Write a function that takes a tuple of integers and returns a tuple with all duplicates
removed.
🔹 Sets (5)
26. Write a program to find the symmetric difference of two sets without using built-in
operators.
27. Given two sets, check if one is a subset of the other without using .issubset().
28. Find all pairs (a, b) such that a belongs to set A, b belongs to set B, and (a+b) is
even.
29. Count the number of unique elements across multiple lists using sets.
30. Write a program to find the intersection of three sets.
🔹 Dictionaries (7)
31. Write a program to invert a dictionary (keys become values and vice versa).
32. Merge two dictionaries, summing values for common keys.
33. Sort a dictionary by its values (ascending and descending).
34. Write a program to check if two dictionaries are equal, considering nested
dictionaries.
35. Given a dictionary of words and frequencies, find the top 3 most common words.
36. Convert two lists into a dictionary, but if a key already exists, append the value
instead of overwriting.
37. Implement a function to group words into anagrams using a dictionary.
🔹 Mixed / Trickier Logic (3)
38. Find the first non-repeating character in a string using a dictionary.
39. Implement a word frequency counter from a paragraph, ignoring case and
punctuation.
40. Write a function that takes a nested list (matrix) and returns its transpose.
🔹 Counter / Collections (7)
1. Use Counter to find the k most common words in a paragraph.
2. Use Counter to check if two strings are anagrams.
3. Find the character frequency in a string using Counter, but return only characters
that appear more than once.
4. Given a list of numbers, use Counter to find which number(s) appear the maximum
times.
5. Use Counter to compare two lists and find elements missing in one list.
6. Given a sentence, return the top 3 most frequent bigrams (pairs of consecutive
words).
7. Use Counter to check if one string is a sub-multiset of another.
🔹 map / filter / reduce (9)
8. Use map() to square every number in a list.
9. Use map() to convert a list of strings to integers, handling errors with try/except.
10. Use filter() to return only prime numbers from a list.
11. Use filter() to extract all words longer than 5 characters from a list of strings.
12. Use reduce() to compute the greatest common divisor (GCD) of a list of numbers.
13. Use reduce() to flatten a list of lists into a single list.
14. Use map() and reduce() together to compute the sum of squares of numbers in a
list.
15. Use filter() and map() to get the uppercase versions of strings that start with a
vowel.
16. Use reduce() to find the longest string in a list of strings.
🔹 Lists / Comprehensions (7)
17. Write a list comprehension to flatten a matrix (list of lists).
18. Use list comprehension to extract all numbers divisible by 7 but not 5 between 1 and
100.
19. Use a list comprehension to create a list of (i, j) pairs where i+j is even.
20. Remove duplicates from a list while preserving order (without using set).
21. Partition a list into two lists: one containing even numbers, the other odd numbers.
22. Write a program to rotate a matrix 90° clockwise.
23. Implement spiral traversal of a 2D list.
🔹 Strings (6)
24. Write a program to check if a string can be rearranged into a palindrome.
25. Find the longest palindromic substring in a string.
26. Use zip() to check if two strings are Hamming distance ≤ 1.
27. Count the number of words that are rotations of each other in a list.
28. Reverse the words in a sentence, but keep the order of characters inside words intact.
29. Write a program to implement Caesar cipher (shift each character by k positions).
30. Write a program to get all combinations of a string.
🔹 Tuples / Sets (4)
30. Write a program to generate all possible permutations of a tuple.
31. Given two sets of intervals, merge overlapping intervals.
32. Check if a set of points in 2D forms a parallelogram.
33. Given a set of integers, find all triplets that sum to zero.
🔹 Dictionaries (6)
34. Create a dictionary that maps each character in a string to the indices where it
appears.
35. Invert a dictionary where multiple keys may share the same value.
36. Given a dictionary of employees {name: salary}, find the top 3 salaries.
37. Create a dictionary of {word: length} for all words in a sentence.
38. Merge multiple dictionaries into one, summing values of duplicate keys.
39. Write a program to convert a nested dictionary into a flattened dictionary (a.b.c:
value).
🔹 Mixed / Advanced Logic (1)
40. Implement groupby logic (like [Link]) to group consecutive elements
in a list.