Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

math.cos

Computes the cosine of an angle measured in radians.

Version: Python 3.14; repository image, production runtime not attested

Syntax

math.cos(x, /)

Computes the cosine of an angle measured in radians.

Zero radians gives one. Angles specified in degrees must be converted before evaluation.

Cosine is the horizontal coordinate on the unit circle. A half turn (pi radians) gives −1 and a zero angle gives 1. The first print rounds the result for display. To use an angle measured in degrees, convert it with math.radians.

import math
assert math.isclose(math.cos(math.radians(180)), -1.0)
assert math.cos(0) == 1.0

Examples

import math
print(round(math.cos(math.pi), 6))
print(math.cos(0))

Result

-1.0
1.0

Cosine is the horizontal coordinate on the unit circle. A half turn (pi radians) gives −1 and a zero angle gives 1. The first print rounds the result for display. To use an angle measured in degrees, convert it with math.radians.

Sources