Average Mask¶
Implement the following Python function in the module mask_avg (file mask_avg.py):
mask_avg(L, Lmask)
such that
given
L,Lmasklists offloatwith same length.modifies
Lby replacing every value by the average of this value and the value placed in the same position inLmask. The new value must be rounded to 1 decimal.
For example:
>>> l = [1.0, 3.0, 2.5, 6.2, 4.8, 8.1]
>>> lmasc = [0.0, 0.2, 0.4, 0.3, 0.5, 0.1]
>>> mask_avg(l, lmasc)
>>> l
[0.5, 1.6, 1.4, 3.2, 2.6, 4.1]
>>> l = [1.0, 3.0, 2.5, 6.2, 4.8, 8.1]
>>> lmasc = [-1.0, -3.0, -2.5, -6.2, -4.8, -8.1]
>>> mask_avg(l, lmasc)
>>> l
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
Doctests are available at the mask_avg-test.txt file.