Posts

Showing posts with the label NOTES FOR ADA

Absolutely πŸ‘ Let’s understand OOPs in Python in the easiest possible way, with simple real-life examples.

  🐍 OOPs in Python OOP = Object-Oriented Programming Think of OOP as creating a blueprint and then creating real things from that blueprint. Real-life example Suppose Car is a blueprint. A car has: Properties: color, brand, speed Actions: start(), stop(), drive() In Python: class Car : def __init__ ( self , color , brand ): self . color = color self . brand = brand def drive ( self ): print ( "Car is driving" ) car1 = Car ( "Red" , "BMW" ) print ( car1 . color) print ( car1 . brand) car1 . drive() Output: Red BMW Car is driving 1. Class A class is a blueprint/template . class Student : pass Here, Student is a class. Think: Class = Blueprint 2. Object An object is a real instance of a class . class Student : pass student1 = Student () student2 = Student () Here: Student → Class student1 → Object student2 → Object Think: Class = House blueprint Obj...