{"record":{"id":"90998791b425fe2a","repo":"TheAlgorithms/Python","slug":"mass-of-the-orbiting-object-must-be-greater-than-z","errorCode":null,"errorMessage":"Mass of the orbiting object must be greater than zero.","messagePattern":"Mass of the orbiting object must be greater than zero\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"physics/orbital_transfer_work.py","lineNumber":65,"sourceCode":"if __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n    print(\"Orbital transfer work calculator\\n\")\n\n    try:\n        M = float(input(\"Enter mass of central body (kg): \").strip())\n        if M <= 0:\n            r1 = float(input(\"Enter initial orbit radius (m): \").strip())\n        if r1 <= 0:\n            raise ValueError(\"Initial orbit radius must be greater than zero.\")\n\n        r2 = float(input(\"Enter final orbit radius (m): \").strip())\n        if r2 <= 0:\n            raise ValueError(\"Final orbit radius must be greater than zero.\")\n        m = float(input(\"Enter mass of orbiting object (kg): \").strip())\n        if m <= 0:\n            raise ValueError(\"Mass of the orbiting object must be greater than zero.\")\n        r1 = float(input(\"Enter initial orbit radius (m): \").strip())\n        r2 = float(input(\"Enter final orbit radius (m): \").strip())\n\n        result = orbital_transfer_work(M, m, r1, r2)\n        print(f\"Work done in orbital transfer: {result} Joules\")\n\n    except ValueError as e:\n        print(f\"Input error: {e}\")\n","sourceCodeStart":47,"sourceCodeEnd":74,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/physics/orbital_transfer_work.py#L47-L74","documentation":"Raised in the __main__ interactive block of physics/orbital_transfer_work.py when the orbiting object's mass entered at the prompt is <= 0. The function itself never checks mass_object, so this error exists only in the interactive path; it is caught locally and printed as 'Input error: ...'. The central mass M is never validated at all — the 'if M <= 0' branch misreads r1 instead of raising.","triggerScenarios":"Running the module directly and answering 'Enter mass of orbiting object (kg):' with 0 or a negative number, e.g. -1000 or 0.","commonSituations":"Entering mass in wrong units (0-heavy values like 0 for a satellite); testing the CLI with placeholder zeros; forgetting that the library function accepts any mass sign and only the CLI enforces positivity.","solutions":["Enter a strictly positive mass such as 1000 (kg)","If a zero mass is genuinely intended (test particle), call orbital_transfer_work() directly — the library function does not raise this error","When maintaining the script, add a proper 'if M <= 0' check for the central mass, which is currently missing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"m = float(input(\"Enter mass of orbiting object (kg): \").strip())\nif m <= 0:\n    raise ValueError(f\"Mass must be > 0, got {m}\")\n\n# library callers: this check exists only in the CLI, not in orbital_transfer_work()","typeGuard":null,"tryCatchPattern":"try:\n    result = orbital_transfer_work(M, m, r1, r2)\nexcept ValueError as e:\n    print(f\"Input error: {e}\")","preventionTips":["Enter a positive mass in kg at the prompt","For zero-mass test particles, call orbital_transfer_work() directly — it does not enforce this"],"tags":["physics","cli","user-input","valueerror","mass"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}