top of page
Search

A python program that computes and displays the distance between two points

  • Writer: Nelson John
    Nelson John
  • Nov 27, 2017
  • 1 min read

Hello all. This is a simple python program that will compute and display the distance between two points.

  1. We have to get the user input first and second point with two float values

  2. Compute the distance

  3. Display the result of the program.

# prompt user to enter first point with two float values

x1, y1 = eval(input("enter x1 and y1 for point 1: "))

# prompt user to enter second point with two float values

x2, y2 = eval(input("enter x2 and y2 for point 2: "))

# compute the distance

distance = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

# Display result

print("the distance between the two points is", distance)

Facebook: ayamnelrodinho1@gmail.com

Yahoo: talk2nelsonjohn2dat@yahoo.com

Whatsapp: +2349034595610

PLEASE KINDLY SHARE WITH FELLOW PROGRAMMERS AND ALSO SUBSCRIBE TO MY BLOG PAGE FOR MORE FEEDS.


 
 
 

Comments


bottom of page