Class 14 — Friday February 18
Tabling
In a loop, a loop — Nesting, but not like a bird — Repeating again
Zooming
Look both ways
Shirt of the day
Agenda
- Introduce web processing
- Introduce dataset processing
- Introduce nested loops
Download now
- Module url.py
- Provides access to web data
- Program going_rowing.py
- Introduces dataset processing
- Program word_of_the_day.py
- Accesses a web file through the use of local module url.py
- Program rc_printing.py
- Introduces nested looping
To do list
- Complete current homeworks
- Review artifacts
What is data?
- Facts and figures
What is information
- Knowledge
What is a dataset
- A dataset is a list whose elements are lists. The elements of the sublists are data
- Datasets are sometimes called tables or data sheets
- The elements of a two-dimensional dataset are called rows. The elements of a row are called data values or cells.
- Most of the datasets that we process will come from the web.
- The datasets acquired by programs are often CSV files; that is, the values are separated by commas.
- One of the CSV dataset we will consider is the best selling fictional books of all time
Web pages
- We have created a module url.py to provide some helpful web access.
- Our introduction to interacting with the web in CS 1112 is intentionally simple. Industrial-strength web applications require familiarity with other and more powerful URL modules.
- There is an external library requests worth checking if you have further interest.
Program word_of_the_day.py
- Displays the word of the day from the CS 1112 web file
word-of-the-day
.
- Uses local module
url.py
???
Program going_rowing.py
- Demonstrates looping through a dataset
-
Program run
table: [['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I'], ['J', 'K', 'L', 'M']]
the table has 4 rows
row ['A', 'B', 'C'] has 3 columns
row ['D', 'E', 'F'] has 3 columns
row ['G', 'H', 'I'] has 3 columns
row ['J', 'K', 'L', 'M'] has 4 columns
row 0 : ['A', 'B', 'C']
row 1 : ['D', 'E', 'F']
row 2 : ['G', 'H', 'I']
row 3 : ['J', 'K', 'L', 'M']
Program rc_printing.py
- Demonstrates printing a table of values (cells) for a user-specicied number of rows and columns.
- The value of cell should be the sum of its row and column indices.
-
Some program runs
Number of rows and columns: 3 4
0 1 2 3
1 2 3 4
2 3 4 5
Number of rows and columns: 4 5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
🦆 © 2022 Jim Cohoon | Resources from previous semesters are available. |