Question: Intro to Computer Science 1 using Python complete the following exercise: 1. Rewrite the distance() function from the Fruitful Functions chapter. so that it takes
Intro to Computer Science 1 using Python complete the following exercise:
1. Rewrite the distance() function from the Fruitful Functions chapter. so that it takes two Points as parameters instead of four numbers. def distance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx*dx + dy*dy result = dsquared**0.5 return result
Convert the distance function into a method of Point which accepts a point Add a method reflect_x to Point which returns a new Point, one which is the reflection of the point about the x-axis. For example, Point(3, 5).reflect_x() is (3, -5)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
