Notice
Recent Posts
Recent Comments
Link
할껀하고놀자
파이썬 기초 300제(8) - 딕셔너리 본문
728x90
딕셔너리 배움
zip 하면 묶어준다는거 배움
구조가 복잡해지는거 넣는거 배움
# 81
inventory = {'메로나':[300,20],'비비빅':[400,3],'죠스바':[250,100]}
print(inventory)
# 82
print(inventory['메로나'][0],"원")
# 83
print(inventory['메로나'][1],"개")
# 84
inventory['월드콘']=[500,7]
print(inventory)
# 85
icecream = {'탱크보이': 1200, '폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
print(icecream.keys()) # dict_keys 붙어서 나옴
print(list(icecream.keys())) # 리스트화 시켜줌
# 86
print(list(icecream.values()))
# 87
new_product = {'팥빙수':2700, '아맛나':1000}
# print(icecream + new_product) 더하는건 안됨
icecream.update(new_product) # 업데이트 해줌
print(icecream)
# 88
icecream = {'탱크보이': 1200, '폴라포': 1200, '빵빠레': 1800, '월드콘': 1500, '메로나': 1000}
print(sum(icecream.values()))
# 89
keys = ('apple', 'pear', 'peach')
vals = (300, 250, 400)
values = dict(zip(keys,vals))
print(values)
# 90
date = ['09/05', '09/06', '09/07', '09/08', '09/09']
close_price = [10500, 10300, 10100, 10800, 11000]
values = dict(zip(date,close_price))
print(values)
Comments