Page 1 of 1

2. Question (5 pt.): We have a list variable 'n' which has integer numbers. For each number in the list, find the number

Posted: Sat Feb 19, 2022 3:21 pm
by answerhappygod
2 Question 5 Pt We Have A List Variable N Which Has Integer Numbers For Each Number In The List Find The Number 1
2 Question 5 Pt We Have A List Variable N Which Has Integer Numbers For Each Number In The List Find The Number 1 (35.84 KiB) Viewed 47 times
2. Question (5 pt.): We have a list variable 'n' which has integer numbers. For each number in the list, find the number of smaller numbers in the preceding positions, i.e. if the index of the current elements is i, then preceding elements should have an index less than i. Create the function, i.e., fun_2, to return a list containing for each number in the input list a number of smaller elements in the preceding positions. arg1 = [ 1, 5, 2, 10, 3, 4] output = fun_2(arg1) print(output) [ 0, 1, 1, 3, 2, 3] >>> arg2 = [ 1, 2, 3, 4 ] >>> output = fun_2(arg2) >>>print(output) >>>[0, 1, 2, 3]