Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python Number cos() Function


previous next AddThis Social Bookmark Button


Description:

This function returns the cosine of x radians.

Syntax:

cos(x)

Note: This function is not accessible directly so we need to import math module and then we need to call this function using math static object.

Parameters:

Here is the detail of parameters:

  • x: Must be a numeric value

Return Value:

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

Example:

#!/usr/bin/python
import math

print "cos(3) : ",  math.cos(3)
print "cos(-3) : ",  math.cos(-3)
print "cos(0) : ",  math.cos(0)
print "cos(math.pi) : ",  math.cos(math.pi)
print "cos(2*math.pi) : ",  math.cos(2*math.pi)

This will produce following result:

cos(3) :  -0.9899924966
cos(-3) :  -0.9899924966
cos(0) :  1.0
cos(math.pi) :  -1.0
cos(2*math.pi) :  1.0


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names