Class 16, Wednesday, February 21
CSV Chrestomathics Déjà vu
CVS Drugstore — Is not to be examined — CSV files yes
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 must see me before they leave class.
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
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_vacant_housing_units.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.cs1112.org/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
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.
Warning: fopen(/l/cs1112/public_html/defs/htm/181-trailer): Failed to open stream: No such file or directory in /l/cs1112/public_html/defs/php/read.php on line 5
Unable to open file!