Question
USE PYTHON TO WRITE THE CODES. Create a Vehicles class that holds instances of cars; this class is completely separate from the Car class. In
USE PYTHON TO WRITE THE CODES.
Create a Vehicles class that holds instances of cars; this class is completely separate from the Car class. In other words, the Car class does not inherit from the Vehicle class. Then assign three car instances to an instance of the Vehicle class.Create MERCEDES CLASS, BMW class, and ferrari class , all inheritance of car class
starter code below:
class Vehicle :
car=() def __init__(self,car): self.car=car
class Car: wheels =4 def __init__(car,make,colour): self.make=make self.colour=colour def description (self): return f('{} is a {} {}.') class Suv(car): def __init__(self): super ().__init__(make ,colour) class Sedan (car): def__init__(self,) super ().__init__() class Supercar (car): def __init__(self) super ().__init__() # create instances of cars my_cars=() # instantiate the Vehicle class mycars=vehicles ()
Your output should look like this:
I have 3 cars: The Mercedes is a black suv. The BMW is a silver sedan. The ferrari is a red supercar . and they all have 4 wheels of course.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started