Python Interview Questions Level-1

1. What is Python? What are the benefits of using Python?
2. What is PEP8?
3. What is pickling and unpickling?
4. How Python is interpreted?
5. How memory is managed in Python?
6. What are the tools that help to find bugs or perform static analysis?
7. What are Python decorators?
8. What is the difference between list and tuple?
9. How are arguments passed by value or by reference?
10. What is Dict and List comprehensions are?
11. What are the built-in type does python provides?
12. What is namespace in Python?
13. What is lambda in Python?
14. Why lambda forms in python does not have statements?
15. What is pass in Python?
16. In Python what are iterators?
17. What is unittest in Python?
18. In Python what is slicing?
19. What are generators in Python?
20. What is docstring in Python?
21. How can you copy an object in Python?
22. What is negative index in Python?
23. How you can convert a number to a string?
24. What is the difference between Xrange and range?
25. What is module and package in Python?

Python Interview Questions Level-2

26. Mention what are the rules for local and global variables in Python?
27. How can you share global variables across modules?
28. Explain how can you make a Python Script executable on Unix?
29. Explain how to delete a file in Python?
30. Explain how can you generate random numbers in Python?
31. Explain how can you access a module written in Python from C?
32. Mention the use of // operator in Python?
33. Mention five benefits of using Python?
34. Mention the use of the split function in Python?
35. Explain what is Flask & its benefits?
36. Mention what is Flask-WTF and what are their features?
37. Explain what is the common way for the Flask script to work?
38. Explain how you can access sessions in Flask?
39. Is Flask an MVC model and if yes give an example showing MVC pattern for your application?
40. Explain database connection in Python Flask?
41. You are having multiple Memcache servers running Python, in which one of the memcacher server fails, and it has your data, will it ever try to get key data from that one failed server?
42. Explain how you can minimize the Memcached server outages in your Python Development?
43. Explain what is Dogpile effect? How can you prevent this effect?
44. Explain how Memcached should not be used in your Python project?
45. What is Python?
46. Name some of the features of Python.
47. What is the purpose of PYTHONPATH environment variable?
48. What is the purpose of PYTHONSTARTUP environment variable?
49. What is the purpose of PYTHONCASEOK environment variable?
50. What is the purpose of PYTHONHOME environment variable?

Python Interview Questions Level-3

51. Is python a case sensitive language?
52. What are the supported data types in Python?
53. What is the output of print str if str = 'Hello World!'?
54. What is the output of print str[0] if str = 'Hello World!'?
55. What is the output of print str[2:5] if str = 'Hello World!'?
56. What is the output of print str[2:] if str = 'Hello World!'?
57. What is the output of print str * 2 if str = 'Hello World!'?
58. What is the output of print str + "TEST" if str = 'Hello World!'?
59. What is the output of print list if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
60. What is the output of print list[0] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
61. What is the output of print list[1:3] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
62. What is the output of print list[2:] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
63. What is the output of print tinylist * 2 if tinylist = [123, 'john']?
64. What is the output of print list1 + list2, if list1 = [ 'abcd', 786 , 2.23, 'john', 70.2 ] and ist2 = [123, 'john']?
65. What are tuples in Python?
66. What is the difference between tuples and lists in Python?
67. What is the output of print tuple if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?
68. What is the output of print tuple[0] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?
69. What is the output of print tuple[1:3] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?
70. What is the output of print tuple[2:] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?
71. What is the output of print tinytuple * 2 if tinytuple = (123, 'john')?
72. What is the output of print tuple + tinytuple if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 ) and tinytuple = (123, 'john')?
73. What are Python's dictionaries?
74. How will you create a dictionary in python?
75. How will you get all the keys from the dictionary?

Python Interview Questions Level-4

76. How will you get all the values from the dictionary?
77. How will you convert a string to an int in python?
78. How will you convert a string to a long in python?
79. How will you convert a string to a float in python?
80. How will you convert a object to a string in python?
81. How will you convert a object to a regular expression in python?
82. How will you convert a String to an object in python?
83. How will you convert a string to a tuple in python?
84. How will you convert a string to a list in python?
85. How will you convert a string to a set in python?
86. How will you create a dictionary using tuples in python?
87. How will you convert a string to a frozen set in python?
88. How will you convert an integer to a character in python?
89. How will you convert an integer to an unicode character in python?
90. How will you convert a single character to its integer value in python?
91. How will you convert an integer to hexadecimal string in python?
92. How will you convert an integer to octal string in python?
93. What is the purpose of ** operator?
94. What is the purpose of // operator?
95. What is the purpose of is operator?
96. What is the purpose of not in operator?
97. What is the purpose break statement in python?
98. What is the purpose continue statement in python?
99. What is the purpose pass statement in python?
100. How can you pick a random item from a list or tuple?

Python Interview Questions Level-5

101. How can you pick a random item from a range?
102. How can you get a random number in python?
103. How will you set the starting value in generating random numbers?
104. How will you randomizes the items of a list in place?
105. How will you capitalizes first letter of string?
106. How will you check in a string that all characters are alphanumeric?
107. How will you check in a string that all characters are digits?
108. How will you check in a string that all characters are in lowercase?
109. How will you check in a string that all characters are numerics?
110. How will you check in a string that all characters are whitespaces?
111. How will you check in a string that it is properly titlecased?
112. How will you check in a string that all characters are in uppercase?
113. How will you merge elements in a sequence?
114. How will you get the length of the string?
115. How will you get a space-padded string with the original string left-justified to a total of width columns?
116. How will you convert a string to all lowercase?
117. How will you remove all leading whitespace in string?
118. How will you get the max alphabetical character from the string?
119. How will you get the min alphabetical character from the string?
120. How will you replaces all occurrences of old substring in string with new string?
121. How will you remove all leading and trailing whitespace in string?
122. How will you change case for all letters in string?
123. How will you get titlecased version of string?
124. How will you convert a string to all uppercase?
125. How will you check in a string that all characters are decimal?

Python Interview Questions Level-6

126. What is the difference between del() and remove() methods of list?
127. How Do We Write A Function In Python?
128. What Is A Function Call Or A Callable Object In Python?
129. What Is The Return Keyword Used For In Python?
130. What Is “Call By Value” In Python?
131. What Is “Call By Reference” In Python?
132. What Is The Return Value Of The Trunc() Function?
133. Is It Mandatory For A Python Function To Return A Value?
134. What Does The Continue Do In Python?
135. What Is The Purpose Of Id() Function In Python?
136. What is the output of len([1, 2, 3])?
137. What is the output of [1, 2, 3] + [4, 5, 6]?
138. What is the output of ['Hi!'] * 4?
139. What is the output of 3 in [1, 2, 3]?
140. What is the output of for x in [1, 2, 3]: print x?
141. What is the output of L[2] if L = [1,2,3]?
142. What is the output of L[-2] if L = [1,2,3]?
143. What is the output of L[1:] if L = [1,2,3]?
144. How will you compare two lists?
145. How will you get the length of a list?
146. How will you get the max valued item of a list?
147. How will you get the min valued item of a list?
148. How will you get the index of an object in a list?
149. How will you insert an object at given index in a list?
150. How will you remove last object from a list?

Python Interview Questions Level-7

151. How will you remove an object from a list?
152. How will you reverse a list?
153. How will you sort a list?
154. What is lambda function in python?
155. What we call a function which is incomplete version of a function?
156. When a function is defined then the system stores parameters and local variables in an area of memory. What this memory is known as?
157. A canvas can have a foreground color? (Yes/No)
158. Is Python platform independent?
159. Do you think Python has a complier?
160. What are the applications of Python?
161. Is String in Python are immutable? (Yes/No)
162. Can True = False be possible in Python?
163. Which module of python is used to apply the methods related to OS.?
164. When does a new block begin in python?
165. Write a function in python which detects whether the given two strings are anagrams or not.
166. Name the python Library used for Machine learning.
167. What does pass operation do?
168. Name the tools which python uses to find bugs (if any).
169. Write a function to give the sum of all the numbers in list? Sample list − (100, 200, 300, 400, 0, 500) Expected output − 1500
172. Write a program in Python to reverse a string without using inbuilt function reverse string?
173. Write a program to test whether the number is in the defined range or not?
174. Write a program to calculate number of upper case letters and number of lower case letters?Test on String: ''Inisrav''
175. What Is Python, What Are The Benefits Of Using It, And What Do You Understand Of PEP 8?

Python Interview Questions Level-8

176. What Is The Statement That Can Be Used In Python If The Program Requires No Action But Requires It Syntactically?
177. What’s The Process To Get The Home Directory Using ‘~’ In Python?
178. What Are The Built-In Types Available In Python?
179. How To Find Bugs Or Perform Static Analysis In A Python Application?
180. When Is The Python Decorator Used?
181. What Is The Principal Difference Between A List And The Tuple?
182. How Does Python Handle Memory Management?
183. What Are The Principal Differences Between The Lambda And Def?
184. Write A Reg Expression That Confirms An Email Id Using The Python Reg Expression Module “Re”?
185. What Do You Think Is The Output Of The Following Code Fragment? Is There Any Error In The Code?
186. Is There A Switch Or Case Statement In Python? If Not Then What Is The Reason For The Same?
187. What Is A Built-In Function That Python Uses To Iterate Over A Number Sequence?
188. What Are The Optional Statements Possible Inside A Try-Except Block In Python?
189. What Is A String In Python?
190. What Is Slicing In Python?
191. What Is %S In Python?
192. Is A String Immutable Or Mutable In Python?
193. What Is The Index In Python?
194. What Is A Function In Python Programming?
195. How Many Basic Types Of Functions Are Available In Python?
196. What Does The *Args Do In Python?
197. What Does The **Kwargs Do In Python?
198. Does Python Have A Main() Method?
199. What Does The __ Name __ Do In Python?
200. What Is The Purpose Of “End” In Python?

Python Interview Questions Level-9

201. When Should You Use The “Break” In Python?
202. What Is The Difference Between Pass And Continue In Python?
203. What Does The Len() Function Do In Python?
204. What Does The Chr() Function Do In Python?
205. What Does The Ord() Function Do In Python?
206. What Is Rstrip() In Python?
207. What Is Whitespace In Python?
208. What Is Isalpha() In Python?
209. How Do You Use The Split() Function In Python?
210. What Does The Join Method Do In Python?
211. What Does The Title() Method Do In Python?
212. What Makes The CPython Different From Python?
213. Which Package Is The Fastest Form Of Python?
214. What Is GIL In Python Language?
215. How Is Python Thread Safe?
216. How Does Python Manage The Memory?
217. How Do You Handle Exceptions With Try/Except/Finally In Python?
218. How Do You Raise Exceptions For A Predefined Condition In Python?
219. What Are Python Iterators?
220. What Is The Difference Between An Iterator And Iterable?
221. What Are Python Generators?
222. What Are Closures In Python?
223. What Are Decorators In Python?
224. How Do You Create A Dictionary In Python?
225. How Do You Read From A Dictionary In Python?

Python Interview Questions Level-10

226. How Do You Traverse Through A Dictionary Object In Python?
227. How Do You Add Elements To A Dictionary In Python?
228. How Do You Delete Elements Of A Dictionary In Python?
229. How Do You Check The Presence Of A Key In A Dictionary?
230. What Is The Syntax For List Comprehension In Python?
231. What Is The Syntax For Dictionary Comprehension In Python?
232. What Is The Syntax For Generator Expression In Python?
233. How Do You Write A Conditional Expression In Python?
234. What Do You Know About The Python Enumerate?
235. What Is The Use Of Globals() Function In Python?
236. Why Do You Use The Zip() Method In Python?
237. What Are Class Or Static Variables In Python Programming?
238. How Does The Ternary Operator Work In Python?
239. What Does The “Self” Keyword Do?
240. What Are The Different Methods To Copy An Object In Python?
241. What Is The Purpose Of Doc Strings In Python?
242. Which Python Function Will You Use To Convert A Number To A String?
243. How Do You Debug A Program In Python? Is It Possible To Step Through The Python Code?
244. List Down Some Of The PDB Commands For Debugging Python Programs?
245. What Is The Command To Debug A Python Program?
246. What Is The Set Object In Python?
247. What Is The Use Of The Dictionary In Python?
248. Is Python List A Linked List?
249. What Is Class In Python?
250. What Are Attributes And Methods In A Python Class?

Python Interview Questions Level-11

251. What Is Composition In Python?
252. How Do You Monitor The Code Flow Of A Program In Python?
253. Why And When Do You Use Generators In Python?
254. What Does The Yield Keyword Do In Python?
255. How To Convert A List Into Other Data Types?
256. How Do You Count The Occurrences Of Each Item Present In The List Without Explicitly Mentioning Them?
257. What Is NumPy And How Is It Better Than A List In Python?
258. What Are Different Ways To Create An Empty NumPy Array In Python?
259. What is List in Python?
260. When do you choose a list over a tuple?
261. How do you get the last value in a list or a tuple?
262. What is Index Out Of Range Error?
263. What is slice notation in Python to access elements in an iterator?
264. How do you convert a list of integers to a comma separated string?
265. What is a Variable in Python?
266. How do you find the type and identification number of an object in Python?
267. How do you represent binary and hexadecimal numbers?
268. What are the Arithmetic Operators that Python supports?
269. What are the basic Data Types Supported by Python?
270. How do you check whether the two variables are pointing to the same object in Python?
271. What is for-else and while-else in Python?
272. How do you programmatically know the version of Python you are using?
273. How do you find the number of references pointing to a particular object?
274. How do you dispose a variable in Python?
275. What is the difference between range() and xrange() functions in Python?

Python Interview Questions Level-12

276. What are the generator functions in Python?
277. Write a generator function to generate a Fibonacci series?
278. What are the ideal naming conventions in Python?
279. What happens in the background when you run a Python file?
280. What is a module in Python?
281. How do you include a module in your Python file?
282. How do you reload a Python module?
283. What is the difference between Python append () and extend () functions?
284. What is List Comprehension? Give an Example.
285. Tell me about a few string operations in Python?
286. How do you create a list which is a reverse version on another list in Python?
287. What is a dictionary in Python?
288. How do you merge one dictionary with the other?
289. How to walk through a list in a sorted order without sorting the actual list?
290. Name some standard Python errors you know?
291. What happens with the following function definition?
292. How Python supports encapsulation with respect to functions?
293. What is a decorator?
294. What is PEP8?
295. What is the basic difference between Python version 2 and Python version 3?
296. Which programming Language is an implementation of Python programming language designed to run on Java Platform?
297. Is there any double data type in Python?
298. What Is A Tuple In Python?
299. What Is A Dictionary In Python Programming?
300. What Are Errors And Exceptions In Python Programs?
301. How To Assign Values For The Class Attributes At Runtime?
302. What Is Inheritance In Python Programming?