# Python Example – Write a program to compute the radius and the central coordinate (x, y) of a circle # (Python Example for Citizen Data Scientist & Business Analyst)

Write a program to compute the radius and the central coordinate (x, y) of a circle which is constructed by three given points on the plane surface.

Input:
x1, y1, x2, y2, x3, y3 separated by a single space.

Sample Solution:

Python Code:

``````print("Input three coordinate of the circle:")
x1, y1, x2, y2, x3, y3 = map(float, input().split())
c = (x1-x2)**2 + (y1-y2)**2
a = (x2-x3)**2 + (y2-y3)**2
b = (x3-x1)**2 + (y3-y1)**2
s = 2*(a*b + b*c + c*a) - (a*a + b*b + c*c)
px = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3) / s
py = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3) / s
ar = a**0.5
br = b**0.5
cr = c**0.5
r = ar*br*cr / ((ar+br+cr)*(-ar+br+cr)*(ar-br+cr)*(ar+br-cr))**0.5
print("{:>.3f}".format(r))
print("Central coordinate (x, y) of the circle:")
print("{:>.3f}".format(px),"{:>.3f}".format(py))
``````

Sample Output:

```Input three coordinate of the circle:
9 3 6 8 3 6
3.358
Central coordinate (x, y) of the circle:
6.071 4.643```

## Write a program to compute the radius and the central coordinate (x, y) of a circle

#### Free Machine Learning & Data Science Coding Tutorials in Python & R for Beginners. Subscribe @ Western Australian Center for Applied Machine Learning & Data Science. ```