Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago