Classes and Objects
What's Class
Class Syntax
class ClassName:
StatementCar Example 😂
class Car:
# attributes
color = "red"
body = "sedan"
# methods
def specs(self):
print("car color is", self.color)
print("body type is", self.body)
# Object instantiation
Bmw = Car()
# Accessing class attributes
# and method through objects
print(Bmw.color)
Bmw.specs()
Output:
red
car color is red
body type is sedanThe Self
__init__ Method
Class and Instance Variables
Modify Object Properties
Delete Object Properties
Delete Objects
The pass Statement
Last updated