LEARNING OBJECT ORIENTED IN PYTHON- WORKING WITH CLASS METHOD AND OBJECT!!

Words
17
Reading
1 min
Listen
Play
7y
class Car:
    def __init__(self):
        self.colour="Golden"
        self.weight=140
        self.price=1500000
        self.mileage=50
        self.condition="Good"
        
       
    def damage(self):
        self.mileage=35
        self.condition="Bad"
        
     
Car1=Car()
print(Car1.mileage)
print(Car1.condition)

Car1.damage()
print(Car1.mileage)
print(Car1.condition)

The output as executed by me is as follows:

Screenshot_2.png

You can run this python code online here.