math.cos()

Anonymous contributor's avatar
Anonymous contributor
Published May 19, 2021Updated Mar 17, 2024
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))

The above code gives the following output:

-0.4480736161291702

Codebyte Example

Run the following example that uses the math.cos() function to understand its working:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy