Python Function Reference

math.cos

Calculate the cosine of an angle.

Python 3.13
math.cos(x)
x
The angle in radians.
int | float

Return value

A float from -1 to 1.

Examples

Cosine of zero

Python 3.13
import math
print(math.cos(0))
1.0

Cosine of an angle in degrees

Python 3.13
import math
print(round(math.cos(math.radians(60)), 2))
0.5

Details

Convert an angle in degrees with math.radians first.

See also

Where to learn