## Class 41 — December 7

#### I know that you know that

Programming basics — You achieved this semester — Bask in the success

### Agenda

• Be chrestohistorical

### Thanks to the undergraduate TAs for making the course successful

 •   Daniel Choi •  Ann Hoang •  Leah Salvano •  Jessica Emmons •  Adriece Sharpe •  Simone Olson •  Ryan Green •  Jessica Krynitsky •  Jacob St. Martin •  Nadia Hassan •  Nikki Pope •  Alexandra Stampfl •  Blake Hesson

### 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 representation `v`

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.
• The test points are likely to be ~135.
• Questions can require in part familiarity with
• Fundamental types; e.g., `int`, `float`, and `str`
• 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`, and `while`
• 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()`, and `id()`
• 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