Question: Pyhton In this lab you're going to create a program that calculates the distance and the midpoint for two given points in the plane. The

In this lab you're going to create a program that calculates the distance and the midpoint for two given points in the plane. The user will enter the r and y coordinates of two given points and then you will return the distance between those points and the midpoint on the line segment between those points. I want you to write this program using functions. You should have three functions as follows: 1. getUserInput - this function should take no parameters but prompt the user to enter the and y coordinate of one point and it should return both of those values. You will call this function twice from the main program. 2. findEuclideanDistance - this function should take four parameters, namely, the x and y coordinate of two different points and it should return a single value that is the distance between those two points. Recall that the formula for the Euclidean distance between two points in the plane is: euclideanDist = V(21 12)2 + (y1 - y2)2 3. findMidpoint - this function should take four parameters, namely, the x and y coordinate of two different points. Then it should return two values, namely, the x and y coordinate of the midpoint between the two given points. Recall, to calculate the midpoint of two points you just average the two values. Specifically: Imid = (x1+x2)/2 and Ymid = (y2 + y2)/2 Note that when you return two values from a function you should assign the result of the function to two variables in the main part of the program. For example, I would call findMidpoint from the main as follows: xmid, ymid = findMidpoint (x1, y1,x2,y2) Returning multiple values from a function is done in hw2 repeatedly. Sample Output Enter data for first point x coordinate: 2 y coordinate: 7 Enter data for second point x coordinate: 6 y coordinate: 12 The Euclidean distance between these points is 6.403 The midpoint of these two points is ( 4.0. 9.5 ) Style and Clarity The main program for this assignment should call the three functions and produce the output as shown in the sample output above. Be sure to use descriptive variable names in your main program. The idea is that your main should first call getUser Input twice, once for each point. Then it should call the other two functions one after the other, each time saving the results in variables and eventually printing them out to the screen. You should comment the functions as you've seen me do in class examples. Specifically, you should explain what the input parameters are and how they're tused. Be sure to denote if you're making any assumptions about their values when they come into the function. The comments on functions should also provide a high level description of what the function returns. Grading Rubric . Correct getUser Input function (1 point) Correct findEuclideanDistance function (1 point) Correct findMidpoint function (1 point) Use of descriptive variable names throughout (1 point) Clear and descriptive comments throughout (1 point) Submission Guidelines You should submit one program named lastname_firstname_lab5.py Congratulations, you have completed Lab 5. You are welcome to work on hw2 during the rest of the lab period
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
