초보자를 위한 파이썬 300제 (081~090)
위키독스
온라인 책을 제작 공유하는 플랫폼 서비스
wikidocs.net
|
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
|
#081
scores = [8.8, 8.9, 8.7, 9.2, 9.3, 9.7, 9.9, 9.5, 7.8, 9.4]
*valid_score, a, b= scores
print(valid_score)
#082
scores = [8.8, 8.9, 8.7, 9.2, 9.3, 9.7, 9.9, 9.5, 7.8, 9.4]
a, b, *valid_score = scores
print(valid_score)
#083
scores = [8.8, 8.9, 8.7, 9.2, 9.3, 9.7, 9.9, 9.5, 7.8, 9.4]
a, *valid_score, b = scores
print(valid_score)
#084
temp = {}
#085
icecream = {"메로나": 1000, "폴라포": 1200, "빵빠레": 1800}
print(icecream)
#086
icecream = {"메로나": 1000, "폴라포": 1200, "빵빠레": 1800}
icecream["죠스바"] = 1200
icecream["월드콘"] = 1500
print(icecream)
#087
ice = {'메로나': 1000,
'폴로포': 1200,
'빵빠레': 1800,
'죠스바': 1200,
'월드콘': 1500}
print("메로나 가격: ", ice["메로나"])
#088
ice = {'메로나': 1000,
'폴로포': 1200,
'빵빠레': 1800,
'죠스바': 1200,
'월드콘': 1500}
ice["메로나"] = 1300
print(ice)
#089
ice = {'메로나': 1000,
'폴로포': 1200,
'빵빠레': 1800,
'죠스바': 1200,
'월드콘': 1500}
del ice["메로나"]
print(ice)
#090 에러 발생 원인 : icecream 딕셔너리에 '누가바'라는 키와 값이 없기 때문
>> icecream = {'폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
>> icecream['누가바']
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
icecream['누가바']
KeyError: '누가바'
|
cs |
초보자를 위한 파이썬 300제 (091~100)
위키독스
온라인 책을 제작 공유하는 플랫폼 서비스
wikidocs.net
|
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
|
#091
inventory = {"메로나": [300, 20], "비비빅": [400, 3], "죠스바": [250, 100]}
print(inventory)
#092
inventory = {"메로나": [300, 20], "비비빅": [400, 3], "죠스바": [250, 100]}
print(inventory["메로나"][0], "원")
#093
inventory = {"메로나": [300, 20], "비비빅": [400, 3], "죠스바": [250, 100]}
print(inventory["메로나"][1], "개")
#094
inventory = {"메로나": [300, 20], "비비빅": [400, 3], "죠스바": [250, 100]}
inventory["월드콘"] = [500, 7]
print(inventory)
#095
icecream = {'탱크보이': 1200, '폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
a = list(icecream.keys())
print(a)
#096
icecream = {'탱크보이': 1200, '폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
a = list(icecream.values())
print(a)
#097
icecream = {'탱크보이': 1200, '폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
print(sum(icecream.values()))
#098
icecream = {'탱크보이': 1200, '폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
new_product = {'팥빙수':2700, '아맛나':1000}
icecream.update(new_product)
print(icecream)
#099
keys = ("apple", "pear", "peach")
vals = (300, 250, 400)
result = dict(zip(keys, vals))
print(result)
#100
date = ['09/05', '09/06', '09/07', '09/08', '09/09']
close_price = [10500, 10300, 10100, 10800, 11000]
close_table = dict(zip(date, close_price))
print(close_table)
|
cs |
'Python & SQL > Python Problems' 카테고리의 다른 글
| [초보 300제] 파이썬 반복문(131~200) 풀이 (0) | 2021.04.03 |
|---|---|
| [초보 300제] 파이썬 분기문(101~130) 풀이 (0) | 2021.03.29 |
| [초보 300제] 파이썬 튜플(071~080) 풀이 (2) | 2021.03.27 |
| [초보 300제] 파이썬 리스트(051~070) 풀이 (0) | 2021.03.27 |
| [초보 300제] 파이썬 문자열(021~050) 풀이 (0) | 2021.03.26 |