PYTHON INTERVIEW QUESTIONS
1. What are Python’s key features? Why is it called a dynamically typed language?
2. What is the difference between is and == in Python?
3. Explain Python’s memory management. How are variables stored and passed?
4. What is the difference between mutable and immutable data types in Python? Give examples?
5. How does Python handle variable scope? Explain LEGB rule?
6. What are metaclasses in Python? When would you use one?
7. What is monkey patching? Is it a good practice?
8. What is the Global Interpreter Lock (GIL)? How does it affect multithreading?
9. Compare multiprocessing vs multithreading in Python. When would you use each?
10. What is a coroutine? How is asyncio different from threads?
11. Explain memory management and garbage collection in Python. What are reference cycles?
12. What is the difference between a list, tuple, set, and dictionary?
13. What are list comprehensions? How do they compare in performance to for-loops?
14. What are generators in Python? How do they differ from iterators?
15. Explain how dict handles key collisions and maintains performance.
16. What is the difference between deepcopy and copy in Python?
17. What are custom exceptions? How and why would you define one?
18. What does the finally block do in exception handling?
19. What is the difference between raise and assert?
20. How do you debug a Python script efficiently (tools, techniques)?
21. What is the difference between import module and from module import?
22. What is a closure? How does it differ from a regular function?
23. What is a decorator in Python? How would you write a custom one?
24. Explain the difference between classmethod, staticmethod, and instance method.
25. How is inheritance implemented in Python? What is MRO (Method Resolution Order)?
26. How are sets different from lists?
27. How do dictionaries work in Python?
28. How is exception handling done in Python?
29. What is the use of try, except, finally, and else blocks?
30. What are common built-in exceptions?
31. How do you raise a custom exception?