|
home—info—lectures—exams—hws—archive
Due Dec.11 23:59
Submit a python program with the following. (Practice good code, as always: Use named constants and helper functions/methods as appropriate; include comments giving the signature and purpose of each (non-anonymous) function.)
Write a function which takes in a list of trucks
and moves all of them using
Include three to four test cases; print out the list before calling the function, and then again on the result / after calling the function. At least one test should call the function enough times so that all the initial trucks have left the scene.
This should be a function which returns a new list;
otherwise you couldn't easily use
Extra credit (5pts):
modify your list-function to be a procedure which mutates, instead.
In order to have your changes seen by the caller, you'll need to
be roundabout: have the caller “box” the real data into
a list-of-length one,
and have your procedure replace the first element of
the (singleton) list it receives.
Provide tests.
See the lecture notes for
how to run python (either as a script, or interactively).
You can
home—info—lectures—exams—hws—archive
©2009, Ian Barland, Radford University Last modified 2009.Dec.06 (Sun) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |