CSCI-UA.002 -- Python -- Summer, 2017
Nathan Hull
ASSIGNMENT 7
Due: Tuesday, August 1st
Write a program that allows a user to type an interactive series of commands which would control the turtle. Here are the possible commands:
- DEG - Sets the number of degrees (N_deg) which will be used for a future turn (Defaults to 90 if not set)
- L - Turns left N_deg degrees (defaults to 90 if DEG not previously called)
- R - Turns left N_deg degrees (defaults to 90 if DEG not previously called)
- DIST - Sets the distance in pixels (N_dist) which will be used for a future F (forward command) (Defaults to 10 if not set)
- F - Moves the turtle forward N_dist number of pixels (Defaults to 10)
- RED - Sets the pen to red
- BLUE - Sets the pen to blue
- GREEN - Sets the pen to green
- BLACK - Set the pen to black (the default)
- UP - Picks the pen up
- DOWN - Puts the pen down
- Q - Quits the program
Note that each one of these commands should call its own Function (Def). In the case of te F, L, and R commands, those functions should be sent a parameter indicating the distance or the number of degrees.
Here is a possible session which your user might have:
DIST
100
F
L
F
L
F
L
F
L
RED
DEG
120
F
L
F
L
F
L
Q
|
This would draw a red triangle inside of a black box.
EXTRA CREDIT (3 points)
Prompt the user at the beginning of the program on whether he/she wants to have input from the keyboard, or from a disk file. If the disk file option is chosen, further prompt the user for the name of the file which contains the "interactive" turtle commands.
PART TWO:
-
When you are done and have tested it, post your source file "smith_john_assign7"
to NYU Classes.
Notes about your program:
- Make sure your program includes a comment at the beginning of the program,
listing your personal
info along with a brief synopsis of the program's function.
- You should use comments throughout the source code to explain key steps
and calculations.
- Choose intuitive names for variables.