Due by class time Wednesday, February 8
If you wish, you may work with a partner on this assignment.
If you haven't already done so, finish reading Chapter 4 of your Python textbook.
For next Friday, read Mind Design Chapter 6: From Micro-Worlds to Knowledge Representation: AI at an Impasse by Hubert Dreyfus.
These will give you extra practice with Python, but you do not need to turn them in. I would strongly recommend doing them if you have never programmed before.
Exercises 1, 2, and 3 on pages 116-117 of the Python textbook. Do these interactively in the Python interpreter, and make sure to type them in exactly as shown.
Re-read sections 4.5.2 and 4.5.3 (pages 102-106) on string formatting and then do Exercise 4 on page 117 interactively in Python.
The following problems should be turned in. Using IDLE, create a new file named assign2.py and put all of your program definitions in this file. That way, you can load them all into Python at once for testing by simply pressing the [F5] key.
Finish the problems from Lab 3. Name your programs as follows:
Problem 8 on page 119: Caesar ciphers. You should define two programs, one for encoding messages called encode() and the other for decoding messages, called decode(). The key value used to encode or decode a message should be kept small, in order to avoid problems (see the Extra Credit below). For example:
>>> encode() Enter a message: Sourpuss Enter a key: 2 The encoded message is: Uqwtrwuu >>> decode() Enter a message: Uqwtrwuu Enter a key: -2 The decoded message is: Sourpuss
Problem 12 on page 120: string formatting. Call your program chaos(). Try to make your program's output look exactly like the output shown in the book.
EXTRA CREDIT
Problem 7 on page 119. Call your program fullnameValue(). Hint: Reuse the code you wrote for problem 6, which computes the numeric value of an individual name, but embed it within an outer for-loop, which cycles through each name in the full name entered by the user. In other words, you'll have a for-loop within a for-loop!
Put all of your function definitions into a single Python file called assign2.py and include your name in a comment (i.e. a line beginning with #) at the top of the file. Submit this file electronically by running the /common/cs/submit/cs30-submit script from any Pomona Linux machine. Be sure to run this command from the directory containing your file.
If you have questions about anything, don't hesitate to ask!