Class 17, Friday, October 5
CSV Chrestomathics Déjà vu Déjà vu
Make sure what you know — Be sure you know what you know — Know now that you know
Look both ways
Agenda
- CSV chrestomathics
- Review
Note
- Students with test accomodations who did see me last class, must see me before they leave class.
Last class revisited
Housing datasets
- A Housing dataset has a one-line header. The fields in the header are some arrangement of the following.
Female | Housing Units | Population |
Male | Name | Type |
Households | Owner-occupied |
- Housing dataset example: all-va-housing.csv
Name,Type,Population,Male,Female,Households,Housing Units,Owner-occupied
Accomack,County,38305,18590,19715,15299,19550,11482
Albemarle,County,79236,38002,41234,31876,33720,20991
...
- Housing dataset example: city-town-va-housing.csv
Population,Male,Female,Households,Housing Units,Owner-occupied,Name,Type
23585,11434,12151,10001,10587,4567,Winchester,City
11998,5382,6616,3619,3880,1602,Williamsburg,City
...
Problem how_many_vacancies.py
- Examines a user-specified housing dataset and determines the number of vacant housing units for that dataset. That number is the difference of the total number of Housing Units and the total number of Households.
- The data set is stored in web folder:
http://www.cs.virginia.edu/~cs1112/datasets/csv/
.
- Sample runs
Enter name of data set: all-va-housing.csv
314205
Enter name of data set: city-town-va-housing.csv
137978
Bonus problem
- Program bonus.py
- Prompts its user for the name of a CS 1112 CSV web file. The program prints on separate lines, prints the total number of data values in the dataset. There should be no other output.
Important problem-solving skills
- Use built-in functions
- Communicate with program user
- Get string input from program user
- Examine strings
- Get multiple string inputs from program user
- Get input from user and convert to numeric
- Perform integer and decimal arithmetic
- Get multiple inputs from user convert to numerics
- Get unknown number of inputs from user and convert to a list of strings
- Get unknown number of inputs from user and convert to a list of stringds
- Set the random generator seed
- Generate random values and choices
- Repeating tasks, a number of times based on user input.
- Loop over the characters in a string
- Loop over the values in a range
- Build and examine lists
- Loop over the elements of a list
- Loop over a list of lists
- Get contents of a web file
- Get and analyze a dataset
To do
- Bring questions to class on Friday
- Review class artifacts
- Review standard documentation for built-in functions.
- Review course documentation for module str.
- Review course documentation for module list.
- Review course documentation for local module url.
- Review standard documentation for module math.
- Review ccourse documentation for module random.
- Epistle on syntax errors and exceptions.
- Epistle on accomplishments.
© 2019 Jim Cohoon | Resources from previous semesters are available. |