-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.py
More file actions
42 lines (39 loc) · 1.3 KB
/
user.py
File metadata and controls
42 lines (39 loc) · 1.3 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
import censusapi as census
class User:
"""
Simple class representation of a single user's information and data.
For the purposes of transmission to front-end.
Fields include:
self.income
self.zipcode
self.rent_ratio -- the percentage of income to be used on rent.
"""
def __init__(self, income, zipcode, age = 0, actual_rent = 0):
"""
A constructor for an instance of the user class.
Requires:
- income: a positive integer representing monthly income.
- zipcode: the zipcode of the user's residence.
"""
self.income = income
self.zipcode = zipcode
self.age = age
self.actual_rent = actual_rent
self.rent_ratio = 0.3
self.piecharts = {}
def ideal_rent(self):
"""
A function to return the ideal rent for a user
based on their income.
Requires: None
Returns: A float representing the ideal rent as
in dollars.
"""
return self.income * self.rent_ratio
def median_rent_utilities(self):
"""
A function which returns the median rent
"""
rent = census.get_med_rent(self.zipcode)
housing = census.get_med_housing_cost(self.zipcode)
return rent, housing - rent