TheAlgorithms/Python · error · ValueError

Invalid angle. Range is 1-90 degrees.

Error message

Invalid angle. Range is 1-90 degrees.

What it means

Error "Invalid angle. Range is 1-90 degrees." thrown in TheAlgorithms/Python.

Source

Thrown at physics/horizontal_projectile_motion.py:41

# Acceleration Constant on Earth (unit m/s^2)
g = 9.80665


def check_args(init_velocity: float, angle: float) -> None:
    """
    Check that the arguments are valid
    """

    # Ensure valid instance
    if not isinstance(init_velocity, (int, float)):
        raise TypeError("Invalid velocity. Should be an integer or float.")

    if not isinstance(angle, (int, float)):
        raise TypeError("Invalid angle. Should be an integer or float.")

    # Ensure valid angle
    if angle > 90 or angle < 1:
        raise ValueError("Invalid angle. Range is 1-90 degrees.")

    # Ensure valid velocity
    if init_velocity < 0:
        raise ValueError("Invalid velocity. Should be a positive number.")


def horizontal_distance(init_velocity: float, angle: float) -> float:
    r"""
    Returns the horizontal distance that the object cover

    Formula:
        .. math::
            \frac{v_0^2 \cdot \sin(2 \alpha)}{g}

            v_0 - \text{initial velocity}

            \alpha - \text{angle}

View on GitHub (pinned to f5988cc097)

Solutions

  1. Use an angle between 1 and 90 degrees.

When it happens

Trigger: Thrown at physics/horizontal_projectile_motion.py:41 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14). Data as JSON: /api/errors/78b3b24d2f7c8f6f. Report an issue: GitHub.