Pratice problem for the DS

problem 1

Create a child class Bus that will inherit all of the variables and methods of the Vehicle class

Given:

class Vehicle:

    def __init__(self, name, max_speed, mileage):
        self.name = name
        self.max_speed = max_speed
        self.mileage = mileage
```Create a Bus object that will inherit all of the variables and methods of the parent Vehicle class and display it.

Expected Output:

Vehicle Name: School Volvo Speed: 180 Mileage: 12


problem 2 Check the type of an object

Write a program to determine which class a given Bus object belongs to.

**Given**:

class Vehicle:
def init(self, name, mileage, capacity):
self.name = name
self.mileage = mileage
self.capacity = capacity

class Bus(Vehicle):
pass

School_bus = Bus(“School Volvo”, 12, 50)

2 Likes