Question: python list and function Write the functions smart1(zj)respectively smart2(z, j) that both receive a list z with numbers and a non-negative integer j. The functions
python list and function

Write the functions smart1(zj)respectively smart2(z, j) that both receive a list z with numbers and a non-negative integer j. The functions must create and return a new list y there yi = (z i-j + z i-j-1 + z i-j-2 + ... + z i-1 + zi + zi+ 1 + ... + zi + n-1 + zi +j)/(2*j + 1) i.e. the mean of z i and the 2j surrounding numbers. If j = 1, the result will be as in the exercise above, at least in the inner points. The difference between the two functions is how the points that are close to the edges are handled, ie when the interval [ in: i + ] is outside the list. Two different strategies must be implemented: smart1 (z, j): The same width ( 21 + 1) on the equalization operator shall be used, but in the points that receive an index less than 0, the first value shall be used and in points that receive an index after the last element, the last element shall be used. It can be seen that the list is expanded both upwards and downwards with j elements that are set equal to the stripe element. smart2(z,j): Only points that are in the array should be used so that the mean value is then formed over fewer points Example: the code z = [1, 2, 6, 4, 5, 0, 1, 2] print ('smart1(2, 1):", smart1 (z, 1)) print ("smart1 (z, 2):", smart1 (z, 2)) print ('smart2(3, 1):", smart2(z, 1)) print ('smart2 (z, 2):', smart2(z, 2)) Loutput should be like this: smart1 (z, 1): (1.3333333333333333, 3.0, 4.0, 5.0, 3.0, 2.0, 1.0, 1.666666666666666667] smart1 (z ,2): [2.2, 2.8, 3.6, 3.4, 3.2, 2.4, 2.0, 1.4] smart2( z, 1): [1.5, 3.0, 4.0, 5.0, 3.0, 2.0, 1.0, 1.5] smart2(z, 2): [3.0, 3.25, 3.6, 3.4, 3.2, 2.4, 2.0, 1.0) Try to use list and list methods as much as you can
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
