Question: Write and test a function that meets the following requirements: def list_2d_find_less(values, n): ------------------------------------------------------- Finds the location of the first value in a 2D
Write and test a function that meets the following requirements:
def list_2d_find_less(values, n): """ ------------------------------------------------------- Finds the location of the first value in a 2D list of values that is smaller than a target value. ------------------------------------------------------- Preconditions: values - a 2D list of numbers (2D list) n - the target value (float) Postconditions: returns result - a list of of the row and column location of the the first value smaller than n in values, an empty list if there is no value smaller than n (list) ------------------------------------------------------- """
The function must return the result indicies in a list; i.e. the location [3][5] should be returned as [3, 5]. If there is no such number in the 2-D list, it should return an empty list.
Sample results (text in italics is user input):
Number of rows: 4 Number of columns: 3 Low value: -100 High value: 100 0 1 2 0 7.715 6.522 23.359 1 79.955 -4.858 -71.112 2 49.249 -17.001 22.338 3 98.593 -28.473 -92.926 Number to find: -60 Location: [1][2] Value: -71.112 Number to find: -101 Value <= -101.0 not found.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
