Question: Problem 3 - Speed comparisons (Please use Python to solve the following problem) We have new data for this problem, the data for 3 peoples
Problem 3 - Speed comparisons (Please use Python to solve the following problem)
We have new data for this problem, the data for 3 peoples distances from Cooper.
We also have a new question to answer:
How fast would each of them have to walk so that they reach Cooper in 10 minutes?
In Problem 2 our distance units were just based on the map.
Now well convert everything to real-life!
One side of one square of the campus map is about 800 feet,
were interested in speed measured in miles-per-hour.
The data input file contains one float per line,
Each representing someones distance to Cooper in map units.
Convert each of these distances into miles,
And then figure out how fast each person needs to walk (in MPH)
To reach Cooper in 10 minutes.
You can assume that:
One unit of distance is 800 feet.
(So if your distance to Cooper is 1.5, thats 1200 feet.)
1. There are 5280 feet in a mile
2. There are 60 minutes in an hour, and everyones goal is to reach Cooper in 10 minutes.
(e.g., if Im a mile away from Cooper, Id need to walk one mile in 10 minutes, equivalent to 6 miles per hour)
For full credit under documentation, include one test case in a block comment at the top of your file.
Once you have everything computed, create a scatterplot showing distance in feet (on the x axis) vs MPH (on the y axis).
For full credit under communication, your plot must have:
1. A title
2. Labels on the x and y axes
3. Reasonable x-limit and y-limit
Please also follow the Rubrics:
Gather data
Use input to prompt the user for Cooper x and y values, both ints
Open the file and save the name (string), x value (int), and y value (int) for Laney and Kayla
Computations
Compute Euclidean distance and time from Kayla to Cooper
Compute Euclidean distance and time from Laney to Cooper
Rounding is not done in computations
Communication
Use print to report distances (rounded to 3 digits past the decimal point)
Use print to report times (rounded to nearest minute)
Readability
File name is saved in a constant above main

Filename: race.py Input files: Download locations.txt and save it in the same directory as your race.py file. Cooper the dog is hanging out somewhere on campus. Laney wants to go and see him, and so does Kayla, but Cooper has time for only one adoring fan today :( So, Laney and Kayla want to find out how far away they are, and how long it will take each of them to reach him. The data files linked above contain Kayla's and Laney's locations. The file has 6 lines of data, three for each person that look like this: - Name, a string - x position, an int from 1-5 (based on the campus map grid) - y position, an int from 1-3 (based on the campus map grid) Read the file in and save each piece of data in its own variable. Additionally, ask the user where Cooper is (his x and y value). Use Euclidean Distance, a commonly-used data science measure, to compute how far apart Kayla and Laney are from Cooper. Given two points (x1,y1),(x2,y2), Euclidean distance is defined as: euclidean=(x2x1)2+(y2y1)2 You can compute the whole thing using Python's mathematical operators. A square root is the same as raising to the .5 power. Calculate four things: - Euclidean distance between the first person from the file and Cooper - Euclidean distance between the second person and Cooper - The time for the first person to reach Cooper (one unit of distance =10 minutes) - The time for the second person to reach Cooper (one unit of distance =10 minutes) For full documentation credit, write one test case, for one example, in a comment at the top of your file using the format shown below (but with your own example.) Do this before you start coding so you will know your program is correct! Test case: Laney's location: (2,2) Cooper's location: (3,3) Euclidean distance: (23) *ok 2+(23)2=2, then take the sqrt to get 1.414 Time to reach Cooper: 1.41410=14.14 minutes =14 minutes Finally, print out: - The name of each person from the file, their distance to cooper (rounded to three digits past the decimal point), and the time it takes to each him (rounded to the nearest minute)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
