Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.cos() Method

Python math.cos() Method

Python math Module Python math Module

Python math.cos(x) Returns the cosine of x radians.

Python version: 1.4

Syntax

The syntax of the math.cos() method is as follows:

math.cos(x)

Parameter Description:

Return Value

Returns a floating-point number representing the cosine of x, between -1 and 1.

Example

The following example returns the cosine of numbers:

Example

Import the math package

import

math

Output the cosine values

print

(

math

.

cos

(

0.00

)

)

print

(

math

.

cos

(

1.23

)

)

print

(

math

.

cos

(

10

)

)

print

(

math

.

cos

(

3.14159265359

)

)

Output result:


1.0
0.3342377271245026
-0.8390715290764524
-1.0

Python math Module Python math Module