Esempio n. 1
0
def majors_analysis(majorsli):
    ''' (list) -> str
    Find and return the mode of a list of majors
    >>> majors_analysis(['CIS', 'CIS', 'EC', 'GSS', 'PBA', 'PS', 'SDSC'])
    'CIS'
    >>> majors_analysis(['CIS', 'CIS', 'CIS', 'CIS', 'EC', 'GSS', 'J', 'J', 'J', 'J', 'PBA', 'PS', 'SDSC', 'UNDL', 'UNDL', 'UNDL', 'UNDL'])
    'CIS, J, UNDL'
    >>> majors_analysis(['ACTG', 'ATCH', 'ATCH', 'BI', 'BI', 'BI', 'BI', 'CEP', 'CEP', 'CH', 'CH', 'CH', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'CIS', 'EC', 'EC', 'EC', 'EC', 'EC', 'EC', 'ERTH', 'GEOG', 'GEOG', 'GS', 'GSS', 'GSS', 'HPHY', 'J', 'MACS', 'MACS', 'MACS', 'MACS', 'MACS', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MATH', 'MUS', 'MUS', 'PBA', 'PBA', 'PBA', 'PBA', 'PBA', 'PBA', 'PBA', 'PDS', 'PEN', 'PEN', 'PEN', 'PHYS', 'PHYS', 'PHYS', 'PHYS', 'PHYS', 'PS', 'PS', 'PS', 'PSY', 'PSY', 'SDSC', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL', 'UNDL'])
    'CIS'
    '''
    mode_list = p62.mode(majorsli)

    #Present mode as a string and not list:
    if len(
            mode_list
    ) > 1:  #When the mode is more than one major add commas between majors
        majors_mode = ''
        for item in mode_list:
            majors_mode += item
            if item != mode_list[-1]:
                majors_mode += ', '
    else:
        majors_mode = mode_list[0]

    return majors_mode
Esempio n. 2
0
def majors_analysis(majorsli):
    '''
    (list) -> tuple

    Determines the most frequently occuring
    major(s) (mode) in a list of majors, and
    also the count of the number of distinct
    majors in the list.

    >>> majors_analysis(['CIS', 'CIS', 'EXPL', 'COLT', 'EXPL'])
    (['CIS', 'EXPL'], 3)

    >>> majors_analysis(['CIS', 'EXPL', 'COLT'])
    (['CIS', 'EXPL', 'COLT'], 3)

    >>> majors_analysis(['CIS', 'CIS', 'EXPL', 'COLT'])
    (['CIS'], 3)
    '''

    majors_mode = p62.mode(majorsli)

    countdict = p62.genFrequencyTable(majorsli)
    majors_ct = len(countdict)

    return majors_mode, majors_ct
Esempio n. 3
0
def equake_analysis(magnitudes):
    '''(list) -> tuple

    Function equake_analysis takes a list of earthquakes and returns the mean,
    median, and mode of the data in a tuple.

    >>> equake_analysis([5.2, 5.1, 6.0, 5.9, 5.6, 5.7, 5.0, 5.0, 5.2, 5.1, 5.4])
    (5.381818181818183, 5.2, [5.1, 5.2, 5.0])
    '''
    mean = p6.mean(magnitudes)
    median = p6.median(magnitudes)
    mode = p6.mode(magnitudes)

    data = (mean, median, mode)

    return data
Esempio n. 4
0
def equake_analysis(magnitudes):
    '''(list) -> tuple
    Find and return the mean, median, and mode
    of the earthquake magnitudes as a tuple
    >>> equake_analysis([2.51, 2.52, 2.54, 2.7, 2.75, 2.77, 2.82, 2.96, 3.38])
    (2.772222222222222, 2.75, [2.51, 2.52, 2.54, 2.7, 2.75, 2.77, 2.82, 2.96, 3.38])
    >>> equake_analysis([5.0, 5.0, 5.1, 5.1, 5.2, 5.2, 5.2, 5.4, 5.6, 5.6, 5.7, 5.9, 6.0])
    (5.384615384615385, 5.2, [5.2])
    >>> equake_analysis([2.51, 2.52, 2.54, 2.6, 2.6, 2.61, 2.7, 2.75, 2.77, 2.8, 2.82, 2.89, 2.96, 3.03, 3.03, 3.3, 3.38, 3.55, 3.9])
    (2.908421052631579, 2.8, [2.6, 3.03])
    '''
    mean = p62.mean(magnitudes)
    median = p62.median(magnitudes)
    mode = p62.mode(magnitudes)
    mmm = (mean, median, mode)
    
    return mmm
Esempio n. 5
0
def equake_analysis(magnitudes):
    '''
    (list) -> tuple
    
    Returns the mean, median, and mode
    from a list of earthquake magnitudes.

    >>> equake_analysis([2.99, 2.56, 2.83, 2.76])
    (2.785, 2.795, [2.99, 2.56, 2.83, 2.76])

    >>> equake_analysis([5.0, 5.2, 5.1, 5.4, 5.2, 5.6, 5.6])
    (5.3, 5.2, [5.2, 5.6])
    
    >>> equake_analysis([5.2, 5.1, 6.0, 5.9, 5.6, 5.7, 5.0, 5.0])
    (5.437500000000001, 5.4, [5.0])
    '''
    
    magnitudes_mean = p62.mean(magnitudes)
    magnitudes_median = p62.median(magnitudes)
    magnitudes_mode = p62.mode(magnitudes)

    return magnitudes_mean, magnitudes_median, magnitudes_mode