-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path딕셔너리.py
95 lines (74 loc) · 1.62 KB
/
딕셔너리.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
n=int(input())
grade={}
cnt=0
while cnt<n:
name=input()
score=int(input())
grade[name] = score
cnt+=1
final_name=input()
print('%s\'s score = %d'%(final_name,grade[final_name]))
n=int(input())
student={}
while n!=0:
if n==1:
name=input()
score=int(input())
student[name]=score
elif n==2:
name=input()
if (name not in student)==True:
print('No student')
else:
print('Name = %s, Score = %d'%(name,student[name]))
n=int(input())
3번 my답
n=int(input())
density={}
cnt=0
while cnt<n:
city=input()
surf=int(input())
pop=int(input())
density[city]=surf/pop
cnt+=1
HD=max(density)
print('Highest Population Density = %s, %.2f'%(HD,density[HD]))
#3번 답
n=int(input())
density={}
cnt=0
while cnt<n:
city=input()
surf=int(input())
pop=int(input())
density[city]=surf/pop
cnt+=1
max = 0
for key,value in city.items():
if max < value:
max=value
max_key=key
print('Highest Population Density = %s, %.2f'%(max_key,max))
n=int(input())
tel={}
while True:
if n==1:
name = input()
num = input()
tel[name]=num
elif n==2:
name=input()
if (name not in tel)==True:
print('Do not find!')
else:
num=input()
tel[name]=num
elif n==0:
name=input()
if (name not in tel)==True:
print('System error!')
else :
print(tel[name])
break
n=int(input())