Class 42 — April 29
I know that you know that
Programming basics — You achieved this semester — Bask in the success
Look both ways
Agenda
- Be chrestohistorical
Notices
- TA-lead review in Olsson 120 on Wednesday starting at 2 PM.
Thanks to the undergraduate TAs for making the course successful
Raven Chen Ryan Green Jacob St. Martin Shelby Slotter Ann Hoang Nadia Hassan Nikki Pope Alexandra Stampfl Vienna Donnelly Peter Haynes Sophia Rogers Hannah Thompson Jessica Emmons Jessica Krynitsky Leah Salvano Torian Wright
Links
- Test 1 artifacts are available
- Test 2 artifacts are available
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
- Build a string, list, or sum
- 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.
- Find first / last index of an item with a property
- Compare two lists
- Synthesize two lists
- Generate random data
- Get a random value from a range
- Select a random element 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
- 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 list strings
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.
Truisms
- The test will cummulative.
- Questions can require in part familiarity with
- Fundamental types; e.g.,
int
,float
, andstr
- Arithmetic operators; e.g.,
+
,-
,*
,**
,/
,//
, and%
- Identifiers, keywords, variables, objects, values, and references
- Logical and relational operators;
and
,or
,not
,==
,!=
,<
,>
,<=
, and>=
- Control constructs; e.g.,
if
,for
, andwhile
- Nested
for
constructs
- Random value manipulation
random.seed()
random.randrange()
random.choice()
- Builtin-in functions; e.g.,
print()
,input()
,int()
,float()
,str()
,max()
,min()
,len()
,type()
, andid()
- URLs and web files; e.g., numeric, text and CSV contents
- Ranges
- Data structures and their use:
list
,dict
, tuples, methods and slicing
- Functions, parameters, definitions, and invocations
- Colors and PIL Image
Final thought
- I say thanks to you — Your presence is a great gift — Brings me happiness