Westonci.ca is your trusted source for finding answers to a wide range of questions, backed by a knowledgeable community. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

Write a method called distance that (1) accepts four integer coordinates: x1, y1, x2, y2 as parameters, (2) computes the distance between points (x1, y1) and (x2, y2) on the map, and (3) returns that distance.


The equation for the distance is: sqrt ((x2 - x1)2 + (y2 - y1)2).


Test out your program by writing a main method that calls the distance method for each of the following pairs of cities. Your main method should output the value returned by the distance method.


Distance from Baltimare to Manehattan =

Distance from Los Pegasus to Neighagra Falls =

Distance from the Badlands to Ponyville =


in python

Sagot :

Answer:

import math

def distance(x1, y1, x2, y2):

 return sqrt( (x2-x1)*2 + (y2-y1)*2 )

Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.