math.sin(x) computes the trigonometric sine of angle x, where x is measured in radians, not degrees.
If your angles are in degrees, wrap them with math.radians() before calling math.sin(), such as math.sin(math.radians(30)).
math.sin() is a function in Python's standard math module: import it with import math and call math.sin(...), or import the name directly with from math import sin.
Syntax
Import math and pass an angle in radians.
python
import math
y = math.sin(angle_radians)
Call
What it does
math.sin(0)
Returns 0.0.
math.sin(math.pi / 6)
Returns 0.49999999999999994 (close to 0.5).
math.sin(math.pi)
Returns 1.2246467991473532e-16 (near 0 due to float pi).
math.sin(float("inf"))
Raises ValueError: domain error.
Because math.pi is a finite float approximation of pi, math.sin(math.pi) returns a tiny value near 1.22e-16 instead of exact 0.0.
Function signatures
python
math.sin(x, /)
# returns: float sine of x radians
Parameters
Parameter
Description
x
Required positional finite angle in radians (int or float).
Return Value
Return Value
Description
float
Sine of x in the range [-1.0, 1.0]; returns nan for nan.
Python Examples
Example 1 — Sample Sine Wave Displacement Across Angles
Convert degree angles to radians and print formatted wave amplitudes from 0 to 270 degrees.
python
import math
for deg in [0, 30, 90, 180, 270]:
amp = math.sin(math.radians(deg))
print(f"{deg:>3} deg -> {amp:+.4f}")