Write a Python program to calculate the midpoints of a line.

Write a Python program to calculate the midpoints of a line.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
print('\nCalculate the midpoint of a line :')

x1 = float(input('The value of x (the first endpoint) '))
y1 = float(input('The value of y (the first endpoint) '))

x2 = float(input('The value of x (the first endpoint) '))
y2 = float(input('The value of y (the first endpoint) '))

x_m_point = (x1 + x2)/2
y_m_point = (y1 + y2)/2
print();
print("The midpoint of line is :")
print( "The midpoint's x value is: ",x_m_point)
print( "The midpoint's y value is: ",y_m_point)
print();

Final output

Leave a Comment