I am trying to calculate the radius of a circle using 2 points given by the user.
The program works with a simple single integer entry like this ...
x1 = int(input("enter x1"))
y1 = int(input("enter y1"))
But I wanted to write the input in a way that allows the user to enter a point like this...
2,5
Below is the code for the program, it will accept the user
input of x1,y1 and x2,y2, but the calculations are coming out as 0.0.
What am I missing?
import math
def distance (x1,y1,x2,y2):
dis = math.sqrt((x2-x1)**2 + (y2-y1)**2)
return distance
def radius (x1,y1,x2,y2):
rad = distance(x1,y1,x2,y2)
return rad
def main():
coordinate_1 = input("enter x1 and y1")
coordinate_1 = coordinate_1.split(",")
x1 = int(coordinate_1[0])
y1 = int(coordinate_1[1])
coordinate_2 = input("enter x2 and y2")
coordinate_2 = coordinate_2.split(",")
x2 = int(coordinate_1[0])
y2 = int(coordinate_1[1])
rad = radius(x1,y1,x2,y2)
print("the radius is:", rad)
main()