## Final exam — May 3

#### We know you can

You are ready now — For problem solving prowess — Your best will be shown

### Always look both ways

• Enjoy what you have accomplished and look forward to the future.

### Important

• Do not leave the room without checking that you have made fifteen submissions for Test 3. The check will inform you if something is moving.
• You are responsible for reading the test in its entirety.
• Based on your many past educational achievements, I expect you to do well on this test.
• Read each question both thoroughly and mindfully of what is being asked.
• No cell phone access during the test. If you need to leave the room, please leave your electronic devices.

### Problems

• You must use my files for developing your solutions. For problems that involve module testing, the testers have been built-in into the module.
• The Python files you are to use are available at the below link. Do not click the link until you have been given permission. Your access to the download page is tracked by email id and the time of clicking.

### Terminology

• Decrement means subtract.
• The additive inverse of a number x, is –x.
• The value of x / y is called a quotient.
• A number x is evenly divisible by a number y, if the remainder of x divided by y is zero. The % is the Python remainder operator.
• The terms dataset and table are synonymous. They are lists of lists. The standard view is they are lists of rows, where each row is a list of column values. The individual column values are called cells.

• Local module url

### Imaging pattern

ow, oh = original.size # get dimensions of original

nw, nh = ... # determine dimensions of new image

new_image = Image.new( 'RGB', ( nw, nh ) ) # create new image

for nx in range( 0, nw ) : # fill in every pixel of new image

for ny in range( 0, nh ) :

nspot = (nx, ny ) # set spot to be filled in new image

ospot = ... # determine corresponding spot in original

opixel = original.getpixel( ospot ) # get pixel at corresponding spot

npixel = ... # determine pixel for new image

new_image.putpixel( nspot, npixel ) # set spot in new image

return new_image # return filled in new image

### Sequence expressions †

 Operation Evaluation `len( s )` Length of sequence `s` `sum( s )` Sums the items in sequence `s` `min( s )` Smallest item in sequence `s` `max( s )` Largest item in sequence `s` `x in s` `True` if an item of sequence `s` equals `x`; otherwise, `False` `x not in s` `False` if an item of sequence `s` equals `x`; otherwise, `True` `s + t` New concatenation of sequences `s` and `t` `s * n` New sequence equivalent to adding sequence `s` to itself `n` times `s[ i ]` Value of item at index `i`th of sequence `s` `s[ : ] ` New copy of sequence `s` `s[ i : ] ` New copy of sequence `s` for the elements from index `i` up to and including last sequence element `s[ : j ] ` New copy of sequence `s` for the elements from index `0` up to but not including index `j` `s[ i : j ] ` New copy of sequence `s` for the elements from index `i` up to but not including index `j` `s[ i : j : k ]` New copy of sequence `s` for the elements from index `i` up to but not including index `j` with step `k` `s.index( x )` Index of the first occurrence of item `x` in sequence `s` `s.index( x, i )` Index of the first occurrence of item `x` in sequence `s` at or after index `i` `s.count( x )` Total number of occurrences of item `x` in sequence `s` `s.split()` A new list of the words making up `s` `s.split( '\n' )` A new list of the lines making up `s` `s.split( ',' )` A new list of the comma-separated data cells making up `s`

### Footnote

† Adapted in part from docs.python.org