Python Interview Prep Questions
String & Character Operations
1. Counting VOWELS in a Given Word
2. Counting CONSONANTS in a Given Word
3. Counting the number of occurrences of a character in a String
4. Removing All Whitespace in a String
5. Comparing Two Strings for ANAGRAMS
6. Checking for PALINDROME Using Extended Slicing Technique
7. Counting the white spaces in a string
8. Counting Digits, Letters, and Spaces in a String
9. Counting Special Characters in a string
10. Reversing a String using Extended Slicing Technique
11. Converting a list into a string
List Operations
12. Finding the Maximum Number in a list
13. Finding the Minimum Number in a List
14. Finding the middle Element in a list
15. Adding Two List Elements Together
16. Randomizing the Items of a List in Python
17. List Compression (to create a list in single line)
Number Properties & Checks
18. Write a program to find GCD of two numbers
19. Check if a number is Krishna Murthy special number or not
20. Find the factors of a number
21. Find if a number is prime or not
22. Check if a number is palindrome or not
23. Check if a number is spy number (sum of digits = product of digits)
24. Check if a number is a special number (sum + product of digits = original number)
25. Check if a number is Harshad/Niven number (divisible by sum of its digits)
26. Check if a number is duck number or not (contains zeros)
27. Check if the number is Neon number (digits of square equal the number)
28. Check if a number is automorphic number or not (contained in square's last digit)
29. Check if a number is perfect number (equal to sum of its divisors)
30. Find if a number is composite number or not
31. Find if the number is an abundant number or deficient
Series & Sequences
32. Writing FIBONACCI Series
33. Arithmetic series - sum of sequences
1+2+3+4 ... N
9 + 13 + 17 ... N
2+4+6+8 ... 20
1+3+5+7... N
10 + 9 + 8 ... N
34. Geometric Series - sum of sequences
2+4+8+ 16.... N
2 + 6 + 18 + 54 .... N
10 + 30 + 90 + 270.... N
5 + 25 + 125 + ....N
Functions & Parameters
35. Implementing variable length arguments in python (*args)
36. What are default arguments in functions?
37. Implementing variable length keyword arguments (**kwargs)
38. What are positional arguments in python?
39. Different types of parameters in python
Pattern Printing
40. Write a program to print the following pattern (asterisk pyramid)
41. Write a program to print the following pattern (number triangle)
42. Write a program to print the following pattern (number sequence)
43. Write a program to print the following pattern (letter patterns A-E)
44. Write a program to print the following pattern (A/BC/DEF/GHIJ/KLMNO)
45. Write a program to print the following pattern (A/AB/ABC/ABCD/ABCDE)
46. Write a program to print the following pattern
(A/ABC/ABCDE/ABCDEFG/ABCDEFGHI)
47. Write a program to print the following pattern
(E/DED/CDCDC/BCDEDBCB/ABCDEDBCBA)
48. Create the following pattern (54321/4321/321/21/1)
49. Create the diamond patterns
50. Print the following pattern (A/CC/EEE/GGGG/IIIII)
51. Print the following pattern (ZZZZZZZZZZ/0000000/ZZZZZ/000/ZZ/0)
52. Create the following pattern (A/ABC/ABCDE/ABCDEFG/ABCDEFGHI)
53. Create the following pattern (A/BCD/EFGHI/JKLMOP/QRSTUVWXY)
54. Create pyramid with 5 rows (asterisk pyramid)
55. Create a sandglass pattern
56. Create a butterfly pattern
57. Create a reverse pyramid
58. Create a hill triangle pattern
59. Parallel vertical lines pattern
60. Square plus pattern
61. Cross pattern
62. Hollow square pattern
63. Hollow increasing triangle
64. Hollow decreasing triangle
65. Hollow hill pattern
66. Hollow diamond pattern
Object-Oriented Programming
67. Creating instance member variables in python
68. What is the init method in python?
69. Creating instance member variables in python
70. What is difference between class object and instance object?
71. How to create static member variables in class?
72. Does python support multiple inheritance?
73. What is name mangling in python?
74. Operator overloading in python
75. How to use else with loop in python?
Advanced OOP Concepts
76. What is monkey patching?
77. Implementing variable length arguments in python
78. Addition using Lambda functions
79. Finding factorial using lambda function
80. What are iterators in python?
81. What are generators in python? (Create a generator for first n natural even
numbers)
82. Create a generator to produce first n prime numbers
83. What are iterators in python?
84. What are commonly used decorators in python?
@classmethod
@staticmethod
@property
Type Conversion & Data Handling
85. Type conversion basics
86. Type conversion
87. What is the use of split and join function of str?
88. Converting an Integer into Decimals
89. Converting a String of Integers into Decimals
90. Extract int type values from a list of heterogeneous element?
91. Convert Numbered string by reversing and converting to character string (ASCII
values)
Functions & Decorators
92. What is python decorator?
93. Function decorators
94. Class Decorators
95. Using decorators to modify function behavior
96. Is Function overloading allowed in python?
97. What are default arguments in functions?
File Handling
98. Opening a file
99. Reading a file
100. Reading file line by line
101. Writing files
102. When you encounter a line that starts with "X-DSPAM-Confidence:" pull apart the line
103. Input file name to read and handle exceptions
Global & Local Variables
104. Global and local variable
105. Globals function
Miscellaneous
106. Building a Pyramid in Python
107. Write a program to print the given number is odd or even
108. Write a program to find the given number is positive or negative
109. Write a program to find the sum of two numbers
110. Accept a number user check whether it is prime or not
111. Printing parameters and variable arguments
112. Difference between sorted and sort function in python