Python Interview Questions and Answers for Freshers
### Basic Python Questions
1. What is Python?
- Python is a high-level, interpreted programming language known for its simplicity, readability, and
vast libraries.
2. What are the key features of Python?
- Easy to learn and use
- Dynamically typed
- Object-oriented
- Extensive libraries
- Cross-platform support
3. What is PEP 8? Why is it important?
- PEP 8 is Python's style guide that ensures clean, readable, and consistent code.
4. What are Python's built-in data types?
- int, float, complex (Numerical types)
- str (String)
- list, tuple, set, dict (Collections)
- bool (Boolean)
5. What is the difference between a list and a tuple?
- Lists are mutable (can be modified), while tuples are immutable (cannot be modified).
- Lists use [], tuples use ().
6. How is memory managed in Python?
- Python uses automatic memory management with garbage collection and reference counting.
7. What are Python's loops?
- for loop: Used for iteration over sequences.
- while loop: Runs as long as a condition is true.
### OOPs Concepts in Python
8. What is a class and an object in Python?
- A class is a blueprint for creating objects. An object is an instance of a class.
9. What is the purpose of the self keyword?
- self represents the instance of the class and is used to access class attributes and methods.
10. What is inheritance? How many types of inheritance does Python support?
- Inheritance allows a class to acquire properties from another class. Python supports:
- Single Inheritance
- Multiple Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
... (More questions and answers follow)