Post

오픈소스 1주차 과제 테스트

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def normalize_data(n_cases, n_people, scale):
    # Calculate the number of cases per its population
    norm_cases = []
    for idx, n in enumerate(n_cases):
        norm_cases.append(n_cases[idx]/n_people[idx]*scale)
    return norm_cases

regions  = ['Seoul', 'Gyeongi', 'Busan', 'Gyeongnam', 'Incheon', 'Gyeongbuk', 'Daegu', 'Chungnam', 'Jeonnam', 'Jeonbuk', 'Chungbuk', 'Gangwon', 'Daejeon', 'Gwangju', 'Ulsan', 'Jeju', 'Sejong']
n_people = [9550227,  13530519, 3359527,     3322373,   2938429,     2630254, 2393626,    2118183,   1838353,   1792476,    1597179,   1536270,   1454679,   1441970, 1124459, 675883,   365309] # 2021-08
n_covid  = [    644,       529,      38,          29,       148,          28,      41,         62,        23,        27,         27,        33,        16,        40,      20,      5,        4] # 2021-09-21

sum_people = sum(n_people) # The total number of people
sum_covid  = sum(n_covid) # The total number of new cases
norm_covid = normalize_data(n_covid, n_people, 1000000) # The new cases per 1 million people

# Print population by region
print('### Korean Population by Region')
print('* Total population:', sum_people)
print() # Print an empty line
print('| Region | Population | Ratio (%) |')
print('| ------ | ---------- | --------- |')
for idx, pop in enumerate(n_people):
    ratio = pop/sum_people*100 # The ratio of new cases to the total
    print('| %s | %d | %.1f |' % (regions[idx], pop, ratio))
print()

# Print COVID-19 new cases by region
print('### Korean COVID-19 New Cases by Region')
print('* Total new cases:', sum_covid)
print() # Print an empty line
print('| Region | New Cases | Ratio (%) | New Cases / 1M |')
print('| ------ | --------- | --------- | -------------- |')
for idx, pop in enumerate(n_covid):
    ratio = n_covid[idx]/sum(n_covid)*100
    print('| %s | %d | %.1f | %.1f |' % (regions[idx], pop, ratio, norm_covid[idx]))
print()

Korean Population by Region

  • Total population: 51669716
RegionPopulationRatio (%)
Seoul955022718.5
Gyeongi1353051926.2
Busan33595276.5
Gyeongnam33223736.4
Incheon29384295.7
Gyeongbuk26302545.1
Daegu23936264.6
Chungnam21181834.1
Jeonnam18383533.6
Jeonbuk17924763.5
Chungbuk15971793.1
Gangwon15362703.0
Daejeon14546792.8
Gwangju14419702.8
Ulsan11244592.2
Jeju6758831.3
Sejong3653090.7

Korean COVID-19 New Cases by Region

  • Total new cases: 1714
RegionNew CasesRatio (%)New Cases / 1M
Seoul64437.667.4
Gyeongi52930.939.1
Busan382.211.3
Gyeongnam291.78.7
Incheon1488.650.4
Gyeongbuk281.610.6
Daegu412.417.1
Chungnam623.629.3
Jeonnam231.312.5
Jeonbuk271.615.1
Chungbuk271.616.9
Gangwon331.921.5
Daejeon160.911.0
Gwangju402.327.7
Ulsan201.217.8
Jeju50.37.4
Sejong40.210.9
This post is licensed under CC BY 4.0 by the author.