In [163]:
# Use the numpy library
import numpy as np

In [164]:
def prepare_inputs(inputs):
    # TODO: create a 2-dimensional ndarray from the given 1-dimensional list;
    #       assign it to input_array
    
    input_array = np.array([inputs])
    
    # TODO: find the minimum value in input_array and subtract that
    #       value from all the elements of input_array. Store the
    #       result in inputs_minus_min
    inputs_minus_min = input_array - np.min(input_array)

    # TODO: find the maximum value in inputs_minus_min and divide
    #       all of the values in inputs_minus_min by the maximum value.
    #       Store the results in inputs_div_max.
    inputs_div_max = inputs_minus_min / np.max(inputs_minus_min)

    # return the three arrays we've created
    return input_array, inputs_minus_min, inputs_div_max

In [165]:
def multiply_inputs(m1, m2):   
    if m1.shape[1] == m2.shape[0]:
        return np.matmul(m1,m2)
    elif m1.shape[0] == m2.shape[1]:
        return np.matmul(m2,m1)
    else:
        return False

In [166]:
def find_mean(values):
    # TODO: Return the average of the values in the given Python list
    return np.mean(values)

In [167]:
input_array, inputs_minus_min, inputs_div_max = prepare_inputs([-1,2,7])

In [168]:
print("Input as Array: {}".format(input_array))


Input as Array: [[-1  2  7]]

In [169]:
print("Input minus min: {}".format(inputs_minus_min))


Input minus min: [[0 3 8]]

In [170]:
print("Input  Array: {}".format(inputs_div_max))


Input  Array: [[0 0 1]]

In [171]:
print("Multiply 1:\n{}".format(multiply_inputs(np.array([[1,2,3],[4,5,6]]), np.array([[1],[2],[3],[4]]))))


Multiply 1:
False

In [172]:
print("Multiply 2:\n{}".format(multiply_inputs(np.array([[1,2,3],[4,5,6]]), np.array([[1],[2],[3]]))))


Multiply 2:
[[14]
 [32]]

In [173]:
print("Multiply 3:\n{}".format(multiply_inputs(np.array([[1,2,3],[4,5,6]]), np.array([[1,2]]))))


Multiply 3:
[[ 9 12 15]]

In [174]:
print("Mean == {}".format(find_mean([1,3,4])))


Mean == 2.66666666667