def get_best_value(data, index, maximum=True)

def get_best_value(data, index, maximum=True):


Returns the ‘best’ value from a given column in a 2-dimensional nested list.

This function is a helper function for get_minimums (whose docstring you should

read and understand first).

The data parameter is a 2-dimensional nested list of data. The index parameter

indicates which “colummn” of data should be evaluated. Each item in that column

is expected to be a number in string format. Each item should be evaluated as a

float and the best value selected as the return value for the function. The

best value is determined by the maximum parameter and is either the highest or

lowest float value.

The 2D list does not include a header row. It should not be modified in any way.

Parameter data: a 2-dimensional nested list of data

Precondition: the column referenced by index should by numbers in string format

Parameter index: position to examine in each row of data

Precondition: index is a an integer

Parameter maximum: indicates whether to return the highest value (True) or

lowest value (False)

Precondition: maximum is a boolean and defaults to True


# Find the best values for each column of the row


def test_get_best_value():


Tests the function pilots.get_best_value


fcn = ‘pilots.get_best_value’

# Test the minimums table

parent = os.path.split(__file__)[0]

fpath = os.path.join(parent,’minimums.csv’)

table = utils.read_csv(fpath)[1:]


# Expected answers for each of the indicated columns

tests = { 4: (500.0, 5000.0),

5: (0.75, 10.0),

6: (20.0, 30.0),

7: (8.0, 20.0) }

# Check for both True (highest) and False (lowest)

situations = ( (False, 0, ‘lowest’),

(True, 1, ‘highest’) )


for col, bests in tests.items():

for situ in situations:

best = pilots.get_best_value(table, col, situ[0])

data = (fcn, repr(best), situ[2], col, bests[situ[1]])

assert_floats_equal(bests[situ[1]], best,

‘%s returned %s as %s value for column position %s in minimums.csv, but should have returned %s’ % data)

print(‘ %s passed all tests’ % fcn)

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?