Reference no: EM132185923
Define a function named numSinRange(..) which receives as parameter a list (which may be empty) of positive integer numbers (lnum) and returns one list (lres).
The numbers in lnum may be between 1 and 99 (in any order), there may be repeated numbers.
The function should count how many numbers in lnum fall within each of the ranges 0<x<=10, 10<x<=20, 20<x<=30, ... 80<x<=90, 90<x< 100 (there are 10 possible ranges)
lres should represent such result as follows:
For example, if
lnum = [2,5,15,17,76,88,1,89,3]
then lres should be [4,2,0,0,0,0,0,1,2,0]
Other examples:
if lnum = [7]
then lres should be [1,0,0,0,0,0,0,0,0,0]
if lnum = [7,10]
then lres should be [2,0,0,0,0,0,0,0,0,0]
if lnum = [99]
then lres should be [0,0,0,0,0,0,0,0,0,1]
As an example, the following code fragment:
lnum = [2,5,15,17,76,88,1,89,3]
print(numSinRange(lnum))
should produce the output:
[4, 2, 0, 0, 0, 0, 0, 1, 2, 0]
language: python