Pybites Logo

Identity and equality

Level: Beginner (score: 2)

Identity and equality are two important concepts in Python. Please correct the mistakes in the Car class (marked with # *) and complete the functions below.

Use the errors in the tests as guidance to what needs fixing. The Car class has two static functions that should behave in the following way:

>>> Car.age(1)
'Neither a week, nor a year old'
>>> Car.age(7)
'A week old'
>>> Car.age(365)
'A year old'

>>> config1 = ["manual", "radio"]
>>> config2 = ["manual", "radio"]
>>> config3 = ["manual"]

>>> Car.has_same_configuration(config1, config2)
True
>>> Car.has_same_configuration(config1, config3)
False

Please alo complete the two functions is_same_car_color_and_model and is_same_instance_of_car to behave like this:

>>> car1 = Car("Pickup", "black")
>>> car2 = Car("Pickup", "black")
>>> car3 = car1
>>> is_same_car_color_and_model(car1, car2)
True
>>> is_same_car_color_and_model(car1, car3)
True
>>> is_same_instance_of_car(car1, car2)
False
>>> is_same_instance_of_car(car1, car3)
True

Check out the articles below for additional pointers to solve the bite:

- Python '!=' Is Not 'is not'

- What are the differences between type() and isinstance()?

Good luck and keep calm and code in Python!