Python math.cos()

ishg-153's avatar
Published May 19, 2021Updated Mar 17, 2024
Contribute to Docs

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

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours

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

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours