Python acos

The Python acos function calculates the trigonometry Arc cosine for the specified expression. The acos or Arc cosine is also called the inverse of a cosine. This section discusses how to use the Python acos function with an example.

The syntax of the Python acos or arccos Function is


Number: It can be a number or a valid numerical expression for which you want to find the 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 acos Function allows you to find the trigonometry Arc Cosine for the numeric values. In this Python acos example, we will find the Arc Cosine values of different data types and display the output.

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 arccos of the corresponding values.

Next, We used the arccos Function on Tuple and List items. If you observe the screenshot above, the acos function works perfectly on them. Next, We used this math function on multiple values.

And within the last statement, we tried the Python acos Function on the String value, which returns TypeError.

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