Question: 1. Create and set up the turtle and the screen. 2. Iterate the angle from 0 to 360. o Generate the sine value for each

1. Create and set up the turtle and the screen.

2. Iterate the angle from 0 to 360.

o Generate the sine value for each angle.

o Move the turtle to that position (leave a line behind).

Here is a partial program for you to complete.

import math

import turtle

wn = turtle.Screen()

wn.bgcolor('lightblue')

fred = turtle.Turtle()

#your code here

#iterate the angle from 0 to 360.

#Generate the sine value for each angle.

#Move the turtle to that position (leave a line behind).

wn.exitonclick()

_____________________________________________________________

Making the Plot Better

You probably think that the program has errors since it does not draw the picture we expect. Maybe you think it looks a bit like a line? What do you think the problem is? Here is a hintgo back and take a look at the values for the sine function as they were calculated and printed in the earlier example.

Now can you see the problem? The value of sin always stays between -1 and 1. This does not give our turtle much room to run.

In order to fix this problem, we need to redesign our graph paper so that the coordinates give us more room to plot the values of the sine function. To do this, we will use a method of the Screen class called setworldcoordinates. This method allows us to change the range of values on the x and y coordinate system for our turtle. Take a look at the documentation for the turtle module to see how to use this method (Global Module Index).

Now add wn.setworldcoordinates(0, -1, 360, 1) to the appropriate place in the program. Run the program. What does the graph look like now?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!