Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

Python ACOS

by suresh

The Python ACOS function is one of the Python Math function which is used to calculate the trigonometry Arc cosine for the specified expression. Arc cosine is also called as inverse of a cosine, Please refer Python COS Function article to understand the Cosine Function. In this article we will show you, How to use ACOS() function in Python Programming language with example.

Syntax of a Python ACOS Function

The basic syntax of the ACOS Function in Python Programming Language is as shown below:

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 positive or negative number, acos() function will return the Arc Cosine value.
  • If the number argument is not a number, acos() function will return TypeError.
  • If the number argument is outside the range -1 and 1, acos() function will return ValueError.

Python ACOS Function Example

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

PYTHON CODE

# 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'))

OUTPUT

Python ACOS Function

ANALYSIS

First, We declared Python List and Tuple with some random values. Next, We used the ACOS() Function directly on both the Positive integer and negative integer. Following statements will 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 Python Tuple and List items. If you observe the above screenshot, 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() Function directly 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 ACOS() Function on String value. As we said before, this will return TypeError as output

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

Thank You for Visiting Our Blog

Placed Under: Python

Stay in Touch!

Sign Up to receive Email updates on Latest Tutorials

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy