[Code Up] 코드업 기초 100제 파이썬 1001–1099 정답

초보개발자
19 min readOct 31, 2020

--

  • 필요한 문제 번호를 ‘Ctrl+F(Window)’ 또는 ‘Command+F(MacOS)’로 검색하세요.(검색 키워드는 ‘#+문제번호’ 예시: #1)
  • 중간에 비어있는 번호는 코드업 사이트에서도 없던 문제입니다.
  • 코드 관련 질문이 있으시다면 댓글로 남겨주세요.
  • 최선의 정답 코드가 아닐수도 있습니다. 더 좋은 코드가 있다면 댓글로 부탁해요.
#1001
print('Hello')

#1002
print('Hello World')

#1003
print('Hello', 'World', sep = '\n')

#1004
print("'Hello'")

#1005
print('"Hello World"')

#1006
print('"!@#$%^&*()"')

#1007
print('"C:\\Download\\hello.cpp"')

#1008
print("\u250C\u252C\u2510\n\u251C\u253C\u2524\n\u2514\u2534\u2518")

#1010
num = int(input())
print(num)

#1011
c = input()
print(c)

#1012
f = input()
print(float(f))

#1013
a, b = map(int, input().split())
print(a, b)

#1014
a, b = map(int, input().split())
print(b, a)

#1015
f = input()
print('%.2f' % float(f))

#1017
i = input()
print(i,i,i)

#1018
h, m = map(int, input().split(':'))
print('%d:%d' % (h,m))

#1019
y, m, d = map(int, input().split('.'))
print('%d.%02d.%02d' % (y,m,d))

#1020
first, second = input().split('-')
print(first+second)

#1021
data = input()
print(data)

#1022
data = input()
print(data)

#1023
data = [int(x) for x in input().split('.')]
print(data[0])
print(data[1])

#1024
data = input()
for i in data:
print("'"+i+"'")

#1025
data = input()
for i in range(len(data)):
print('['+str(int(data[i])*(10**(len(data)-(i+1))))+']')

#1026
h, m, s = map(int, input().split(':'))
print(m)

#1027
year, month, day = map(int, input().split('.'))
print('%02d-%02d-%04d'%(day,month,year))

#1028
num = int(input())
print(num)

#1029
f = float(input())
print('%.3f' % f)

#1030
num = int(input())
print(num)

#1031
num = int(input())
print('%o'%num)

#1032
num = int(input())
print('%x'%num)

#1033
num = int(input())
print('%X'%num)

#1034
num = int(input(), 8)
print(num)

#1035
num = int(input(), 16)
print('%o' % num)

#1036 ord() 단일 문자형을 대응하는 ASCII번호로 반환
n = ord(input())
print(n)

#1037 chr() 정수를 ASCII에 대응하는 문자형으로 반환
c = chr(int(input()))
print(c)

#1038
def add(a, b):
print(a+b)
input_data = [int(x) for x in input().split()]
add(input_data[0], input_data[1])

#1039
def add(a, b):
print(a+b)
input_data = [int(x) for x in input().split()]
add(input_data[0], input_data[1])

#1040
num = int(input())
print(-num)

#1041
c = input()
c = chr(ord(c)+1)
print(c)

#1042
num1, num2 = map(int,input().split())
print(num1//num2)

#1043
num1, num2 = map(int,input().split())
print(num1%num2)

#1044
num = int(input())
print(num+1)

#1045
num1, num2 = map(int, input().split())
print(num1+num2, num1-num2, num1*num2, num1//num2, num1%num2, sep = '\n')
print('%.2f' % (num1/num2))

#1046
data = list(map(int,input().split()))
print(sum(data))
print(round(sum(data)/len(data),1))

#1047
num = int(input())
print(num<<1)

#1048
num1, num2 = map(int,input().split())
print(num1<<num2)

#1049
a, b = map(int, input().split())
print(1) if a > b else print(0)

#1050
a, b = map(int, input().split())
print(1) if a == b else print(0)

#1051
a, b = map(int, input().split())
print(0) if a > b else print(1)

#1052
a, b = map(int, input().split())
print(1) if a != b else print(0)

#1053
b = int(input())
print(int(not(b)))

#1054
b1, b2 = map(int, input().split())
print(1) if b1 and b2 else print(0)

#1055
b1, b2 = map(int, input().split())
print(1) if b1 or b2 else print(0)

#1056 - exclusive or(XOR, 배타적 OR)
b1, b2 = map(int, input().split())
print(1) if b1 != b2 else print(0)

#1057
b1, b2 = map(int, input().split())
print(1) if b1 == b2 else print(0)

#1058
b1, b2 = map(int, input().split())
print(1) if b1 == b2 == 0 else print(0)

#1059
num = int(input())
print(~num)

#1060
n1, n2 = map(int, input().split())
print(n1&n2)

#1061
n1, n2 = map(int, input().split())
print(n1|n2)

#1062
n1, n2 = map(int, input().split())
print(n1^n2)

#1063
a, b = map(int,input().split())
print(a if a>b else b)

#1064
numbers = list(map(int,input().split()))
print(min(numbers))

#1065
data = [int(x) for x in input().split()]
for x in data:
if x % 2 == 0: print(x)

#1066
data = [int(x) for x in input().split()]
for x in data:
if x % 2 == 0: print('even')
else: print('odd')

#1067
num = int(input())
print('plus') if num >= 0 else print('minus')
print('even') if num % 2 == 0 else print('odd')

#1068
score = int(input())
if 90 <= score <= 100:
print('A')
elif 70 <= score <= 89:
print('B')
elif 40 <= score <= 69:
print('C')
elif 0 <= score <= 39:
print('D')

#1069
grade = input()
data = {'A':'best!!!', 'B':'good!!', 'C':'run!', 'D':'slowly~'}
print(data[grade]) if grade in data.keys() else print('what?')

#1070
month = int(input())
if month in (12, 1, 2):
print('winter')
elif month in (3,4,5):
print('spring')
elif month in (6,7,8):
print('summer')
else:
print('fall')

#1071
numbers = list(map(int,input().split()))
for n in numbers:
if n != 0: print(n)
else: break

#1072
n = int(input())
data = list(map(int, input().split()))
for i in data:
print(i)

#1073
data = list(map(int,input().split()))
for i in data:
if i != 0: print(i)
else: break

#1074
num = int(input())
for i in range(num, 0, -1):
print(i)

#1075
num = int(input())
for i in range(num-1, -1, -1):
print(i)

#1076 a(97)~z(122)
apb = input()
for i in range(97, ord(apb)+1):
print(chr(i), end = ' ')

#1077
num = int(input())
for i in range(num+1):
print(i)

#1078
num = int(input())
data = [i for i in range(1, num+1) if i % 2 == 0]
print(sum(data))

#1079
data = list(input().split())
for i in data:
if i != 'q': print(i)
else:
print('q')
break

#1080
num = int(input())
sum = 0
for i in range(1, 46):
sum = sum + i
if sum >= num:
print(i)
break

#1081
n, m = map(int, input().split())
dice_1 = [i for i in range(1, n+1)]
dice_2 = [i for i in range(1, m+1)]

for i in dice_1:
for j in dice_2:
print(i, j)

#1082
num = int(input(), 16)
for i in range(1,16):
print('%X*%X=%X' % (num, i, num*i))

#1083
num = int(input())
for i in range(1, num+1):
print(i, end = ' ') if i not in (3,6,9) else print('X', end = ' ')

#1084
r, g, b = map(int, input().split())
red = [i for i in range(r)]
green = [i for i in range(g)]
blue = [i for i in range(b)]
for i in red:
for j in green:
for k in blue:
print(i, j, k)
print(r*g*b)

#1085
h, b, c, s = map(int, input().split())
print('%.1f'% ((h*b*c*s)*(2**-23)), 'MB')

#1086
w, h, b = map(int, input().split())
print('%.2f' % ((w*h*b)*(2**-23)), 'MB')

#1087
sum = 0
num = int(input())
for i in range(1,20000):
sum = sum + i
if sum >= num:
print(sum)
break

#1088
num = int(input())
for i in range(1, num+1):
if (i % 3 != 0): print(i, end = ' ')

#1089
a, d, n = map(int, input().split())
print(a+(d*(n-1)))

#1090
a, r, n = map(int, input().split())
print(a*(r**(n-1)))

#1091
a, m, d, n = map(int, input().split())
data = a
for i in range(n-1):
data = (data * m) + d
print(data)

#1092
a, b, c = map(int, input().split())
day = 1
while(day%a != 0 or day%b != 0 or day%c != 0): day = day + 1
print(day)

#1093
students = [0]*23
number_of_call = int(input())
called_students = list(map(int, input().split()))
for i in range(23): students[i] = called_students.count(i+1)
for i in students: print(i, end = ' ')

#1094
number_of_call = int(input())
called_students = list(map(int, input().split()))
called_students.reverse()
for i in called_students: print(i, end = ' ')

#1095
number_of_call = int(input())
called_students = list(map(int, input().split()))
print(min(called_students))

#1096
stone_stage = [[0]*19 for _ in range(19)]
stone_cnt = int(input())
for i in range(stone_cnt):
x, y = map(int, input().split())
stone_stage[x-1][y-1] = 1
for i in range(len(stone_stage)):
for j in range(len(stone_stage[i])):
print(stone_stage[i][j], end=' ') if j != 18 else print(stone_stage[i][j], end = '\n')

입력값:
5
1 1
2 2
3 3
4 4
5 5

출력값:
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

#1097
stone_stage = []
for _ in range(19):
stone_line = list(map(int, input().split()))
stone_stage.append(stone_line)
number_of_point = int(input())
for i in range(number_of_point):
x, y = map(int, input().split())
for j in range(19): stone_stage[x-1][j] = int(not(stone_stage[x-1][j]))
for j in range(19): stone_stage[j][y-1] = int(not(stone_stage[j][y-1]))
for i in range(len(stone_stage)):
for j in range(len(stone_stage[i])):
print(stone_stage[i][j], end=' ') if j != 19-1 else print(stone_stage[i][j], end = '\n')

입력값:
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

#1098
h, w = map(int, input().split())
candy_stage = [[0] * w for i in range(h)]
count_of_stick = int(input())
for _ in range(count_of_stick):
l, d, x, y = map(int, input().split())
if d == 0:
for j in range(y-1, y+l-1):
candy_stage[x-1][j] = 1
else:
for j in range(x-1, x+l-1):
candy_stage[j][y-1] = 1
for i in range(len(candy_stage)):
for j in range(len(candy_stage[i])):
print(candy_stage[i][j], end=' ') if j != w-1 else print(candy_stage[i][j], end = '\n')

#1099
#동작순서: 우선 현재 좌표에 2가 있는지 확인, 그 다음 오른쪽 확인, 그 다음 아래 확인
x = 1
y = 1
ant_stage = []
for i in range(10):
ant_stage.append(list(map(int, input().split())))
while(True):
if ant_stage[y][x] == 2:
ant_stage[y][x] = 9
break
elif ant_stage[y][x+1] == 1:
if ant_stage[y+1][x] == 1:
ant_stage[y][x] = 9
break
else:
ant_stage[y][x] = 9
y = y + 1
elif x == 8 and y == 8:
ant_stage[y][x] = 9
break
else:
ant_stage[y][x] = 9
x = x + 1
for i in range(len(ant_stage)):
for j in range(len(ant_stage[i])):
print(ant_stage[i][j], end=' ') if j != 10-1 else print(ant_stage[i][j], end = '\n')

입력값:
1 1 1 1 1 1 1 1 1 1
1 0 0 1 0 0 0 0 0 1
1 0 0 1 1 1 0 0 0 1
1 0 0 0 0 0 0 1 0 1
1 0 0 0 0 0 0 1 0 1
1 0 0 0 0 1 0 1 0 1
1 0 0 0 0 1 2 1 0 1
1 0 0 0 0 1 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1

--

--

Responses (2)