-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathQuestion 1
More file actions
43 lines (38 loc) · 1.72 KB
/
Question 1
File metadata and controls
43 lines (38 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# QUESTION-1 Create the class Society with following information:
# society_name, house_no, no_of_members, flat, income
# Methods : An __init__ method to assign initial values of society_name, flat, house_no, no_of_members, income
# input_data() To read information from members
# allocate_flat() To allocate flat according to income using the below table.
# show_data() to display the details of the entire class.
class Society():
def __init__(self,society_name, flat, house_no, no_of_members, income):
self.society_name = society_name
self.flat = flat
self.house_no = house_no
self.no_of_members = no_of_members
self.income = income
def input_data(self):
self.society_name = input("Enter the society name: ")
self.flat = input("Enter the flat: ")
self.house_no = int(input("Enter the house number: "))
self.no_of_members = int(input("Enter the number of members: "))
self.income = int(input("Enter the income: "))
self.allocate_flat()
def allocate_flat(self):
if self.income>=25000:
print("A Type")
elif self.income>=20000 and self.income<25000:
print("B Type")
elif self.income>=15000 and self.income<20000:
print("C Type")
elif self.income<15000:
print("D Type")
def show_data(self):
print("\nsociety name: ", self.society_name, "\nflat name: ", self.flat, "\nhouse number: ", self.house_no, "\nnumber of members: ", self.no_of_members, "\nincome : ", self.income, "\nflat allocation:")
return self.allocate_flat()
a=Society("","", 0, 0, 0)
a.input_data()
a.allocate_flat()
a.show_data()
a.allocate_flat()
a.show_data()