Graphing A Sine Wave With Python Turtle

A further lesson on graphing equations

--

Graph of sine waves
source screenshot my computer

In a previous lesson we introduced the concept of graphing equations. In this lesson we are going to graph the equation of a sine wave.

Here’s the code:

import turtle as T
import math
T.width (5)
amplitude = 30
frequency = 6
frequency2 = 7
T.penup()
T.goto(-300,0)
T.pendown()
for i in range (-300,300,frequency):
y = (math.sin(i))* (2*math.pi*amplitude)
T.goto(i,y)
T.pencolor ("red")
T.penup()
T.goto (-300,0)
T.pendown()
for i in range (-300,300,frequency2):
y = (math.sin(i))* (2*math.pi*amplitude)
T.goto(i,y)
T.hideturtle()

The sine wave is an import concept in It in both pure and applied mathematics, as well as physics, engineering, signal processing and many other fields.We will be looking at this in more detail in subsequent lessons. For now experiment with changing the amplitude and the frequency.

Jim McAulay🍁 says “It takes a village to raise a child. It takes a distillery to homeschool one.”.

81–78

--

--

Jim McAulay🍁 I'm nobody. Are you a nobody too?
ILLUMINATION

I love puns. https://medium.com/@Jim_McAulay/membership Use this link if you love them too. I’m not joking, but Stephen King has a son who is Joe King.