Take the program “combined.py” and add a loop so that the user can continue entering messages to encipher or decipher. When done, the user should type ’q’ (or ’Q’) to exit the program.
In addition, when an exception occurs during input (for example, the user types a keyboard interrupt — usually control-c), terminate the program without printing the usual exception message.
Here is a sample run. As usual, what you type is in red:
e to encrypt, d to decrypt, q to quit): e Enter your message: WHENINTHECOURSEOFHUMANEVENTS plain = "WHENINTHECOURSEOFHUMANEVENTS"; cipher = "WEITEOREFUAEETHNNHCUSOHMNVNS" e to encrypt, d to decrypt, q to quit): d Enter your ciphertext: WEITEOREFUAEETHNNHCUSOHMNVNS cipher = "WEITEOREFUAEETHNNHCUSOHMNVNS"; plain = "WHENINTHECOURSEOFHUMANEVENTS" e to encrypt, d to decrypt, q to quit): qSubmit. Name your file “looper.py” and submit it to the Extra Credit #3 area for this class on SmartSite.
You can also obtain a PDF version of this. | Version of May 7, 2014 at 11:49PM |