Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING PYTHON def normalize(list): after u define the function, u need to add thi

ID: 3567156 • Letter: U

Question

USING PYTHON

def normalize(list):

after u define the function, u need to add this test part:
a =[1, -2, 4, 5, 20,33]
print a
print normalizt(a)

Write a function to normalize a given list of numbers. The inut is a list of real values; the return value is a list of normalized values. The normalization is done by: X_{i}= frac{X_{i}-minx}{maxx-minx} where Xi is the ith element of the input. def normalize(list): after u define the function, u need to add this test part: a =[1, -2, 4, 5, 20,33] print a print normalizt(a)

Explanation / Answer

#!/usr/bin/env python

def normalize(myList):
    minx = min(myList)
    maxx = max(myList)
    print minx,maxx
    for index, element in enumerate(myList):
        myList[index] = (( element - minx ) / float(maxx - minx ) )
    return myList  

# test part  
a =[1, -2, 4, 5, 20,33]
print a
print normalize(a)