0% found this document useful (0 votes)
3 views

Inheritance

The document defines a class hierarchy for vehicles, including a base class 'vehicle' and two derived classes 'bike' and 'car'. Each class has methods to accept and display attributes like price, mileage, model, cc, and tyre number, as well as a rating method that provides a star rating for the vehicle. An instance of 'car' is created, and its methods are called to demonstrate the functionality.
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Inheritance

The document defines a class hierarchy for vehicles, including a base class 'vehicle' and two derived classes 'bike' and 'car'. Each class has methods to accept and display attributes like price, mileage, model, cc, and tyre number, as well as a rating method that provides a star rating for the vehicle. An instance of 'car' is created, and its methods are called to demonstrate the functionality.
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

class vehicle:

def accept(self):

self.price = int(input("Enter Price no"))

self.mileage = int(input("Enter the mileage"))

self.model = int(input("Enter the model no"))

def display(self):

print("Model : ",self.model)

print("Price : ",self.price)

print("Mileage : ",self.mileage)

class bike(vehicle):

def accept1(self):

self.cc = int(input("Enter the cc number"))

self.tyre = int(input("Enter the tyre number"))

def display1(self):

print("CC : ",self.cc)

print("Tyres : ",self.tyre)

def rating(self):

print("4 star")
class car(bike,vehicle):

def rating(self):

print('5 star')

c1=car()

c1.accept()

c1.accept1()

c1.display()

c1.display1()

c1.rating()

You might also like