📜  Python中的数学函数 |第 3 组(三角函数和角函数)

📅  最后修改于: 2022-05-13 01:55:32.539000             🧑  作者: Mango

Python中的数学函数 |第 3 组(三角函数和角函数)

一些数学函数在下面的集合 1 和集合 2 中讨论

Python中的数学函数 |第 1 组(数值函数)
Python中的数学函数 |第 2 组(对数和幂函数)

本文讨论了三角函数和角函数。

1. sin() :- 此函数返回作为参数传递的值的正弦值。在这个函数中传递的值应该是弧度

2. cos() :- 该函数返回作为参数传递的值的余弦值。在这个函数中传递的值应该是弧度

# Python code to demonstrate the working of
# sin() and cos()
   
# importing "math" for mathematical operations
import math
  
a = math.pi/6
   
# returning the value of sine of pi/6
print ("The value of sine of pi/6 is : ", end="")
print (math.sin(a))
   
# returning the value of cosine of pi/6
print ("The value of cosine of pi/6 is : ", end="")
print (math.cos(a))

输出:

The value of sine of pi/6 is : 0.49999999999999994
The value of cosine of pi/6 is : 0.8660254037844387

3. tan() :- 该函数返回作为参数传递的值的正切值。在这个函数中传递的值应该是弧度

4. hypot(a, b) :- 这将返回参数中传递的值的斜边。在数值上,它返回sqrt(a*a + b*b)的值。

# Python code to demonstrate the working of
# tan() and hypot()
   
# importing "math" for mathematical operations
import math
  
a = math.pi/6
b = 3
c = 4
   
# returning the value of tangent of pi/6
print ("The value of tangent of pi/6 is : ", end="")
print (math.tan(a))
   
# returning the value of hypotenuse of 3 and 4
print ("The value of hypotenuse of 3 and 4 is : ", end="")
print (math.hypot(b,c))

输出:

The value of tangent of pi/6 is : 0.5773502691896257
The value of hypotenuse of 3 and 4 is : 5.0

5. degree() :- 此函数用于将参数值从弧度转换为度数

6. radians() :- 此函数用于将参数值从度数转换为弧度

# Python code to demonstrate the working of
# degrees() and radians()
   
# importing "math" for mathematical operations
import math
   
a = math.pi/6
b = 30
  
# returning the converted value from radians to degrees
print ("The converted value from radians to degrees is : ", end="")
print (math.degrees(a))
   
# returning the converted value from degrees to radians
print ("The converted value from degrees to radians is : ", end="")
print (math.radians(b))

输出:

The converted value from radians to degrees is : 29.999999999999996
The converted value from degrees to radians is : 0.5235987755982988