Assignment 25 — function implementation that manipulate lists

Due November 1


Module quad.py


Suppose the following definitions are in effect below

test1 = ['AbCdE', 'ABCDE', '!"#\'x$&)|}~', '- x -_', 'AAcc', ' ', 'x\n']

test2 = ['\tx X']

test3 = []

test4 = ['a', 'B', 'r', 'A', 'c', 'a', 'D', 'a', 'B', 'r', 'a']



Function to_lower( strings )

to_lower( test1 ) = ['abcde', 'abcde', '!"#\'x$&)|}~', '- x -_', 'aacc', ' ', 'x\n']

to_lower( test2 ) = ['\tx x']

to_lower( test3 ) = []

to_lower( test4 ) = ['a', 'b', 'r', 'a', 'c', 'a', 'd', 'a', 'b', 'r', 'a']


Function cleanup( strings )

PUNCTUATION = '''!"#$%&'()*+,-./:;<=>?@[]^_`{|}~'''

WHITE_SPACE = ' \t\n\r\v\f'

EXTRANEOUS = PUNCTUATION + WHITE_SPACE

cleanup( test1 ) = ['AbCdE', 'ABCDE', 'x', 'x', 'AAcc', '', 'x']

cleanup( test2 ) = ['x X']

cleanup( test3 ) = []

cleanup( test4 ) = ['a', 'B', 'r', 'A', 'c', 'a', 'D', 'a', 'B', 'r', 'a']


Function unique( strings )

unique( test1 ) = ['AbCdE', 'ABCDE', '!"#\'x$&)|}~', '- x -_', 'AAcc', ' ', 'x\n']

unique( test2 ) = ['\tx X']

unique( test3 ) = []

unique( test4 ) = ['a', 'B', 'r', 'A', 'c', 'D']


Function canonical( strings )

canonical( test1 ) = ['abcde', 'x', 'aacc', '']

canonical( test2 ) = ['x x']

canonical( test3 ) = []

canonical( test4 ) = ['a', 'b', 'r', 'c', 'd']

 


  © 2020 Jim Cohoon   Resources from previous semesters are available.