Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3, Turtle draw help! Turtle Paint A new graphics file format called turtle has been created and you are tasked writing a python program

Python 3, Turtle draw help!

Turtle Paint A new graphics file format called turtle has been created and you are tasked writing a python program to read the data from the file and using the turtle module to draw the shapes from the file. This assignment will have you using your skills with file handling, error handling, string manipulation and using the turtle module. To make this easier you should use your newfound knowledge of functions to break the program down into smaller testable portions.

The input file contains commands to draw with turtle. Each line is a separate action or item to draw. There are three different commands; rect, circle, and line. The beginning of each line will contain the command followed by the arguments for the command. The arguments are separated by a comma. 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.

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

:You will want to take note of how turtle draws a circle and what the starting point and direction is. It does not assume the turtle is at the center of the circle. Try a circle with the heading set to 0 degrees. Then try another with heading at 45 degrees. What is the difference? Youll want to account for this when figuring out how to draw it with a given center. You may find setting the initial heading of the turtle aids in drawing consisten circles

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.

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.

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.

Break this down into small parts. Debug each part thoroughly before moving on. Create a function to draw a filled circle with the center at a given point and given radius. Create a function to draw a filled rectangle et.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

2. What are Seventh Generations four sustainability goals?

Answered: 1 week ago