A class is like a form or a questionnaire. An instance is like a form that has been filled out with information. Just like many people can fill out the same form with their unique information, many instances can be created from a single class.
class Car :
pass
Usually written in CamelCase
Example Class :
class Car:
pass
c= Car
c.name = "Ferrari"
c.topspeed = 400
print(c.name)
print(c.topspeed)
def __init__(self):
# body of the constructor
class Car:
def __init__(self, name, topSpeed):
self.name = name
self.topSpeed= topSpeed
1. **self.name = name**creates an attribute called name and assigns to it the value of the name parameter.
2. self.topSpeed= topSpeed creates an attribute called topSpeed and assigns to it the value of the topSpeed parameter.
Example :