1.

Create the class SOCIETY with following information: society_name,house_no,no_of_members,flat, income Methods : (i) An _init_ method to assign initial values of society_name as “Surya Apartments”, flat as “AType”, house_.no as 20, no_of_ members as 3, income as 25000.  (ii) Inputdata()-To read data members (society,house_no,no_of members & income) and call allocate_flat(). (iii) allocate_flat( )-To allocate flat according to incomeIncomeFlat>=25000A Type>=20000 and <25000B Type<15000C TypeShowData() to display the details of the entire class.

Answer»

class SOCIETY:

# constructor to create an object

def init (self):

#constructor

self. society_name=‘Surya Apartments’

self.house_no=20

self.no_of_members=3

self.flat=AType’

self.income=25000

def Inputdata(self):

self. society_name = raw_input (“Enter Society Name”)

self.house_no=input(“Enter House Number”)

self.no_of_members = input (“Enter No. of members”)

self.income = float(raw_input (“Enter income”))

def Allocate_Flat(self):

if self.income >= 25000:

self.flat = AType’

elif self.income >= 20000 and self.income < 25000 :

self.flat = ‘BTÿpe’ else:

self.flat = ‘CType’

def Showdata(self):

print “Society Name”,

self.society_name

print “House_No”,

self.house_no print “No.of members”,

self.no_of mem-bers

print “Flat Type”,

self.flat print “Income”,

self.income

S = SOCIETY))

S.InputdataO

S.Allocate_Flat()

S.ShowdataO



Discussion

No Comment Found