Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this activity is to practice writing simple programs that require multiple variables, and to ensure you understand the idea of interpolation. The

The purpose of this activity is to practice writing simple programs that require multiple variables, and to ensure you understand the idea of interpolation. The individual assignment will build on this program.

Write a short program in Python that performs linear interpolation. Here is the scenario:

You arrive at a racetrack and observe a car moving around a track at what appears to be a constant speed. You would like to be able to predict where the car is at any point in time. To do this, you take a measurement of how far around the track the vehicle has traveled at two points in time. Assume that the track is marked so that you can determine position very precisely. You note the time of this first position measurement. A short while later (before the vehicle has passed the starting point on the track), you take a second measurement for how far around the track the vehicle has traveled, again noting the time.

Now, assume that youd like to reconstruct the position of the vehicle at any time between the first measurement and the second. Since you assume the vehicle is moving at constant speed, this calculation can be found precisely by linear interpolation.

As a team, determine what variables you will need to use, and what formula(s) you will need to use to perform this calculation. You should use variables for all of the values that could change.

Now, assume that for your observation, the first measurement was taken 30 seconds after you arrived, and the second was taken 45 seconds after you arrived. At the first measurement, the car was 50 meters past the starting line of the track. At the second measurement, the car was 615 meters past the starting line of the track.

Write a program that determines, for any time between 30 and 45 seconds, where the car will be on the track (in terms of meters past the starting line). The time to evaluate at should be a variable in your program. The program should print both the time and the position at that time to the screen, with a line describing what is being output. You should test your program at various times and make sure the results seem reasonable.

For your final program that you turn in, you can assume that you want to know the position at a time 37 seconds after you first arrived. (Next week, we will see how you can read in numbers from a user, but for now, just assume it is a fixed number of seconds.)

Assume the racetrack is circular with radius 0.5 kilometers. Notice that every time the car passes the starting point of the track, its distance from the starting point gets reset to 0. So, if you go far into the future, say at a point 20 minutes after your arrival time, simple linear interpolation will not work. See if you can modify your code to report distances correctly regardless of the time.

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 Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

We are doing better in both overall sales and in profits.

Answered: 1 week ago

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago

Question

=+j Describe an effective crisis management program.

Answered: 1 week ago