Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

How to Find Cos or Cosine in Python

Cosine is one of the basic trigonometric ratios. To find out cos or cosine in Python we use math.cos() function.
 

cos() function in Python

math.cos() function is from Slandered math Library of Python Programming Language. The purpose of this function is to calculate cosine of any given number either the number is positive or negative.

 

Syntax of cos()

The syntax of cos() function in Python is:
math.cos( x )

 

Parameters of cos() Function

x Any valid Python number (positive or negative). This parameter is required.
Note: if the x parameter is not a number, cos() function will return an error.

 

Python cos() Function Compatibility

Python 2.x – Yes
Python 3.x – Yes

 

Return Value of cos()

cos() function will return a floating point number (a value of cosine of x radian).

 

Python cos() Function Example


Output of Python cos() function:
0.9800665778412416
1.0
0.9800665778412416
0.5403023058681398
0.28366218546322625

 

Loading...
LearnAndLearn.com © 2018 - All rights reserved