Define three classes: Vehicle, Car and Truck. Vehicle will be the parent class of Car and Truck.
Randomly create five objects of Car and Truck using the for loop given below
The program should output the correct number of vehicles: Car and Truck objects.
The count of objects should be calculated within the class definitions.
Example output There are 5 Vehicle objects [‘Car’, ‘Car’, ‘Truck’, ‘Truck’, ‘Car’] 3 of them are Cars 2 of them are Trucks
#INSERT YOUR ANSWER HERE.
# Define Vehicle class
# Define Car class
# Define Truck class
# Run the following lines of code
from random import choice
list_of_vehicles = [choice([‘Car’, ‘Truck’]) for x in range(5)]
for vehicle in list_of_vehicles:
if vehicle == ‘Car’:
# create an object of Car class
o = Car(‘Pick Car’)
# create an object of Truck class
c = Truck(‘Pick Truck’)
# print the list_of_vehicles
# print number of Vehicle objects
# print number of Car objects
# print number of Truck objects