math.cos()

Published May 19, 2021Updated Aug 7, 2023
Contribute to Docs

The math.cos() function returns the cosine of an angle.

Syntax

math.cos(n)

The math.cos() function returns a numeric value between -1 and 1, which represents the cosine of the value n.

Example

Use math.cos() to return the cosine of a 90 degree angle:

import math
print(math.cos(90))
# Output: -0.4480736161291702

Codebyte Example

The following example is runnable and uses the math.cos() function to return the cosine of a number:

Code
Output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy