Project 2: A second project for working with
lists and files.
Due:
Sept 27th at 11:59pm
Summary:
In this project you will open a file, read it in, and practice your
lists, strings, slicing and math in python.
Details:
For this project,
- First create a new project in pycharm (again with your name and
project 2 in the project name)
- Next get this sample text file, (which I
created by combining US house price data from
https://fred.stlouisfed.org/series/MSPUS and US median income data
over the years that I got from (https://fred.stlouisfed.org/series/mepainusa646n)
and put it into your main folder for your project.
- I will use a similar but larger file to
test your project - because of that you can't change the text
file.
- open the file and read the whole thing in
- this file contains actual median income in the US from 1975 to 2025 as
well as median house sales price for the same years.
- each line is in the format that you can see at the top of the file
(which is pretty cryptic - but
- the first section is the date of the data,
- the second is the official FED collected median (half the salaries
in the country are above and half are below) salary for that date
- The third is the official FED collected median (half the houses
sold for more, half sold for less) house selling price for that
date.
- you want to skip the top line
when doing the rest of the project.
- for each line
- calculate how many time the median income the median house price is
(for example in 1979 it was 8.35, while in 1999 it was 7.64. Only
display two digits after the decimal place. You will learn this in the
comp143 sections.
- print (in a nice easy to read format) the year of the reading (don't
include the month and day) and the ratio of house price to income
- be sure to print each years data on its own line.
For this you likely want to use the string split, f-strings, for-each
through a list, slicing of strings and lists etc.
Of course put this into git and onto github sooner rather than later.
Submission:
As with the previous project, to submit
the project to me, share it with me on github (including your
copy of the text file). My github id is jsantore. You can see
directions for doing this here.