avatar Bite 319. Identity and equality

Identity and equality are two important concepts in Python. Please correct the mistakes in the Car class (marked with # *) and 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!

Login and get coding
go back Beginner level
Bitecoin 2X

21 out of 22 users completed this Bite.
Will you be Pythonista #22 to crack this Bite?
Resolution time: ~47 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌

We use Python 3.8