Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use these two functions as models for the functions you are to write. You will be removing code from main() and putting it in several

Use these two functions as models for the functions you are to write. You will be removing code from main() and putting it in several separate functions. The behavior of the program will not change throughout the exercise, so you can always tell if your program is correct. Use the non-fruitful function drawRect as a model. Write another non-fruitful function that moves a turtle forward without drawing a line. The function is defined as def skipForward(t, len): """ Moves the turtle t forward len units without drawing anything. """ and called with a statement like skipForward(alex, 20) The contents of the function are to lift the pen, move the turtle, then lower the pen. Write another non-fruitful function skipTo, which is defined as def skipTo(t, x, y): """ Moves the turtle t to coordinates (x,y) without drawing anything. """ and is called with skipTo(alex, xpos, ypos) Make sure to use the parameters x and y in the body of this function. Next, you'll work with fruitful functions. Look at the function to calculate the next y-position for drawing a set of shapes. This function is called near the bottom of the program: ypos = next_y_position(ypos, width) Using this function as a model, add a fruitful function to calculate the perimeter of a rectangle. The function is defined with def perimeter(len,wid): """ Returns the perimeter of rectangle with sides len and wid. """ and it is called with the statement p = perimeter(length, width) Make sure you use the parameters len and wid in the body of the function. Again, using this function as a model, add a fruitful function to calculate the value math.sqrt(length*width/math.pi) which appears near the end of the program. The function should be defined as def circ_rad(len, wid): """ Returns the radius of a circle with an area of len * wid """ Mimic the call from what you did in the previous step Make sure that your main function is calling each of the non-fruitful functions at least twice.

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions