Esempio n. 1
0
def test_class_total():
    assert class_total([{'국어': 100}], '국어') == 100
    assert class_total([{'국어': 100}, {'국어': 80}], '국어') == 180
    assert class_total([{
        '국어': 100,
        '영어': 90
    }, {
        '국어': 80,
        '영어': 20
    }], '국어') == 180
    assert class_total([
        {
            '국어': 100,
            '영어': 90,
            '수학': 95
        },
        {
            '국어': 80,
            '영어': 20,
            '수학': 100
        },
        {
            '국어': 10,
            '영어': 20,
            '수학': 30
        },
    ], '국어') == 190
Esempio n. 2
0
def main():
    class_scores = [{
        'Name': 'Jane',
        'Korean': 100,
        'English': 100,
        'Math': 100
    }, {
        'Name': 'Brown',
        'Korean': 10,
        'English': 20,
        'Math': 30
    }]

    total = {'Name': '<Total>'}
    for subject in ['Korean', 'English', 'Math']:
        total[subject] = class_total(class_scores, subject)

    avg = {'Name': '<Average>'}
    for subject in ['Korean', 'English', 'Math']:
        avg[subject] = class_avg(class_scores, subject)

    table = pd.DataFrame(class_scores + [total] + [avg],
                         columns=['Name', 'Korean', 'English', 'Math'])

    table["Average"]
    table["Total"]

    print(table)
Esempio n. 3
0
def main():
    class_scores = [{
        'Name': 'Jane',
        'Korean': 100,
        'English': 100,
        'Math': 100
    }, {
        'Name': 'Brown',
        'Korean': 10,
        'English': 20,
        'Math': 30
    }]

    total = {'Name': '<Total>'}
    for subject in ['Korean', 'English', 'Math']:
        total[subject] = class_total(class_scores, subject)

    table = tabulate(class_scores + [total], 'keys', 'fancy_grid')
    print(table)
    print()

    table = pd.DataFrame(class_scores + [total],
                         columns=['Name', 'Korean', 'English', 'Math'])
    print(table)
    print()