{"slug":"distance-2d","tier":1,"subject":"geometry","title":"Distance 2D","description":"Distance between two points in 2D.","files":[{"filename":"DIST2D.py","content":"def p(s):print(s)\ndef o1():\n p(\"=DIST=\")\n a=float(input(\"x1:\"))\n b=float(input(\"y1:\"))\n c=float(input(\"x2:\"))\n e=float(input(\"y2:\"))\n d=((c-a)**2+(e-b)**2)**0.5\n p(\"d=\"+str(d))\ndef menu():\n while True:\n  p(\"=DIST 2D=\")\n  p(\"1:DIST\")\n  p(\"0:EXIT\")\n  c=input(\"?>\")\n  if c==\"1\":o1()\n  elif c==\"0\":break\nmenu()"}],"testCases":[{"id":"origin-to-3-4","inputs":["1","0","0","3","4","0"],"expectedContains":["d=5.0"]},{"id":"1-2-to-4-6","inputs":["1","1","2","4","6","0"],"expectedContains":["d=5.0"]}],"usage":"Launch `DIST2D` from `prgm`, choose `1:DIST`, then enter the four coordinates in this order:\n\n1. `x1:` x of the first point.\n2. `y1:` y of the first point.\n3. `x2:` x of the second point.\n4. `y2:` y of the second point.\n\nOutput is `d=` with the Euclidean distance. Press `0` at the main menu to exit.","example":{"problem":"Find the distance between (1, 2) and (4, 6).","walkthrough":"1. Run `DIST2D`, choose `1:DIST`.\n2. `x1:` → **1**, `y1:` → **2**, `x2:` → **4**, `y2:` → **6**.\n3. Output: `d=5.0`.\n\nVerify with the distance formula: √((4−1)² + (6−2)²) = √(9+16) = √25 = 5. ✓"}}