- 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.
Execute:
python sine_wave.py
Code language: CSS (css)
Source Code:
sine_wave.py
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()
Code language: PHP (php)
Output:
