Question

# In Python Compose a function that takes an array of strictly positive floats as its parameter...

In Python

Compose a function that takes an array of strictly positive floats as its parameter and rescales the array so that each element is between 0.0 and 1.0 by subtracting the minimum value from each element and then dividing each element by the difference between the minimum and maximum values in the array. The first constraint in this assignment is that you must use a list comprehension to implement the function. To test your function, have your program call the function passing the array:

[10.0, 10.25, 10.5, 10.75, ... 19.25, 19.5, 19.75, 20.0]

And simply output the rescaled array as a single line in CSV format. The 2nd constraint is that you can’t manually enter the input array in your code (hint: does numpy have something similar to the range function for floats?)

``````import numpy as np
a = np.arange(10.0, 20.25, 0.25)
min_a = min(a)
max_a = max(a)
a = [x - min_a for x in a]
a = [x/(max_a-min_a) for x in a]
for i in a:
print(i, end=" ")``````

#### Earn Coins

Coins can be redeemed for fabulous gifts.

##### Need Online Homework Help?

Most questions answered within 1 hours.