📌 PART – A (2 MARKS EACH)
------------------------------------------
1. Define class.
A class is a blueprint or template for creating objects. It contains attributes (variables) and methods (functions).
---
2. Define object.
An object is an instance of a class. It represents a real-world entity and has its own data and behaviour.
---
3. Define data encapsulation.
Encapsulation is the process of binding data and methods together and restricting access to some components using private/protected members.
---
4. Define data abstraction.
Abstraction means showing only essential details and hiding unnecessary internal workings from the user.
---
5. Define polymorphism.
Polymorphism means one function behaving in different ways depending on the input or object.
---
6. Define inheritance.
Inheritance allows one class to acquire the properties and methods of another class.
---
7. Define method overriding.
Method overriding means defining a method with the same name in a child class that replaces the parent class method.
---
8. What is the use of ‘self’ keyword?
self refers to the current object and is used to access its variables and methods.
---
9. What is the use of ‘cls’ keyword?
cls refers to the class itself and is used inside class methods to access class-level data.
---
10. What are magic methods?
Magic methods (dunder methods) are special methods that start and end with double underscores, e.g., __init__, __str__.
---
11. What are instance attributes and instance methods?
Instance attributes → variables that belong to an object
Instance methods → functions that operate on instance attributes
---
12. What are class attributes and class methods?
Class attributes → variables shared by all objects
Class methods → use @classmethod and work with class attributes
---
13. What are properties? Why do we need them?
Properties are used to control access to instance variables by using @property decorator.
They help in validation and encapsulation.
---
14. Compare numpy arrays and Python lists.
NumPy Array Python List
Faster Slower
Stores same-type values Can store mixed types
Supports vector operations No vectorized operations
---
