Python Interview Questions & Answers
Top questions asked in interviews for freshers & experienced developers
1. What is Python?
Python is a high-level, interpreted, and general-purpose programming
language.
2. What are the features of Python?
Simple syntax, interpreted, dynamically typed, object-oriented, and
cross-platform.
3. Is Python compiled or interpreted?
Python is interpreted, but it is first compiled into bytecode.
4. What are Python data types?
int, float, complex, str, list, tuple, set, dict, and bool.
5. What is dynamic typing?
Variable types are decided at runtime, not beforehand.
6. What is a variable?
A variable stores data values in memory.
7. Difference between list and tuple?
Lists are mutable, tuples are immutable.
8. What is a dictionary?
A dictionary stores key-value pairs.
9. What is a set?
A set is an unordered collection of unique elements.
10. What is None?
None represents the absence of a value.
11. What is indentation?
Indentation defines code blocks in Python.
12. What are comments in Python?
Comments are used to explain code and start with #.
13. What is a function?
A function is a reusable block of code.
14. What is a lambda function?
A small anonymous function defined using lambda keyword.
15. What is recursion?
A function calling itself to solve a problem.
16. What is a module?
A module is a file containing Python code.
17. What is a package?
A package is a collection of modules.
18. What is pip?
pip is Python’s package manager.
19. What is exception handling?
Handling runtime errors using try, except, else, and finally.
20. What is an exception?
An exception is an error that occurs during execution.
21. Difference between break and continue?
break exits the loop, continue skips the current iteration.
22. What is pass keyword?
pass is a null statement that does nothing.
23. What is OOP?
Object-Oriented Programming organizes code using classes and
objects.
24. What is a class?
A class is a blueprint for creating objects.
25. What is an object?
An object is an instance of a class.
26. What is __init__ method?
It is a constructor method used to initialize objects.
27. What is inheritance?
A class acquiring properties of another class.
28. What is polymorphism?
Same function name behaving differently for different objects.
29. What is encapsulation?
Binding data and methods together.
30. What is abstraction?
Hiding implementation details and showing only functionality.
31. What is file handling?
Reading and writing files using open() function.
32. What is with statement?
It simplifies resource management like file handling.
33. What is generator?
A function that yields values using yield keyword.
34. What is iterator?
An object that can be iterated using __iter__ and __next__.
35. What is list comprehension?
A concise way to create lists.
36. What is slicing?
Extracting parts of sequences like lists or strings.
37. What is deep copy vs shallow copy?
Shallow copy copies references, deep copy copies actual objects.
38. What is mutable and immutable?
Mutable objects can change, immutable cannot.
39. What is global keyword?
It allows modifying global variables inside a function.
40. What is local variable?
A variable defined inside a function.
41. What is virtual environment?
An isolated Python environment for dependencies.
42. What is Django?
A high-level Python web framework.
43. What is Flask?
A lightweight Python web framework.
44. What is NumPy?
A library for numerical computing.
45. What is Pandas?
A library for data analysis and manipulation.
46. What is exception vs error?
Exceptions can be handled, errors usually cannot.
47. What is threading?
Running multiple threads concurrently.
48. What is multiprocessing?
Running multiple processes in parallel.
49. What is GIL?
Global Interpreter Lock allows only one thread at a time.
50. What is memory management?
Python automatically manages memory using garbage collection.
51. What is garbage collection?
Automatic removal of unused objects from memory.
52. What is map function?
Applies a function to all items in an iterable.
53. What is filter function?
Filters items based on a condition.
54. What is reduce function?
Reduces iterable to a single value.
55. What is zip function?
Combines multiple iterables.
56. What is enumerate?
Returns index and value pairs.
57. What is Python interpreter?
Executes Python code line by line.
58. What is REPL?
Read-Eval-Print Loop for interactive coding.
59. What is PEP 8?
Python’s official style guide.
60. What is Python used for?
Web development, data science, AI, automation, and more.