Python asin

Python asin 函数用于计算指定表达式的反正弦(Arc Sine)。asin 或 Arc Sine 也称为正弦的倒数。在本节中,我们将通过示例讨论如何使用 asin 函数。

Python asin 函数的语法如下所示。

math.asin(number);

Number:一个有效的数值表达式,用于查找反正弦值。

  • 如果数字参数是正数或负数,asin 函数将返回反正弦值。
  • 如果它不是数字,asin 函数将返回 TypeError。
  • 如果它超出 -1 和 1 的范围,asin 函数将返回 ValueError。

Python asin 函数示例

asin 函数允许您查找数值的反正弦。在此 asin 示例中,我们将查找不同数据类型的反正弦值并显示输出。

import math

Tup = (0.21, 0.12, 0.39, -0.89 , 0.42) # Tuple Declaration
Lis = [-0.1, 0.92, 0.35, -0.46 , 0.85] # List Declaration

print('Arc Sine value of Positive Number = %.2f' %math.asin(1))
print('Arc Sine value of Negative Number = %.2f' %math.asin(-1))

print('Arc Sine value of Tuple Item = %.2f' %math.asin(Tup[3]))
print('Arc Sine value of List Item = %.2f' %math.asin(Lis[2]))

print('Arc Sine value of Multiple Number = %.2f' %math.asin(0.10 + 0.20 - 0.40))
print('Arc Sine value of String Value = ', math.asin('Python'))
Python ASIN Function

首先,我们将 asin 函数直接应用于正整数和负整数。以下语句查找相应值的反正弦。

print('Arc Sine value of Positive Number = %.2f' %math.asin(1))
print('Arc Sine value of Negative Number = %.2f' %math.asin(-1))

接下来,我们将 asin 函数应用于 元组列表 项。如果您查看上面的截图,asin 函数在它们上运行得非常好!

print('Arc Sine value of Tuple Item = %.2f' %math.asin(Tup[3]))
print('Arc Sine value of List Item = %.2f' %math.asin(Lis[2]))

接下来,我们将 asin 数学函数 直接应用于多个值。

print('Arc Sine value of Multiple Number = %.2f' %math.asin(0.10 + 0.20 - 0.40))

在最后一个语句中,我们尝试将 asin 函数应用于字符串值,这会返回 TypeError。

print('Arc Sine value of String Value = ', math.asin('Python'))

请参阅 sin 函数文章以了解Python 正弦函数。