Note 21.10.1. Now try this….
Now that you can plot a sine function, how about trying a different function, such as cosine or log?
sin
function from the math library takes a single parameter. This parameter must be a value in “radians” (you may remember this from trigonometry class). Since most of us are used to stating the size of an angle in “degrees”, the math module provides a function, radians
that will convert from degrees to radians for us.
goto
method. goto
takes two parameters, x
and y
, and moves the turtle to that location. If the tail is down, a line will be drawn from the previous location to the new location.
fred.goto(50,60)
goto
method. Experiment with the method to make sure you understand the coordinate system of the screen. Try both positive and negative numbers.
Generate the sine value for each angle. Move the turtle to that position (leave a line behind).
sin
always stays between -1 and 1. This does not give our turtle much room to run.
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 Indexhttp://docs.python.org/py3k/py-modindex.html