OBJECTIVES
Your midterm will have three components spanning the material covered thus far in class.
Real Estate
You are a real estate agent who has clients who are interested in buying a new house in Collin
County near UTD. It is a hot market, so you cannot wait for homes to go for sale. Instead, you
want to find existing homes that meet your clients’ criteria and then ask the owners if they are
interested in selling. Your clients want a single-family house (state_code=’A1’) with at least
1600 sq ft of living area (“living_area”) and a market value (“market_value”) between $250,000
and $350,000. They also have children and want to live in the area zoned to Aldridge Elementary
(CAMPNAME=’ALDRIDGE EL’).
A file named “parcels.py” has been provided to you that contains a variable named parcels which
is a list of dictionaries. Each dictionary contains the above-mentioned keys, as well as
street_address for a parcel. To access this data in your script, you just need to import this file and
then you should be able to use the parcels variable (from parcels import parcels).
Undergraduates: Write a Python script to print the count of houses that meet the criteria as well
as a list of all the addresses.
Graduates: Write a Python script to print the count of houses that meet the criteria as well as a
list of all of the matching addresses. You also need to prompt the user for each criteria (state
code, living area, min & max cost, and elementary name). For living area and cost, make sure the
user enters valid numbers and ask them to retry if invalid entry is detected (no crashing!).
Deliverables:
Python script file, commented appropriately, in PEP8 format, with name on top.
Coordinate Conversion
Write a script to convert Decimal Degree (DD) latitude/longitude coordinates into Degree-
Minute-Second (DMS) coordinates. There is a demo program attached:
latlong4317.exe (For Undergraduates)
latlong6317.exe (For Graduates)
Your program should behave in an identical fashion, taking input coordinates in DD format and
outputting them in DMS. The script should return an error message if the user inputs invalid
coordinates (e.g. letters or numbers out-of-range). Graduates should prompt the user to run
another conversion when finished.
2
(Hint: http://en.wikipedia.org/wiki/Decimal_degrees for conversion formula)
(Another hint: to print the degree symbol in Python, you need to refer to it by its Unicode value,
so try printing this: u"\u00b0" [one u inside the quotes, one outside])
Deliverable:
Python script file, commented appropriately, in PEP8 format, with name on top.
File Manipulation
Write a Python script that opens a CSV file and prints out the contents with tabs delimiting the
columns for proper spacing. You should write a function that accepts the filename as the
parameter that does the actual work of opening and printing. The main body of the script will just
call this function for opening/printing.
Undergraduates: Ask the user what CSV file to read/print. Pass this file to your function to print
the results. You can use the attached countries.csv as a test. Make sure the script does not crash if
the file does not exist.
Graduates: Ask the user what directory to search for CSVs in. Search through all child
directories as well. For each CSV you encounter, pass to your function to print it out. Make sure
the script does not crash if the directory entered does not exist.
(Hint: the os module & os.walk())
Deliverable:
Python script file, commented appropriately, in PEP8 format, with name on top.
Other Notes
Unlike other assignments, this project should be done completely independently. Think of it as a
take-home exam. Also, we will not have a lecture next week, so that you can devote your time to
this project. Please use that time to work on the project, and don’t wait until the day before to
start – you will NOT be able to finish it in one day. This is a strict deadline, and any late
submissions will be penalized. If you use any code from the Internet, please cite your sources
and document what exactly it is doing!
By typing my name here, I affirm that I will not and have not communicated in any way
(email, phone, person-to-person, etc) with any person in completing this exam.