Question: Problem 2 - Race to Cooper Cooper the dog is hanging out somewhere on campus. Laney wants to go and see him, and so does

Problem 2 - Race to Cooper

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 Kaylas and Laneys 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 =(x2-x1)2+(y2-y1)2

You can compute the whole thing using Pythons 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!

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)

Please 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

Problem 2 - Race to Cooper Cooper the dog is hanging out

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)2+(23) * 22=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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!