cos function in python

In this tutorial, you will learn about the cos function in python.This will give you the cosine of the angle in degrees. Remember, math.cos() takes the angle in radians, so you may need to convert it if your angle is given in degrees.

cos() in python

The cos() function in Python calculates the cosine of a given angle. The angle must be in radians, not degrees. The result will be a number between -1 and 1, where -1 corresponds to an angle of π radians (180 degrees) and 1 corresponds to an angle of 0 radians (0 degrees).

import math

angle_radians = math.pi / 6
cosine_value = math.cos(angle_radians)
print("Cosine of", angle_radians, "radians is:", cosine_value)

output:

Cosine of 0.5235987755982988 radians is: 0.8660254037844387

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top