A Taxi Is a Vehicle
Python
20 pts
A Taxi Is a Vehicle
The Vehicle class is ready. Create a child class Taxi:
__init__(self, brand, year, city)callssuper().__init__(brand, year)and storesself.city.- A new method
route()that returnsbrand taxi in city, for exampleFiat taxi in Asmara.
Do not write info() in Taxi — it is inherited. Expected output:
Fiat (2010) Fiat taxi in Asmara
Checklist
- Keep the
Vehicleclass and create a child class calledTaxithat inherits from it (do not rewriteinfo()). - In
Taxi's__init__, let the parent store the brand and year, then store the city. - Add a method
route()that returnsbrand taxi in city. - Run the code at the bottom.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
