Most homework and lab assignments are taken from the M2 textbook. This page
lists the assignments not from the M2 textbook.
Lab08: due Wed 19 Nov / Thu 20 Nov
Complete one of Lab04-07 in Modula-2, with a full lab write-up.
Some labs gave you a choice of problems; you need not choose the same problem,
but you may. You may reuse parts of your old lab write-up if appropriate,
although some refinements of your pseudocode may need to be revisited before
you start your M2 code. You may wish to refer to
the Stonybrook M2
tutorial and the M2 text.
HW08: due Mon 24 Nov
Calculate a knight's
tour for a 3x4 board, starting at the corner (0,0). In addition to the
completed board, also show all your backtracking, using a tree diagram or a
list of moves or whatever you see fit.
Lab09: due Wed 26 Nov / Thu 27 Nov
Write a library that provides robust user input:
For each basic Python data type (int, float, bool, str), provide a function
that reads input from
the keyboard and returns the value in the proper type.
E.g., input_str(), input_bool(), etc.
- If the user types an invalid input (e.g., a string when an
integer is expected), then an error message is printed, and
the function keeps prompting the user until
the user does enter a valid input.
- Make sure to handle if the user just presses "Enter" without any input.
- Also provide a way for the user to cancel.
- Each function should be able to take
either zero or one parameters; the parameter, if present, should be the
prompt string (just like with regular input()).
- Each function should return a value of the proper type, or
None if the user cancelled.
- For input_bool(), allow the user to type any of
(1, T, t, True, true, TRUE, Y, y, Yes, yes, YES) etc. for True,
and any of (0, F, f, False, false, FALSE, N, n, No, no, NO) etc. for
False.
- Hint: exception handling may be useful.
Lab10: due Wed 3 Dec / Thu 4 Dec
Write a Python program to calculate a knight's tour of an arbitrary-size
board, given the dimensions of the board and the starting position.
References you may find useful (cite them in your lab write-up if you use
them):