ReportStatistics

ThereportStatistics () function callr all of the fUnctiofrjust described asd stores iceri retumnalues in two dictionaries, averages and ranges. It tPen places these dictionaries in another dictionary called report, which it returns.

def reportStatistics (nums):

# get central tendencies averages = {

"mean":getMean(nums,0), "median":getMedian(nums),

"mode":getMode(nums) }

# get range range = getRange(nums)

# put ranges in a dictionary ranges = {

"min": range [0], "max": range [1],

"averages": averages,

"ranges": ranges }

return report

Notice that Python, unlike Java, has a built-in syntax that allows you to specify a dictionary (which is similar to a Java hashtable) with a literal.

Was this article helpful?

0 0

Post a comment