PYTHON/파이썬 코딩 도장

파이썬 코딩 도장 UNIT 22, 23, 24 심사문제

GaeGim 2022. 7. 26. 20:20
반응형

22.10 심사문제: 2의 거듭제곱 리스트 생성하기

srt, end = map(int, input().split())
list = []
for i in range(srt, end+1):
    a = 2**i
    list.append(a)
del list[1]
del list[-2]
print(list)

 

 

 

 

23.7 심사문제: 지뢰찾기

col, row = map(int, input().split())
matrix = []
for i in range(row):
    matrix.append(list(input()))
for i in range(col):
    for j in range(row):
        if matrix[i][j]=='*':
            print('*',end='')     
        else:
            count=0
            for k in range(i-1,i+2):
                for l in range(j-1,j+2):
                    if k<0 or k>=row or l<0 or l>=row:
                        continue
                    elif matrix[k][l]=='*':
                        count+=1
            print(count,end='')
    print()

 

 

 

 

24.5 심사문제: 특정 단어 개수 세기

stc = '''the growns-ups response, this time, was to advise me to lay aside my drawings of boa
constrictors, whether from the inside or the outside, and devote myself instead to
geography, history, arithmetic, and grammer. That is why, at the, age of six, I gave up
what might have been a magnificent career as a painter. I had been disheartened by the
failure of my Drawing Number One and my Drawing Number Two. Grown-ups never understand
anything by themselves, and it is tiresome for children to be always and forever
explaining things to the.'''.split()
cnt = 0
for i in stc:
    if i.strip('.,') == 'the':
        cnt+=1
print(cnt)	//6

 

 

 

 

 

24.6 심사문제: 높은 가격순으로 출력하기

p = list(map(int, input().split(';')))
p.sort(reverse=True)
for i in p:
    print('%9s' % format(i, ','))
반응형