Free cookie consent management tool by TermsFeed The cos() function - Python math module | Pythontic.com

The cos() function - Python math module

Method name:

cos(aRadians_in)

Parameters:

aRadians_in : Angle in radians for which the cosine value is to be found.

Method overview:

In Python, the math.cos() function returns the cosine value for the given angle in radians. The cosine value of an angle is given by the ratio of adjacent to the hypotenuse.

Cosine value of an angle

Return value:

The cosine value for the given angle in radians is returned.

Example:

# Example Python program that finds the 
# cosine values for the common angles
# in degrees using the math.cos() function.
import math

# Find the cosine value for zero degrees
radians_0            = math.radians(0)
# Convert zero degrees to radians
cosine_0            = math.cos(radians_0)
cosine_0_rounded      = round(cosine_0, 2)

# Find the cosine value for 30 degrees
radians_30           = math.radians(30)
# Convert 30 degrees to radians
cosine_30            = math.cos(radians_30)
cosine_30_rounded    = round(cosine_30, 2)

# Find the cosine value for 45 degrees
radians_45           = math.radians(45)
# Convert 45 degrees to radians
cosine_45            = math.cos(radians_45)
cosine_45_rounded   = round(cosine_45, 2)

# Find the cosine value for 60 degrees
radians_60           = math.radians(60)
# Convert 60 degrees to radians
cosine_60            = math.cos(radians_60)
cosine_60_rounded    = round(cosine_60, 2)

# Find the cosine value for 90 degrees
radians_90           = math.radians(90)
# Convert 90 degrees to radians
cosine_90           = math.cos(radians_90)
cosine_90_rounded   = round(cosine_90,2)

# math.cos(degrees) : Python Example: Printing cosine values for common

# angles
print("Cosine(0 degrees):{}".format(cosine_0_rounded))
print("Cosine(30 degrees):{}".format(cosine_30_rounded))
print("Cosine(45 degrees):{}".format(cosine_45_rounded))
print("Cosine(60 degrees):{}".format(cosine_60_rounded))
print("Cosine(90 degrees):{}".format(cosine_90_rounded))

Output:

Cosine(0 degrees):1.0
Cosine(30 degrees):0.87
Cosine(45 degrees):0.71
Cosine(60 degrees):0.5
Cosine(90 degrees):0.0


Copyright 2025 © pythontic.com