Assume there are two cars, one following the other, on a one lane road (i.e. no passing). The one in front cannot hold a constant speed, the driver keeps speeding up and slowing down. Specifically, every 20 seconds he hits the accelerator and 20 seconds later the brake.
· Write a Python function which, given a time in seconds, returns whether the brake is being pressed or the accelerator. If the former, return a -1; if the latter, a +1. To check you are doing it right, make a graph of what your function returns for times from 0 to 100 seconds.
Assume that the car in back is trying to keep a constant distance of 50 feet from the car in front. Every time the separation gets greater than 60 feet that driver presses the accelerator and the brake whenever the separation is less than 40.
· Write a Python function which, given a separation in feet also returns a +1 or -1 depending if the accelerator or brake, respectively is being pressed. Check it by making a graph of what your function returns for separations from 20 to 70 feet.