Python Interview questions

Python Interview questions

1) What is Python? What are the benefits of using Python and its main features?
2) What is PEP 8?
3) What Are The Built-In Types Available In Python?
4) What is mutable and immutable objects in python?
5) Difference between remove, pop, del on lists?
6) What is the difference between list and tuple?
7) What are tuples?
8) What is difference between tuple and list ? Where will you use tuple and where will you use list ?
9) What is Dynamic Typing ?
10) What are args, *kwargs ? 11) How instance variables are different from class variables? 12) Differentiate between .py” file and “.pyc” file?
13) Explain the use “with” statement in python?
14) What does the “self” keyword do?
15) What Are Different Methods To Copy an Object In Python?
16) What does the keyword do in Python?
17) What is pickling and unpickling?
18) How are arguments passed by value or by reference?
19) What is namespace in Python?
20) How you can convert a number to a string?
21) What is module and package in Python?
22) What is a pass in Python?
23) Write a function to merge the two lists into one sorted list:
X = [2, 5, 7, 10, 11, 18]
Y = [1, 4, 6, 12, 14, 17, 21]
24) How can we get home directory using ‘~’ in Python?
25) Difference between range and xrange?
26) Generators in Python and its use?
27) What are Iterators ?
28) How to debug python code using PDB?
29) What Lambda and use in Python?
30) How does Python handle the memory management?
31) What is monkey patching? How can you do it in Python?
32) Why are functions considered first class objects in Python?
33) How will you reverse the list in Python?
34) Explain how can you generate random numbers in Python?
35) Explain the usage of decorators?
36) How is Multithreading achieved in Python?
37) How can the ternary operators be used in python?
38) How is memory managed in Python?
39) Explain Inheritance in Python with an example?
40) What is the usage of help() and dir() function in Python?
41) Whenever Python exits, why isn’t all the memory de-allocated?
42) What is dictionary in Python?
43) What does this mean: *args, **kwargs? And why would we use it?
44) How can you randomize the items of a list in place in Python?
45) What is the process of compilation and linking in python?
46) Write a sorting algorithm for a numerical dataset in Python?
47) Explain split(), sub(), subn() methods of “re” module in Python?
48) What is pickling and unpickling?