Monday, June 5, 2023

The math module - trigonometric functions

 Some of the trigonometric functions defined in the math module are as follows:

import math

# calculate arc tangent in radians

print ("atan(0) : ",math.atan(0))

print("**************")

# cosine of x

print ("cos(90) : ",math.cos(0))

print("**************")

# calculate hypotenuse

print ("hypot(3,6) : ",math.hypot(3,6))

print("**************")

# calculates sine of x

print ("sin(0) : ", math.sin(0))

print("**************")

# calculates tangent of x

print ("tan(0) : ",math.tan(0))

print("**************")

# converts radians to degree

print ("degrees(0.45) : ",math.degrees(0.45))

print("**************")

# converts degrees to radians

print ("radians(0) : ",math.radians(0))

OUTPUT

atan(0) : 0.0

**************

cos(90) : 1.0

**************

hypot(3,6) : 6.708203932499369

**************

sin(0) : 0.0

**************

tan(0) : 0.0

**************

degrees(0.45) : 25.783100780887047

**************

radians(0) : 0.0

>>>

Share:

0 comments:

Post a Comment