This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Rodrigo Paes - rodrigo@ic.ufal.br' | |
import unittest | |
from statistics_faulty import stats | |
class MyTestCase(unittest.TestCase): | |
def test_stats(self): | |
l = [31] | |
my_map = stats(l) | |
self.assertEqual(31,my_map["min"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stats(lst): | |
_min = None | |
_max = None | |
freq = {} | |
for i in lst: | |
i = abs(i) | |
if _min is None or i < _min: | |
_min = i | |
if _max is None or i > _max: | |
_max = i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stats(lst): | |
_min = None | |
_max = None | |
freq = {} | |
for i in lst: | |
if _min is None or i < _min: | |
_min = i | |
if _max is None or i > _max: | |
_max = i | |
if i in freq: |