solutions

Make a Car with Attributes

Create a class Car that is initialized by providing three arguments: color, make, and model.

Then, create two instances:
car1 will be have it's color be blue, model be Tesla, and make be Model S.
car2 will be have it's color be red, model be Chevy, and make be Camaro.

Example:

car1 = Car(color='blue', make='Tesla', model="Model S")
print(car1.color)  # 'blue'
print(car1.make)  # 'Tesla'
print(car1.model)  # Model S

car2 = Car(color='red', make='Chevy', model="Camaro")
print(car2.color)  # 'red'
print(car2.make)  # 'Chevy'
print(car2.model)  # Camaro

Test Cases

test car1 attributes - Run Test


def test_car1_attributes():
    assert isinstance(car1, Car) is True, 'car1 is not created'
    assert isinstance(car1, object) is True

    assert hasattr(car1, 'color') is True, "car1 doesn't have a color attribute"
    assert car1.color == 'blue', "car1's color isn't blue"

    assert hasattr(car1, 'make') is True, "car1 doesn't have a make attribute"
    assert car1.make == 'Tesla', "car1's make isn't Tesla"

    assert hasattr(car1, 'model') is True, "car1 doesn't have a model attribute"
    assert car1.model == 'Model S', "car1's model isn't Model S"

test car2 attributes - Run Test

def test_car2_attributes():
    assert isinstance(car2, Car) is True, 'car2 is not created'
    assert isinstance(car2, object) is True

    assert hasattr(car2, 'color') is True, "car2 doesn't have a color attribute"
    assert car2.color == 'red', "car2's color isn't red"

    assert hasattr(car2, 'make') is True, "car2 doesn't have a make attribute"
    assert car2.make == 'Chevy', "car2's make isn't Chevy"

    assert hasattr(car2, 'model') is True, "car2 doesn't have a model attribute"
    assert car2.model == 'Camaro', "car2's model isn't Camaro"