Question: Using Python 2.7 or higher, (no dictionaries or built in min or max functions; use basic if and while loops only) 4. Implement function, q4(L,
4. Implement function, 4(L, goalX, goaly), that takes a non-empty list, L, of [x,y) pairs, and two goal numbers, and returns tuple (closestXY, Xory) where closestXY is the item from L whose x distance from goal X or whose y distance from goal is the minimum among all distances, and Xory is 'x' if x distance is minimized and 'y' otherwise. You may assume there is a unique answer. Note: You may not use built-in min or max functions. Examples: 94 ([[4, 4], [10, 10]], 1, 8) should return ([10,10), 'y') 94([[10, 25], [2, 2], [49, 200]], 50, 8) should return ([ 49,200), 'x') 5. Implement function q5(L) that takes as input a (possibly empty) list of (possibly empty) lists of numbers and returns a three-element list. The first element is a list of the sums of corresponding lists in L, the second element is the number of lists in L that contain more positive than negative values, and the third element in the minimum value among all items in all lists (or None if there is no minimum). Note: you may NOT use Python's 'sum' or 'min' function instead,compute sums and min within a loop or loops.) For example, >>> 95([[1, 2, 2], [3]]) [[5, 3), 2, 1] >>> 05([[0, 1, 0], U, 1-1, 100]]) [[1, 0, 99], 1, -1]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
