Here’s an extended list of 170+ Python interview coding questions, focusing on
strings, lists, dictionaries, sets, if-else statements, loops, and intermediate
problems on those topics.
Basic Level
Strings
1. Write a program to check if a string is a palindrome.
2. Write a program to count the number of vowels and consonants in a string.
3. Write a program to reverse a string.
4. Write a program to count the number of words in a string.
5. Check if a string contains only digits.
6. Write a program to remove all whitespaces from a string.
7. Write a program to check if a string is an anagram of another string.
8. Write a program to count the occurrences of a character in a string.
9. Write a program to find the length of a string without using the `len()`
function.
10. Convert a string to uppercase and lowercase.
11. Write a program to replace all occurrences of a substring in a string.
12. Write a program to find the index of the first occurrence of a substring.
13. Write a program to capitalize the first letter of each word in a string.
14. Check if a string starts with a specific prefix.
15. Write a program to find the longest word in a string.
16. Write a program to check if two strings are rotations of each other.
Follow me on LinkedIn – Shivakiran kotur
17. Write a program to remove duplicate characters from a string.
18. Write a program to reverse the order of words in a string.
19. Write a program to count the frequency of each character in a string.
20. Write a program to convert a string to a list of characters.
Lists
21. Write a program to find the maximum and minimum elements in a list.
22. Write a program to reverse a list without using built-in functions.
23. Write a program to sort a list of numbers.
24. Write a program to remove duplicates from a list.
25. Write a program to count the occurrences of an element in a list.
26. Write a program to find the sum of all elements in a list.
27. Write a program to find the second largest number in a list.
28. Write a program to merge two sorted lists.
29. Write a program to check if a list is empty.
30. Write a program to concatenate two lists.
31. Write a program to check if an element exists in a list.
32. Write a program to split a list into even and odd numbers.
33. Write a program to find the product of elements in a list.
34. Write a program to count the number of even and odd numbers in a list.
35. Write a program to flatten a nested list.
36. Write a program to rotate a list by a specified number of positions.
37. Write a program to remove all occurrences of a value from a list.
38. Write a program to find the common elements between two lists.
Follow me on LinkedIn – Shivakiran kotur
39. Write a program to split a list into two halves.
40. Write a program to find the cumulative sum of elements in a list.
41. Write a program to find the intersection of two lists.
42. Write a program to find the union of two lists.
43. Write a program to check if two lists are identical.
44. Write a program to convert a list of characters into a string.
45. Write a program to multiply all elements in a list by a given number.
Dictionaries
46. Write a program to create a dictionary from two lists (keys and values).
47. Write a program to access a value by key in a dictionary.
48. Write a program to update the value of a key in a dictionary.
49. Write a program to remove a key from a dictionary.
50. Write a program to merge two dictionaries.
51. Write a program to find the maximum and minimum value in a dictionary.
52. Write a program to count the frequency of each word in a string using a
dictionary.
53. Write a program to check if a key exists in a dictionary.
54. Write a program to iterate over dictionary keys and values.
55. Write a program to invert a dictionary (swap keys and values).
56. Write a program to get a list of all keys and values in a dictionary.
57. Write a program to sort a dictionary by its keys.
58. Write a program to find common keys between two dictionaries.
Follow me on LinkedIn – Shivakiran kotur
59. Write a program to calculate the sum of values in a dictionary.
60. Write a program to remove all duplicate values from a dictionary.
61. Write a program to get the key with the maximum value in a dictionary.
62. Write a program to filter dictionary entries based on their values.
63. Write a program to find keys in a dictionary that have a specific value.
64. Write a program to group elements in a list by frequency using a dictionary.
65. Write a program to sort a dictionary by its values.
Sets
66. Write a program to create a set and add elements to it.
67. Write a program to remove an element from a set.
68. Write a program to find the union of two sets.
69. Write a program to find the intersection of two sets.
70. Write a program to check if a set is a subset of another set.
71. Write a program to find the difference between two sets.
72. Write a program to iterate over the elements of a set.
73. Write a program to convert a list into a set and remove duplicates.
74. Write a program to find the symmetric difference of two sets.
75. Write a program to check if two sets have any common elements.
76. Write a program to check if a set is a superset of another set.
77. Write a program to check if a set is disjoint from another set.
78. Write a program to remove all elements from a set.
79. Write a program to find the smallest and largest elements in a set.
80. Write a program to find the length of a set without using the `len()` function.
Follow me on LinkedIn – Shivakiran kotur
If-Else Statements
81. Write a program to check if a number is positive, negative, or zero.
82. Write a program to check if a number is odd or even.
83. Write a program to check if a year is a leap year.
84. Write a program to find the largest of three numbers.
85. Write a program to check if a string contains a vowel.
86. Write a program to check if a list is empty or not.
87. Write a program to check if a number is divisible by both 3 and 5.
88. Write a program to check if a number is prime.
89. Write a program to print "Hello" if the input number is greater than 10, else
print "Goodbye".
90. Write a program to check if the first and last elements of a list are the same.
91. Write a program to determine the grade based on a student's score.
92. Write a program to check if a string contains only alphabetic characters.
93. Write a program to check if two lists are identical.
94. Write a program to check if a dictionary is empty.
95. Write a program to determine if a number is divisible by a specific number.
Loops
96. Write a program to print the first 10 natural numbers using a loop.
97. Write a program to find the factorial of a number using a loop.
98. Write a program to print the Fibonacci sequence up to n terms using a loop.
Follow me on LinkedIn – Shivakiran kotur
99. Write a program to calculate the sum of all elements in a list using a loop.
100. Write a program to count the number of even numbers in a list using a
loop.
101. Write a program to print all prime numbers between 1 and 100 using a
loop.
102. Write a program to print the multiplication table of a given number using a
loop.
103. Write a program to find the reverse of a number using a loop.
104. Write a program to count the number of digits in a number using a loop.
105. Write a program to find the sum of digits of a number using a loop.
106. Write a program to reverse a list using a loop.
107. Write a program to check if a number is prime using a loop.
108. Write a program to print all even numbers from 1 to 100 using a loop.
109. Write a program to calculate the product of all elements in a list using a
loop.
110. Write a program to find the GCD (Greatest Common Divisor) of two
numbers using a loop.
111. Write a program to print all the characters in a string using a loop.
112. Write a program to print the sum of all even numbers up to n using a loop
113. Write a program to print the sum of all odd numbers up to n using a loop.
114. Write a program to find the factorial of a number using a while loop.
115. Write a program to calculate the sum of the squares of the first n natural
numbers using a loop.
Follow me on LinkedIn – Shivakiran kotur
Intermediate String Problems
116. Write a program to check if a string is a valid palindrome (ignoring spaces
and case).
117. Write a program to find the longest substring without repeating characters.
118. Write a program to count the frequency of each character in a string.
119. Write a program to find the first non-repeating character in a string.
120. Write a program to reverse the words in a given sentence.
121. Write a program to find the longest word in a sentence.
122. Write a program to split a string by a specific delimiter and join it back.
123. Write a program to find the number of uppercase and lowercase letters in a
string.
124. Write a program to find all substrings of a given string.
125. Write a program to remove duplicate characters from a string.
126. Write a program to find all possible permutations of a string.
127. Write a program to find the longest palindromic substring in a given string.
128. Write a program to check if a string contains only alphanumeric characters.
129. Write a program to remove all characters from a string except alphabets.
130. Write a program to check if a string is a valid email address.
Intermediate List Problems
131. Write a program to rotate elements of a list by k positions.
132. Write a program to find the cumulative sum of elements in a list.
Follow me on LinkedIn – Shivakiran kotur
133. Write a program to find the intersection of two lists.
134. Write a program to find all pairs in a list that sum up to a specific number.
135. Write a program to remove all occurrences of a specific element from a list.
136. Write a program to split a list into chunks of size n.
137. Write a program to flatten a list of lists into a single list.
138. Write a program to find the most frequent element in a list.
139. Write a program to find the k largest elements in a list.
140. Write a program to sort a list of tuples based on the second element.
141. Write a program to find all permutations of a list.
142. Write a program to sort a list of dictionaries by a key.
143. Write a program to find the median of a list of numbers.
144. Write a program to count the number of unique elements in a list.
145. Write a program to find the longest increasing subsequence in a list.
Intermediate Dictionary Problems
146. Write a program to merge multiple dictionaries into one.
147. Write a program to count the frequency of elements in a list using a
dictionary.
148. Write a program to group elements of a list based on the frequency in a
dictionary.
149. Write a program to find the key with the maximum value in a dictionary.
150. Write a program to sort a dictionary by its values.
Follow me on LinkedIn – Shivakiran kotur
Intermediate Loop Questions
151. Write a program to find all the duplicate characters in a string.
152. Write a program to generate a list of all unique substrings of a given string.
153. Write a program to count the number of occurrences of each word in a list
of strings.
154. Write a program to sort a list of strings by their lengths.
155. Write a program to merge two lists into a single list, alternating elements
from each list.
156. Write a program to find the most frequent element in a list of integers.
157. Write a program to find all anagrams of a given word from a list of words.
158. Write a program to remove all non-alphabetic characters from a string.
159. Write a program to find the sum of the lengths of all strings in a list.
160. Write a program to count the number of palindromic substrings in a given
string.
161. Write a program to find the common characters between two strings.
162. Write a program to generate all combinations of characters from a given
string.
163. Write a program to find all pairs of elements in a list that sum up to a
specific target value.
164. Write a program to replace all occurrences of a character in a string with
another character.
165. Write a program to find the number of unique words in a list of strings.
Follow me on LinkedIn – Shivakiran kotur
166. Write a program to remove all occurrences of a specific word from a list of
words.
167. Write a program to count the number of vowels in each string in a list of
strings.
168. Write a program to find the index of the last occurrence of a substring in a
given string.
169. Write a program to split a list into two sublists of roughly equal size.
170. Write a program to generate a list of all permutations of a given list of
integers.
171. Write a program to find the longest common prefix among a list of strings.
172. Write a program to count the total number of characters in all strings of a
list.
173. Write a program to find the average length of strings in a list.
This extended list should give you a comprehensive set of interview questions,
covering key Python concepts and scenarios asked in interviews focused on
strings, lists, dictionaries, sets, if-else conditions, and loops.
Follow me on LinkedIn – Shivakiran kotur