Assign point_dist with the distance between point (x1, y1) and point (x2, y2). The calculation is: Distance = SquareRootOf( (x2 - x1)2 + (y2 - y1)2 ).

Sample output with inputs: 1.0 2.0 1.0 5.0

Points distance: 3.0
import math
point_dist = 0.0
x1 = float(input())
y1 = float(input())
x2 = float(input())
y2 = float(input())

Respuesta :

Following are the complete code to the given question:

Program:

import math as mx #import package  

def point_dist (x1,y1,x2,y2):#defining a method point_dist that accepts four parameters

    x= (float(x2)-float(x1))**2#defining x variable that calculates the x value

    y= (float(y2)-float(y1))**2#defining y variable that calculates the y value

    return(mx.sqrt(float(x)+float(y)))#useing return type that calculates SquareRootOf of x and y

x1 = float(input())#input x1 value

y1 = float(input())#input y1 value

x2 = float(input())#input x2 value

y2 = float(input())#input y2 value

print('Points distance: ',point_dist(x1,y1,x2,y2))#calling method

Output:

Please find the attachment file.

Program Explanation:

  • Import package.
  • Defining a method point_dist that accepts four parameters "x1,y1,x2,and y2".
  • Inside the method "x and y" variable is declared that calculates its sum and store its value into its respective variable.
  • In the next step, a return keyword is used that calculates and returns SquareRootOf of x and y.
  • Outside the method, the parameter variable has been used that input the value and pass into the method that prints its calculated value.

Learn more:

https://brainly.com/question/6548083

Ver imagen codiepienagoya