본문 바로가기
Algorithm problem solving/풀이

[SW Expert Academy] 파이썬 기초2_딕셔너리 ( 6259~ 6262 )

by Jiyoon-park 2020. 3. 1.

딕셔너리 파트 마지막 네문제

6259. 딕셔너리_7

sentence = input()

letters = 0
digit = 0
for s in sentence:
    if s.isdigit():
        digit += 1
    if s.isalpha():
        letters += 1
print(f'LETTERS {letters}\nDIGITS {digit}')

6260. 딕셔너리_8

sentence = input()

upper = 0
lower = 0
for s in sentence:
    if 65<= ord(s) <=90:
        upper += 1
    if 97<= ord(s) <=122:
        lower += 1

print('UPPER CASE {}\nLOWER CASE {}'.format(upper, lower))

6261. 딕셔너리_9

beer = {'하이트': 2000, '카스': 2100, '칭따오': 2500, '하이네켄': 4000, '버드와이저': 500}
result = { key:value*1.05 for key,value in beer.items() }

print(beer)
print(result)

6262. 딕셔너리_10

chars = input()

result = {}
for char in chars:
    if char not in result.keys():
        result[char] = 1
    else:
        result[char] += 1

for key, val in result.items():
    print(key, val, sep=',')