Easy Tutorial
❮ Python Func Number Random Python Func Zip ❯

Python3 cos() Function

Python3 Numbers


Description

The cos() function returns the cosine of x radians.


Syntax

Here is the syntax for the cos() method:

import math

math.cos(x)

Note: The cos() function cannot be accessed directly; you need to import the math module and then call this function using the math static object.


Parameters


Return Value

Returns the cosine of x radians, between -1 and 1.


Example

The following example demonstrates the use of the cos() method:

#!/usr/bin/python3
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))

The output of the above example is:

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

Python3 Numbers

❮ Python Func Number Random Python Func Zip ❯