Courses‎ > ‎Intro to CS - Full Year‎ > ‎Spring‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

### Work 14: 3/7

posted Mar 7, 2019, 10:18 AM by JonAlf Dyrland-Weaver
 Write the following functions in a single .py file`taxiFare`A taxi company charges it's users based on how many other people need taxis at the same time in the same area. If there are fewer that 5 people in the same area, then the company charges \$1.50 per mile.If there are more than 5 people in the same area, then the company charges \$2.50 per mile.Write a function that takes two parameters, the first represents the number of miles needed to go and the second represents the number of other customers nearby. The function should return the total cost of the trip.ExamplestaxiFare( 8, 3 ) ==> 12.0taxiFare( 8, 6 ) ==> 20.0onLineWill test whether a point is on a lineTakes 4 parameters, the first representing the slope of the line, the second representing the y-intercept on the line and the last 2 representing the coordinates of the point to test. (remember y=mx + b)Returns True if the point is on the line, False otherwisecloserPointTakes 6 parameters, each pair of parameters represents the (x, y) coordinates of a point on the cartesian plane.Returns 1 if the first point is closer to the third than the second is to the third.Returns 2 if the second point is closer to the third than the first is to the third.Use the distance formula to determine closeness:d = (sqrt (x3 - x1)2 + (y3 - y1)2 )where the 2 points are (x1, y1) and (x3, y3)ExamplesAssume the parameters are (x1, y1, x2, y2, x3, y3)closerPoint( 4, 0, 10, 0, 0, 0) ==> 1 (4, 0) is closer to (0, 0)closerPoint( 9, 0, 0, -3, 0, 0) ==> 2 (0, -3) is closer to (0, 0)Note: This would be easier if you had a function to tell you the distance between two points...factorialTakes a single nonnegative integer as a parameter and returns that number factorial.Your solution must use a while loopexamples:factorial(5) ==> 120factorial(0) ==> 1submit this as test2_review