Content · Programming · Python

Python math.acos() Function: Usage and Examples

Find the angle whose cosine equals a value.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

Find the angle whose cosine equals a value.

What You Will Learn


acos(value) returns radians in the interval 0 through pi. Its real-number domain is [-1, 1].

For floating-point results, remember that stored values are approximations. Rounding a displayed value does not change the exact value used by later calculations.

Step-by-Step Example


The example below makes the behavior visible with small input values that you can change safely.

import math
print(math.acos(0.5))

How the Example Works


  • The imports provide the standard-library tools used in the demonstration: math.
  • The print() calls make the return values or state visible so you can compare them with the explanation and check your prediction.

For the chosen input, the expression math.acos(0.5) prints 1.0471975511965979. Compare that result with the rule above before you change the argument.

Expected output from the example:

1.0471975511965979

Another Example: Compare the Results


Try a second input and compare it with the first. Notice whether the result changes in type, value, order, or number of items.

import math
print(math.acos(1), round(math.acos(0), 4))

Expected output:

0.0 1.5708

When You Would Use This


This operation can support measurements, numeric reports, simulations, or input validation. Choose integer operations when exact integer answers are required, and check floating-point rounding when displaying measured values. Validate units and input domains before using the result in a calculation.

Practice: Modify the Code


Convert acos(0.5) to degrees.

Verify the changed output against the behavior described above, including the relevant invalid or boundary case.

For complete parameters and version details, consult the official Python documentation.

Common Beginner Mistakes


  • Assuming the acos result is expressed in degrees rather than radians.
  • Skipping invalid or boundary inputs when adapting a numeric function to real user data.

Key Takeaways


  • Find the angle whose cosine equals a value.
  • acos(value) returns radians in the interval 0 through pi.
  • Apply this operation only after checking the assumptions and input conditions shown in the example.
Share this resourceSend this page to someone who may find it useful.