{"slug":"pythagorean","tier":1,"subject":"geometry","title":"Pythagorean","description":"Right triangle: find missing side.","files":[{"filename":"PYTHAG.py","content":"def p(s):print(s)\ndef o1():\n p(\"=FIND C=\")\n a=float(input(\"a:\"))\n b=float(input(\"b:\"))\n c=(a*a+b*b)**0.5\n p(\"c=\"+str(c))\ndef o2():\n p(\"=FIND A=\")\n a=float(input(\"a:\"))\n c=float(input(\"c:\"))\n b=(c*c-a*a)**0.5\n p(\"b=\"+str(b))\ndef menu():\n while True:\n  p(\"=PYTHAG=\")\n  p(\"1:FIND C\")\n  p(\"2:FIND A\")\n  p(\"0:EXIT\")\n  c=input(\"?>\")\n  if c==\"1\":o1()\n  elif c==\"2\":o2()\n  elif c==\"0\":break\nmenu()"}],"testCases":[{"id":"3-4-to-5","inputs":["1","3","4","0"],"expectedContains":["c=5.0"]},{"id":"5-13-to-12","inputs":["2","5","13","0"],"expectedContains":["b=12.0"]}],"usage":"Right-triangle solver. Pick your direction first:\n\n- `1:FIND C` — you know both legs, want the hypotenuse. Prompts `a:` and `b:`, returns `c=√(a²+b²)`.\n- `2:FIND A` — you know one leg and the hypotenuse, want the other leg. Prompts `a:` (the known leg) and `c:` (hypotenuse), returns `b=√(c²−a²)`.\n- `0:EXIT` — leave.\n\nIf `a > c` on option 2, you'll see a math error — re-check which side is the hypotenuse.","example":{"problem":"A ladder leans against a wall. The foot is 5 ft from the wall and the ladder is 13 ft long. How high up the wall does it reach?","walkthrough":"Hypotenuse is the ladder (c=13); one leg is the distance from the wall (a=5); we want the other leg (height up the wall).\n\n1. Run `PYTHAG`, choose `2:FIND A`.\n2. `a:` → **5**, `c:` → **13**.\n3. Output: `b=12.0`.\n\nThe ladder reaches 12 ft up the wall. Verify: 5² + 12² = 25 + 144 = 169 = 13². ✓"}}