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 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)
>>> Car.has_same_configuration(config1, config3)

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)
>>> is_same_car_color_and_model(car1, car3)
>>> is_same_instance_of_car(car1, car2)
>>> is_same_instance_of_car(car1, car3)

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

43 out of 45 users completed this Bite.
Will you be Pythonista #44 to crack this Bite?
Resolution time: ~49 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 4.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8