analyseData

This is the task I am having troubles withWrite a function called analyseData() that takes two parameters:
• A single mandatory positional argument: a list containing integer numbers.
• A single optional keyword argument isPositive that can take the value
True or False.
The function should calculate the average of all the numbers in the list of integers and return that average as a number that can then be displayed on the screen subject to the following rules:
• If isPositive is set to True, then only positive numbers in the list should be used in the calculation.
• If isPositive is set to False, then all numbers in the list should be used in the calculation.
• If isPositive is not specified, then its default value should be False.
• If the list parameter is empty i.e. [ ] , the returned value should be 0.
So, for example:
• A call analyseData([1,2,3,4,5], isPositive=True) should return the value 3.
• A call analyseData([1,2,3,4,5]) should return the value 3.
• A call analyseData([10,20,-30,45], isPositive=True) should
return the value 25.
• A call analyseData([10,20,-30,45], isPositive=False) should
return the value 11.25.
• A call analyseData([10,20,-30,45]) should return the value 11.25.

×
New Download