- This script draws a sine wave using the built-in Python library Turtle.
- The image below demonstrates the equation of a sine wave.
Run the Script:
- Open a terminal
- Navigate to the “Sine_Wave” directory containing this python file using the command prompt.
Code language: CSS (css)
Code language: PHP (php)
from turtle import * from math import * A = 50 # Amplitude B = 100 # WaveLength C = 0 # Horizontal Shift D = 0 # Vertical Shift penup() # As x increases y increases and decreases as it is evaluated. for x in range(-200, 200): # Sine Wave Equation y = A * sin((2 * pi / B) * (x + C)) + D goto(x, y) pendown() hideturtle() mainloop()