Create the class SOCIETY with the following information:

-Society name
-House number
-No. of members
-Flat
-Income

Methods supposed to be defined:

-__init__(): defining name- Surya Appartment, Flat – A type, House No.-20, No. of members-3, Income-Rs.25000.
-input_data(): reads data members from user and call allocate flat function.
-allocate_flat(): This will allocate flat according to income:
    -If income>=25000, flat-A type
    -If income between 20000-25000, flat-B type
    -If income<20000, flat-C type
-show_data():  To display complete details of attributes of class. Test your class using SOCIETY class.

In [2]:
class SOCIETY(object):
    lasthouse = 20
    def __init__(self):
        self.name = 'Surya Apartments'
        self.houseno = 20
        self.members = 3
        self.flat = 'A'
        self.income = 25000
    def input_data(self):
        self.name = raw_input('Enter Name: ')
        self.members = int(raw_input('Enter number of members: '))
        self.income = int(raw_input('Enter monthly income: '))
        self.houseno = lasthouse+1
        lasthouse = self.houseno
        self.allocate_flat()
    def allocate_flat(self):
        if self.income>=25000:
            self.flat = 'A'
        elif 20000<=self.income<25000:
            self.flat = 'B'
        elif self.income<20000:
            self.flat = 'C'
    def show_data(self):
        print 'Society Name: ' + self.name + '\n' + 'House No: ' + str(self.houseno) + '\n' + 'No. of members: ' + str(self.members) + '\n' + 'Income: ' + str(self.income) + '\n' + 'Flat Type: ' + self.flat

In [ ]: