Pythondex

Exercise

Car Info Using Classes Exercise

In this exercise, you will learn how to create a Python class and use the __init__() method. This method runs automatically when you make a new object and is used to store information in it.

Task

1. Create a class named Car.
2. In the __init__() method, add two inputs: brand and color.
3. Save these inputs inside the object as self.brand and self.color.
4. Make a Car object and print its brand and color.

Expected Output

Solve