Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

Write a short note on the art of persuasion. Section C

Answered: 1 week ago

Question

What are the functions of top management?

Answered: 1 week ago

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago