🐍 Beginner–Intermediate Python Coding
Questions (Practice Only)
Questions are tagged for interview preparation: - 🟢 Easy - 🟡 Medium - 🔵
Interview-Frequent
1. 🟢 🔵 Check if a number is a palindrome (number-based)
o Example: 121 → Palindrome
2. 🟢 🔵 Find the count of digits in a number
o Input: 12345
o Output: 5
3. 🟢 Find sum of odd numbers in a list
4. 🟡 🔵 Find the maximum occurring character in a string
o Input: “success”
o Output: s
5. 🟢 🔵 Remove all spaces from a string
o Input: “python is easy”
o Output: “pythoniseasy”
6. 🟡 🔵 Find the first non-repeating character in a string
o Input: “aabbcddee”
o Output: c
7. 🟢 🔵 Check if a list contains duplicate elements
o Return True / False
8. 🟢 🔵 Find the index of an element manually (without using index())
o Input: [10, 20, 30], element = 20
o Output: 1
9. 🟡 Count number of prime digits in a number
o Input: 23745
o Output: 3 (2, 3, 7)
10. 🟢 🔵 Reverse a number without converting it to a string
Input: 123
Output: 321
11. 🟢 Print multiplication table of a number
Input: 5
12. 🟡 🔵 Check if two numbers are co-prime
Example: 8 & 15 → True
13. 🟢 Find the average of elements in a list (without using sum())
14. 🟡 🔵 Convert a string to title case (without using title())
Input: “python is fun”
Output: “Python Is Fun”
15. 🟡 Count number of trailing zeros in a number
Input: 12000
Output: 3
16. 🟢 Find the difference between sum of even and odd numbers in a
list
17. 🟢 🔵 Find all factors of a number
Input: 12
Output: 1 2 3 4 6 12
18. 🟡 🔵 Replace duplicate characters in a string with *
Input: “programming”
Output: “progamin*”
19. 🟡 🔵 Find the smallest missing positive number in a list
Input: [1, 2, 3, 5]
Output: 4
20. 🟢 Count consonants in a string
21. 🟡 🔵 Check if a string contains only digits (without using isdigit())
22. 🟢 Find the cumulative sum of a list
Input: [1, 2, 3]
Output: [1, 3, 6]
23. 🟡 🔵 Find the frequency of words in a sentence
24. 🟢 🔵 Move all zeros to the end of a list
Input: [1, 0, 2, 0, 3]
Output: [1, 2, 3, 0, 0]
25. 🟢 🔵 Check if two lists are equal (same elements and same order)
26. 🟢 Count occurrences of a digit in a number
Input: 122333, digit = 3
Output: 3
27. 🟢 🔵 Print numbers in a pyramid pattern
Pattern: 1 12 123 1234
28. 🟢 Find the length of a string without using len()
29. 🟢 Find the middle element of a list
30. 🟡 🔵 Check if a number is a Harshad (Niven) number
Example: 18 → True
✅ Ideal for Cognizant GenC, TCS, Infosys, Wipro & Accenture
interviews