Python acos

The Python acos function calculates the trigonometry Arc cosine for the specified expression. Python acos or Arc cosine also called the inverse of a cosine. In this section, we discuss how to use acos function in Python with example.

The syntax of the acos Function in Python Programming Language is

math.acos(number);

Number: It can be a number or a valid numerical expression for which you want to find Arc cosine value.

  • If the number argument is a positive or negative number, the acos function returns the Arc Cosine value.
  • If it is not a number, the acos function returns TypeError.
  • And if it is outside the range -1 and 1, acos function returns ValueError.

Python acos Function Example

The Python acos Function allows you to find the trigonometry Arc Cosine for the numeric values. In this acos example, we are going to find the Arc Cosine values of different data types and display the output.

# Python ACOS Function

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 Cosine value of Positive Number = %.2f' %math.acos(1))
print('Arc Cosine value of Negative Number = %.2f' %math.acos(-1))

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

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

First, we used the acos Function directly on both the Positive integer and negative integer. The following statements find the Arc Cosine of the corresponding values.

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

Next, We used the acos Function on Tuple and List items. If you observe the above screenshot, the acos function is working perfectly on them.

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

Next, We used the acos Math function on multiple values.

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

Within the last statement, we tried the acos Function on the String value, and it returns TypeError.

print('Arc Cosine value of String Value = ', math.acos('Python'))

Please refer to the Python cos Function article to understand the Python Cosine Function.