Python Project for Students
Python program to display delinquent residents of a community
Instructions
Python project for students to write a program that displays delinquent residents of a residential community. Given three lists of residents and landlords of a building, your task is to write a program that compares both lists, find the landlords who owe their community fees to the board and display their names along with floor they live in.
It must show the residents that are homeowners, not tenants.
It is great Python challenge for students willing to practice data structures and loops and conditionals.
Data
residents = { ‘ZJY9666’: ‘Jordan Doyle Floor 1’, ‘WIL9666’: ‘Fletcher Willis Floor 1’, ‘JRT9666’: ‘Cade Ortiz Floor 1’,
‘FSL9666’: ‘Madison Fulton Floor 2’, ‘MYT9666’: ‘Camille Matthews Floor 2’, ‘ZJY9661’: ‘Jordan Doyle Floor 2’,
‘ZJT9666’: ‘Ainsley Dotson Floor 3’, ‘LYW9666’: ‘Imogene Lawrence Floor 3’,
‘JSM9666’: ‘Fletcher Justice Floor 3’, ‘BYX9666’: ‘Armand Baxter Floor 4’,
‘BLY9666’: ‘Orson Blake Floor 4’, ‘BSL9666’: ‘Avram Bullock Floor 4’,
‘MPX9666’: ‘Colette Sexton Floor 5’, ‘ZJT9661’: ‘Ainsley Dotson Floor 5’,
‘ZPJ9666’: ‘Jason Dejesus Floor 5’, ‘XJF9666’: ‘Herman Coffey PH’,
‘BYX9661’: ‘Armand Baxter PH’, ‘SDR0000’: ‘David Peter PH’ }
paid = [‘ZJY9666’, ‘WIL9666’, ‘JRT9666’, ‘MYT9666’, ‘ZJY9661’, ‘ZJT9666’, ‘LYW9666’, ‘JSM9666’, ‘BYX9666’, ‘BLY9666’, ‘BSL9666’, ‘MPX9666’, ‘BYX9661’]
homeowners = [‘ZJY9666’, ‘WIL9666’, ‘JRT9666’, ‘FSL9666’, ‘MYT9666’, ‘ZJY9661’, ‘ZJT9666’, ‘LYW9666’, ‘JSM9666’, ‘BYX9666’, ‘BLY9666’, ‘BSL9666’, ‘MPX9666’, ‘ZJT9661’, ‘ZPJ9666’, ‘XJF9666’, ‘BYX9661’]
Steps
- Create an empty list called
"unpaid"to store the residents who are landlords but have not paid the community fees of the building. - Iterate over the “homeowner” list and check if each resident ID is not present in the
"paid"list.- If a resident ID is not in the
"paid"list, add the resident’s name to the"unpaid"list.
- If a resident ID is not in the
- Print values of “unpaid”.
Source Code
## Lists of residents and the floor they're living in
residents = {
'ZJY9666': 'Jordan Doyle Floor 1',
'WIL9666': 'Fletcher Willis Floor 1',
'JRT9666': 'Cade Ortiz Floor 1',
'FSL9666': 'Madison Fulton Floor 2',
'MYT9666': 'Camille Matthews Floor 2',
'ZJY9661': 'Jordan Doyle Floor 2',
'ZJT9666': 'Ainsley Dotson Floor 3',
'LYW9666': 'Imogene Lawrence Floor 3',
'JSM9666': 'Fletcher Justice Floor 3',
'BYX9666': 'Armand Baxter Floor 4',
'BLY9666': 'Orson Blake Floor 4',
'BSL9666': 'Avram Bullock Floor 4',
'MPX9666': 'Colette Sexton Floor 5',
'ZJT9661': 'Ainsley Dotson Floor 5',
'ZPJ9666': 'Jason Dejesus Floor 5',
'XJF9666': 'Herman Coffey PH',
'BYX9661': 'Armand Baxter PH',
'SDR0000': 'David Peter PH'
}
## Homeowner residents with community expenses paid
paid = ['ZJY9666', 'WIL9666', 'JRT9666', 'MYT9666', 'ZJY9661', 'ZJT9666', 'LYW9666', 'JSM9666', 'BYX9666', 'BLY9666', 'BSL9666', 'MPX9666', 'BYX9661']
## Residents that are landlords (not tenants)
homeowners = ['ZJY9666', 'WIL9666', 'JRT9666', 'FSL9666', 'MYT9666', 'ZJY9661', 'ZJT9666', 'LYW9666', 'JSM9666', 'BYX9666', 'BLY9666', 'BSL9666', 'MPX9666', 'ZJT9661', 'ZPJ9666', 'XJF9666', 'BYX9661']
unpaid = []
for resident_id in homeowners:
if resident_id not in paid:
unpaid.append(residents[resident_id])
# Print the names of residents that are owners but haven´t paid
for name in unpaid:
print(name)
Expected Output
Madison Fulton Floor 2 Ainsley Dotson Floor 5 Jason Dejesus Floor 5 Herman Coffey PH