Final exam — May 2
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.
Test 3
Downloads (my files must be used)
- Program whoami.py
- Program drops.py
- Program mediate.py
- Program asterisk.py
- Tester t3.py
- Module human.py
- Module wed.py
- Module determine.py
- Module valuable.py
- Module rolling.py
- Module look.py
- Module euclid.py
- Module datable.py
- Module pixie.py
Very important
- Read this web page carefully.
If you need it
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.
- With regard to your submissions:
- Comments including header identifying comments are not necessary.
- You should follow other class style practices; e.g., whitespace, identifier naming, etc.
- Only do what is requested.
- None of the functions should get input or produce output.
- Functions should not modify their parameters in any way.
- Whether code is testable (runs) is important.
Important
- Based on your many past educational achievements, I expect you to do well on this test.
- This pledged exam is closed notes. The only device you may access during the test is your laptop. Uploading after you leave the room will be treated as an honor violation.
- Do not leave the room without checking that you have made thirteen submissions for Test 3. The check will inform you if something is missing. Do not ask afterwards whether you can submit a forgotten solution.
- Do not access class examples, web solutions, other people's code, or your own past assignments during the test; that is, the only code you may access or view are ones that you develop for this test. Any cheating on a test can result in failing the class and the incident being referred to the Honor Committee.
- To make things go smoother, you are strongly encouraged to submit as you go along.
- The only windows to be open on your computer are PyCharm and a single browser with tabs reachable from the class website.
- You are responsible for reading the test in its entirety.
- Answer the questions in any order that you want.
- Read each question both thoroughly and mindfully of what is being asked.
- To receive points, you must turn in your test.
- No cell phone access during the test. If you need to leave the room, please leave your electronic devices.
- I suggest you do things the easiest way possible. There are no intended trick questions. Each module has a straight-forward answer.
Helpful documenation
- Module list
- Module random
- Module str
- Module pillow
- 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 sequences
equalsx
; otherwise,False
x not in s
False
if an item of sequences
equalsx
; otherwise,True
s + t
New concatenation of sequences s
andt
s[ i ]
Value of item at index i
th of sequences
s[ : ]
New copy of sequence s
s[ i : ]
New copy of sequence s
for the elements from indexi
up to and including last sequence elements[ : j ]
New copy of sequence s
for the elements from index0
up to but not including indexj
s[ i : j ]
New copy of sequence s
for the elements from indexi
up to but not including indexj
s[ i : j : k ]
New copy of sequence s
for the elements from indexi
up to but not including indexj
with stepk
s.index( x )
Index of the first occurrence of item x
in sequences
s.index( x, i )
Index of the first occurrence of item x
in sequences
at or after indexi
s.count( x )
Total number of occurrences of item x
in sequences
s * n
New sequence equivalent to adding sequence s
to itselfn
times
Footnote
† Adapted in part from docs.python.org