Question: I need help writing a python program to draw a circle, line and rectangle from inputed files in python. RECT Command The rect command is
I need help writing a python program to draw a circle, line and rectangle from inputed files in python.
RECT Command
The rect command is used to draw a rectangle with turtle. It has 5 arguments; x, y, width, height and color. x and y are the top left coordinates of the rectangle. The rectangle drawn should be filled in with the color given when complete.
rect,-100,100,200,50,Red
Circle Command
The circle command draws a circle. There are 4 arguments passed to the circle command the x, and y coordinate for the center of the circle and the radius of the circle and the color to fill the circle
circle,0,0,100,blue
Line Command
The line command draws a simple line. It is used to draw a line from a given x, y in a particular direction for the given length. There are 5 arguments; x, y, heading, length and color of line. line,20,20,45,100,green
Requirements
The program should ask the user for the file to open and draw with turtle. If the file does not exist, the program should warn the user and ask for a valid filename again. (use error handling)
Read through the file performing the actions specified with the arguments given. The files will be plain text with the command and arguments separated by commas.
If the line is an invalid command, warn the user and output the line to the shell. The program should continue execution of the text file.
If a command has too few arguments, or an integer argument cant be converted, you should warn the user in the console and output the line that caused the problem. The program should continue execution of the text file.
After the file has been drawn the user can enter another file to be drawn. Before drawing a new image you should clear the current turtle screen.
If the user enters quit for the filename the program ends.
Development notes
When moving the turtle to a new location it will continue to draw. You need to find a way to suppress that action. If it was a pen on paper youd pick the pen up.
Circle and rectangle should fill when complete.
Set the turtle speed to the fastest speed before submitting your program. While debugging you may want to slow it down if you are having trouble and want to see what the turtle is doing better.
Please help!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
