Python Interview Questions - Numbered List
Core Python Fundamentals
1. What is the structural and behavioral difference between a List and a Tuple in Python?
2. Explain the concepts of Mutability and Immutability with examples of data types belonging to
each.
3. What are Generators and Iterators in Python? How do they help in optimizing memory
consumption?
4. Explain how Python Decorators work. Can you write a simple decorator function to calculate
execution time?
5. What is the difference between a Shallow Copy and a Deep Copy? Which module is required to
implement them?
6. Explain Slicing in Python. What is the behavior of the expression list1[::-1]?
7. What is List Comprehension? Rewrite a nested for loop filter into a single line using list
comprehension.
8. How does memory management work in Python? Explain the role of the Garbage Collector.
9. What is the purpose of *args and **kwargs in a Python function signature?
10. Explain the differences between Local, Global, and Nonlocal scope variables.
Object-Oriented Programming (OOP)
11. What are the four pillars of Object-Oriented Programming? Give real-time design examples for
each.
12. How do you implement Multiple Inheritance in Python? Explain how Method Resolution Order
(MRO) works.
13. What is the difference between Abstract Classes and Interfaces in Python? How do you define
them using the abc module?
14. Explain Method Overloading vs Method Overriding. Does Python natively support compile-time
method overloading?
15. What is the use of the __init__ constructor? Can a class have multiple constructors in Python?
16. What is the significance of the self parameter inside a class method?
17. Explain the difference between @classmethod, @staticmethod, and regular instance methods.
18. How do you achieve data encapsulation or declare 'private' and 'protected' members in a
Python class?
19. What are Magic Methods (or Dunder Methods) like __str__ and __repr__ used for?
20. How do you implement a Singleton Design Pattern in Python?
Data Structures & Libraries (Pandas, Flask, Cloud)
21. How would you optimize data transformations when processing a massive 10GB CSV file using
Python?
22. How do you locate, handle, and remove duplicates efficiently within a Pandas DataFrame?
23. Explain the lifecycle of a request in a Flask application.
24. What is the difference between a Series and a DataFrame in Pandas?
25. How do you handle a scenario where a Python application is suffering from memory leaks or
slow performance bottlenecks?
26. How do you connect a Python script to a relational database like MySQL or PostgreSQL?
27. How do you write structured code to handle multiple exceptions using try-except-finally blocks?
28. Explain how to call an external API using Python's requests module and parse the resulting
JSON data.
29. How can you implement parallel processing or concurrency using multithreading or
multiprocessing in Python?
30. How do you trigger a Python AWS Lambda function using cloud-native event-driven services?
Hands-on Coding Problems
31. Write a program to reverse a string without using built-in slicing tools.
32. Write a function to check whether two strings are anagrams of each other.
33. Write a program to find the missing number in an integer array ranging from 1 to N.
34. Write a script that loops through a mixed list and separates positive numbers, negative
numbers, and strings into distinct lists.
35. Given a string of digits, calculate the sum of the digits. If the sum is a Fibonacci number, append
it to the string; if not, append the next closest Fibonacci number.
36. Write a program to move all occurrences of a specific character (e.g., # symbols) to the front of
a string.
37. Write a function to find the first non-repeating character in a given string.
38. Write a Python program to generate the Fibonacci series up to N terms using recursion.
39. Write a script to remove duplicate elements from a sorted list in-place without using extra
memory space.
40. Given an unsorted array, write a program to find two numbers that sum up to a specific target
value and return their index positions.