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

Multiple Inheritance: Source Code

The document describes using multiple inheritance in Python by defining three classes - company, distributer, and sale - where sale inherits from both company and distributer. It creates an instance of the sale class, calls methods to input data for company and distributer, and then displays the collected data.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Multiple Inheritance: Source Code

The document describes using multiple inheritance in Python by defining three classes - company, distributer, and sale - where sale inherits from both company and distributer. It creates an instance of the sale class, calls methods to input data for company and distributer, and then displays the collected data.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MULTIPLE INHERITANCE

SOURCE CODE:
class company:

def __init__(self):

self.company=''

self.branch=''

def inputdata(self):

self.company=raw_input('Enter company name:')

self.branch=raw_input('Enter company branch:')

def display(self):

print 'Company name is', self.company

print 'Company branch is', self.branch

class distributer:

def __init__(self):

self.distributer=''

self.id=0

def accept(self):

self.distributer=raw_input('Enter name of distributer:')

self.id=input('Enter distributer ID:')

def show(self):

print 'Distributer name is', self.distributer

print 'Distributer ID is', self.id


class sale(company, distributer):

def __init__(self):

self.stock=''

self.sale=0.0

def take(self):

self.stock=raw_input('Enter the total stock:')

self.sale=input('Enter total sale:')

def present(self):

print 'Total stock is', self.stock

print 'Total sale is', self.sale

c=sale()

c.inputdata()

c.display()

c.accept()

c.show()

c.take()

c.present()
OUTPUT:

You might also like