TheAlgorithms/Python · error · ValueError

The radius is always a positive non zero integer

Error message

The radius is always a positive non zero integer

What it means

Error "The radius is always a positive non zero integer" thrown in TheAlgorithms/Python.

Source

Thrown at physics/centripetal_force.py:42

def centripetal(mass: float, velocity: float, radius: float) -> float:
    """
    The Centripetal Force formula is given as: (m*v*v)/r

    >>> round(centripetal(15.5,-30,10),2)
    1395.0
    >>> round(centripetal(10,15,5),2)
    450.0
    >>> round(centripetal(20,-50,15),2)
    3333.33
    >>> round(centripetal(12.25,40,25),2)
    784.0
    >>> round(centripetal(50,100,50),2)
    10000.0
    """
    if mass < 0:
        raise ValueError("The mass of the body cannot be negative")
    if radius <= 0:
        raise ValueError("The radius is always a positive non zero integer")
    return (mass * (velocity) ** 2) / radius


if __name__ == "__main__":
    import doctest

    doctest.testmod(verbose=True)

View on GitHub (pinned to f5988cc097)

Solutions

  1. Pass a positive non-zero radius.

When it happens

Trigger: Thrown at physics/centripetal_force.py:42 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/8a4bb06c6c6cef61. Report an issue: GitHub.