CS151 HW#4

Tara Davidson '10

Write up:

  1. A brief description of the task (in your own words): In this assignment, I modified my processString function so that a user can call shapes as well as simple turtle commands such as up(), down(), forward(10), backward(10), right(30), left(30) with just one character and those commands can be processed in a string. After this, I made my function capable of letting my user save their string to a file with a filename of their choosing. My function opens a file, let's the user name that file, then let's the user create a string to put in that file, and then the user's string is saved to that file. This function is in follow.py and I created imageA with this function. In the second part of the assignment, I created a new BBEdit file, linearC.py, and I created a new function that asks my user for an existing filename, opens that existing file, reads the first line of that file and stores it as a string, then processes that string. I made a file, mem4.txt, with the string: tftftftrrsfsfsfsllliii in it. Then when I called linearC.py I choose to open mem4.txt, and imageB was created.
  2. Describe your user interface and explain how your programs work In follow.py, my function's user interface involves asking my user "Enter a file name to save" and then lets the user put in any raw input for the file name. In addition, the file prints out all the characters that have functions attached to them to remind the user which characters are valid for the string they are about to type in. Then the function asks the user "Enter a string of the characters above" and lets the user type in a string of those characters. If the user types in a string without any characters, nothing happens and "Done" is printed. If the user types a string with a character that isn't defined, the string is processed but everytime an undefinted character is processed, the user will read "I'm sorry I don't know what to do with that character."
  3. The two required scenes
    Picture of imageA:



    Picture of imageB: