Class 41 — November 29
I know that
Programming basics — You achieved this semester — Bask in the success
Look both ways
Download if needed
Survey
---
Agenda
- Discuss algorithmic patterns
- Continue coloring
- Consider Beyonce on the UVA Lawn
Important patterns
- Print output
- Get input
- Convert input to data
- Perform calculations
- Process strings
- Get web input
- Use to do above and below tasks
- Examine and create lists
- Convert a string into a list of strings
- Convert a list of strings into a list of numbers
- Perform an accumulation
- Check to see if the elements of the list are all of the same form
- Check to see if any element of the list has a desired form.
- Generate random data
- Produce random value from a range
- Produce random from a list
- Produce a random tuple
- Produce random lists and tables
- CSV data
- Convert a list of CSV-strings into a new list of lists
- Examine and create dictionaries
- Convert a list of tuples into a dictionary
- Convert a list of two-element lists into a dictionary
- Examine a list with respect to a dictionary
- Examine a table
- Perform an accumulation
- Process a table on a row by row basis
- Convert cells from strings to numerics
- Check to see if all data cells in the table are of the same form
- Check to see if any data cells in the table are of the desired form
- Check to see if all rows in the table are of the same form
- Check to see if any rows in the table are of the desired form
- Design, implement, analyze functions that can encapsulate the above tasks
- Photo manipulation
Realizations
- A variable has an identity and a type
- The value of a variable indicates where the object which it represents can be found
- Strings are immutable
- String functions require the use of a parameters
- String splitting
s.strip()
returns a new list of the words making ups
.
s.strip( '\n' )
returns a new list of the lines making ups
.
s.strip( ',' )
returns a new list of the comma-separated data cells making ups
.
- Converting string data to numeric data.
- To hand back a single integer value
nbr
from a single numeric representationv
nbr = int( v )
- To hand back a list of integer values
nbrs
from a string liststrings
nbrs = []
for v in s :
nbr = int( v )
nbrs.append( nbr )
- A function invocation cannot change the identity of an argument
- All functions return a value either explicitly or implicitly. If there is no explicit return,
None
is returned.
To do
- Review for Monday
- Complete Homework 28