Class 29 — October 29

Moving on

Working Together – On a cautionary tale – New understandings


Look both ways


Module quad.py


Nuance downloads


Agenda


Test 2


To do


What the heck happens (PDF, slide show)

import tale | def f( x, y ) :

city1 = 'London' | rmbr = x

city2 = 'Paris' | x = y

tale.f( city1, city2 ) | y = rmbr

print( city1, city2 ) | return

London Paris

Paris London



Module self-testing downloads


Tester statement if ( __name__ == '__main__' )

if ( __name__ == '__main__' ): # __name__ is a built in python variable.

  import abet # it is set to __main__ if you are running

  # that module as a program

  # it is set to the name of the module

  # if it is being imported

  abet.test_rotate()

  abet.test_rotate_k_times()

  abet.test_common()



Module quad.py musings

Create a new empty list

For each string in strings do

— Get a converted version of the string

— Add conversion to the new list

Hand back completed new list

Create a new empty list

For each string in strings do

— Test whether string needs to be added the new list. If so, add string to new list

Hand back completed new list

What is left to do is figure out does it make a difference which of functions cleanup(), to_lower(), and unique() should be applied first, second, and third. I will just say not any order of the three will work in general.


Module for next class aid.pyhomework 27

Function rotate( x )


Function rotate_k_times( x, k )


Function common( x, y )


Slide show

 


  © 2020 Jim Cohoon   Resources from previous semesters are available.