Class 18 — Monday March 15

Knowing what you know

Though the past is past – It is still an augury – Of future tidings

Always be mindful. — Make sure what you are doing, — Is what you intend.


Look both ways


Agenda


Examples


Recent Test 1 solutions


Review module documentation


Epistles


Chrestomathics


Development and translation


How Python works


Values and types


str


range


list


for loops

for item in sequence :

   statement1

   statement2

   ...

   statementn

In the above, iterator variable item takes on each of the values of sequence in turn. For each of those values, statement1, statement2, ..., and statementn are repeated.


Producing values


Functions and methods


Library


Web processing


Errors


Gotchas


Datasets

dataset = ... # get the dataset

... # set up dataset processing (if needed)

for row in dataset : # consider rows one by one

  # process current row of the dataset

  ... # process the row

... # finish off dataset (if needed)


dataset = ... # get the dataset

... # set up dataset processing (if needed)

for row in dataset : # consider rows one by one

  # process current row of the dataset

  ... # prepare to process the cells (if needed)

  for cell in row : # consider cells of the row one by one

  # process the current cell for the row

  ... # process the cell

  ... # finish off row (if needed )

... # finish off dataset (if needed)

dataset = ... # get the dataset

c = ... # get the column

column_copy = [] # need a cell accumulator

for row in dataset : # consider rows one by one

  # get cell from row' column c

  cell = row [ c ] # get the cell in column c

  column_copy.append( cell ) # copy the cell into accumulator

... # analyze the column




https://en.m.wikipedia.org/wiki/File:Bavarian_Krautsalat_Munich.JPG

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.