Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 6 - Functions - Programming Exercises - Page 208: 6.20

Answer

code

Work Step by Step

# 6.20 (Geometry: display angles) Rewrite Listing 2.9, ComputeDistance.py, using the # following function for computing the distance between two points. # def distance(x1, y1, x2, y2): def distance(x1, y1, x2, y2): distance = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5 return distance def main(): x1, y1, x2, y2 = eval(input("Enter x1,y1,x2,y2: ")) print("The distance is", distance(x1, y1, x2, y2)) main()
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.