본문 바로가기

코딩테스트

[CodeUp] python 기초 100제_6001~6100

 

 

[기초 - 출력]

 

6001

print('Hello')

 

 

6002

print('Hello','World')

 

6003

print('Hello')
print('World')

 

6004

print("'Hello'")

 

6005

print('"Hello World"')

 

6006

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

 

6007

print('"C:\Download\\\'hello\'.py"')

 

6008

print('print("Hello\\nWorld")')

 


[기초 - 입출력]

 

6009

i = input()
print(i)

 

6010

n = int(input())
print(n)

 

6011

f = float(input())
print(f)

 

6012

a = int(input())
b = int(input())
print(a)
print(b)

 

6013

a = input()
b = input()
print(b)
print(a)

 

6014

f = float(input())
print(f)
print(f)
print(f)

 

6015

a, b = input().split()
a = int(a)
b = int(b)
print(a)
print(b)

 

6016

a, b = input().split()
print(b, a)

 

6017

s = input()
print(s,s,s)

 

6018

a, b = input().split(':')
print(a, b, sep=':')

 

6019

a, b, c = input().split('.')
print(c, b, a, sep='-')

 

6020

a, b = input().split('-')
print(a, b, sep='')

 

6021

s = input()
for i in range(len(s)):
	print(s[i])

 

6022

s = input()
print(s[0:2], s[2:4], s[4:])

 

6023

a, b, c = input().split(':')
print(b)

 

6024

a, b = input().split()
print(a+b)

 


[기초 - 값변환]

 

6025

a, b = input().split()
a = int(a)
b = int(b)
print(a+b)

 

6026

a = float(input())
b = float(input())
print(a+b)

 

6029

  • 16진 정수 입력 → 8진수 출력
a = input()
n = int(a, 16)
print('%o' %n)

 

6030

  • 영문자 입력 → 10진수 유니코드(Unicode) 출력
a = ord(input())
print(a)

 

6031

  • 정수 입력 → 유니코드 문자 변환 출력
a = int(input())
print(chr(a))

 

6042

a = float(input())
print(round(a,2))

[기초 - 출력변환]

 

6027

  • 10진 정수 입력 → 16진수 출력
a = int(input())
print('%x' %a)

 

6028

  • 10진 정수 입력 → 16진수 대문자 출력 
a = int(input())
print('%X' %a)

 


[기초 - 산술연산]

 

6032

a = int(input())
print(-a)

 

6033

  • 문자 1개 입력 → 다음 문자 출력 
a = ord(input())
print(chr(a+1))

 

6034

a, b = input().split()
print(int(a)-int(b))

 

6035

a, b = input().split()
m = float(a) * float(b)
print(m)

 

6036

w, n = input().split()
a = w * int(n)
print(a)

 

6037

n = int(input())
w = input()
print(n * w)

 

6038

a, b = input().split()
a = int(a)
b = int(b)
print( a**b )

 

6039

a, b = input().split()
a = float(a)
b = float(b)
print( a**b )

 

6040

a, b = input().split()
a = int(a)
b = int(b)
print(a//b)

 

6041

a, b = input().split()
a = int(a)
b = int(b)
print(a%b)

 

6043

a, b = input().split()
a = float(a)
b = float(b)
m = a/b
print('%.3f' %m)

 

6044

a, b = input().split()
a = int(a)
b = int(b)
print(a+b)
print(a-b)
print(a*b)
print(a//b)
print(a%b)
m = a/b
print('%.2f' %m)

 

6045

a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
hap = a + b + c
avg = hap/3
print(hap, '%.2f' %avg)

 


[기초 - 비트시프트연산]

 

6046

n = int(input())
print(int(n<<1))

 

6047

a, b = input().split()
a = int(a)
b = int(b)
print(int(a<<b))

 


[기초 - 비교연산]

 

6048

a, b = input().split()
a = int(a)
b = int(b)
print(a<b)

 

6049

a, b = input().split()
a = int(a)
b = int(b)
print(a==b)

 

6050

a, b = input().split()
a = int(a)
b = int(b)
print(a<=b)

 

6051

a, b = input().split()
a = int(a)
b = int(b)
print(a!=b)

 


[기초 - 논리연산]

 

6052

n = int(input())
print(bool(n))

 

6053

n = bool(int(input()))
print(not n)

 

6054

a, b = input().split()
print(bool(int(a)) and bool(int(b)))

 

6055

a, b = input().split()
print(bool(int(a)) or bool(int(b)))

 

6056

a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print((a and not b) or (not a and b))

 

6057

a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print((not a and not b) or (a and b))

 

6058

a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print(not(a or b))

[기초 - 비트단위논리연산]

 

6059

a = int(input())
print(~a)

 

6060

a, b = input().split()
a = int(a)
b = int(b)
print(a&b)

 

6061

a, b = input().split()
a = int(a)
b = int(b)
print(a|b)

 

6062

a, b = input().split()
a = int(a)
b = int(b)
print(a^b)

[기초 - 3항 연산]

 

6063

a, b = input().split()
a = int(a)
b = int(b)
c = (a if (a>b) else b)
print(c)

 

6064

a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
print((a if a<b else b) if (a if a<b else b)<c else c)

[기초 - 조건/선택실행구조]

 

6065

a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
if a % 2 == 0:
    print(a)
if b % 2 == 0:
    print(b)
if c % 2 == 0:
    print(c)

 

6066

a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
if a%2==0:
    print('even')
else:
    print('odd')
if b%2==0:
    print('even')
else:
    print('odd')
if c%2==0:
    print('even')
else:
    print('odd')

 

6067

n = int(input())
if (n<0) and (n%2==0):
    print('A')
elif (n<0) and (n%2==1):
    print('B')
elif (n>0) and (n%2==0):
    print('C')
else:
    print('D')

 

6068

n = int(input())
if n>=90:
    print('A')
elif n>=70:
    print('B')
elif n>=40:
    print('C')
else:
    print('D')

 

6069

s = input()
if s == 'A':
    print('best!!!')
elif s == 'B':
    print('good!!')
elif s == 'C':
    print('run!')
elif s == 'D':
    print('slowly~')
else:
    print('what?')

 

6070

n = int(input())
if n//3 == 1:
    print('spring')
elif n//3 == 2:
    print('summer')
elif n//3 ==3:
    print('fall')
else:
    print('winter')

[기초 - 반복실행구조]

 

6071

n = 1
while n != 0:
    n = int(input())
    if n != 0:
        print(n)
    else:
        pass

 

6072

n = int(input())
while n!=0:
    print(n)
    n = n-1

 

6073

n = int(input())
while n != 0:
    n = n-1
    print(n)

 

6074

c = ord(input())
a = ord('a')
while a <= c:
    print(chr(a), end=" ")
    a = a + 1

 

6075

n = int(input())
f = 0
while f <= n:
    print(f)
    f += 1

 

6076

n = int(input())
f = 0
while f <= n:
    print(f)
    f += 1

[기초 - 종합]

 

6077

n = int(input())
s = 0
for i in range(n+1):
    if i % 2 == 0:
        s = s + i
    else:
        pass
print(s)

 

6078

while 1:
    n = input()
    if n == 'q':
        print(n)
        break
    else:
        print(n)

 

6079

n = int(input())
s = 0
i = 1
while s<n:
    s = s + i
    i += 1
print(i-1)

 

6080

a , b = input().split()
a = int(a)
b = int(b)
for i in range(1,a+1):
    for j in range(1,b+1):
        print(i,j)

 

6081

n = int(input(),16)
for i in range(1, 16):
    print('%X'%n, '*%X'%i, '=%X'%(n*i), sep='')

 

6082

n = int(input())
for i in range(1,n+1):
    if i % 10 == 3:
        print('X', end=' ')
    elif i % 10 == 6:
        print('X', end=' ')
    elif i % 10 == 9:
        print('X', end=' ')
    else:
        print(i, end=' ')

 

6083

a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
count = 0
for i in range(a):
    for j in range(b):
        for k in range(c):
            print(i, j, k)
            count += 1 
print(count)

 

6084

h, b, c, s = input().split()
h = int(h)
b = int(b)
c = int(c)
s = int(s)
cap = (h * b * c * s) / 8 / 1024/1024
print(round(cap, 1), 'MB')

 

6085

w, h, b = input().split()
w = int(w)
h = int(h)
b = int(b)
cap = (w*h*b)/8/1024/1024
print('%.2f' %cap,'MB')

 

6086

n = int(input())
i = 0
s = 0
while True:
    s += i
    i += 1 
    if s >= n:
        break
print(s)

 

6087

n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        pass
    else:
        print(i)

 

6088

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

 

6089

a, r, n = input().split()
a = int(a)
r = int(r)
n = int(n)
seq = a*r**(n-1)
print(seq)

 

6090

a, m, d, n = input().split()
a = int(a)
m = int(m)
d = int(d)
n = int(n)
seq = (a * m) + d
if n == 1 :
    print(a)
elif n == 2:
    print(seq)
else:
    for i in range(n-2):
        seq = seq * m + d
    print(seq)

 

6091

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

 


[기초 - 리스트]

 

6092

n = int(input())
a = input().split()
d = []

for i in range(n):
    a[i] = int(a[i])

for i in range(24):
    d.append(0)

for i in range(n):
    d[a[i]] += 1

for i in range(1,24):
    print(d[i], end=' ')

 

6093

n = int(input())
a = input().split()

for i in range(n):
    a[i] = int(a[i])

for i in range(n-1,-1,-1):
    print(a[i], end=' ')

 

6094

n = int(input())
a = input().split()

for i in range(n):
    a[i] = int(a[i])

print(min(a))

 

6095

# 바둑판 
d = [[0 for j in range(19)] for i in range(19)]

#바둑 위치  
n = int(input())
k =[]
for i in range(n):
    a, b = input().split()
    a = int(a)
    b = int(b)
    d[a-1][b-1] = 1

#출력
for i in range(19):
    for j in range(19):
        print(d[i][j], end=' ')
    print()

 

6096

#바둑판 
d = []
for i in range(19):
    a = input().split()
    d.append(a)

#정수형 변환 
d = [[int(d[i][j]) for j in range(19)]for i in range(19)]

#좌표
n = int(input())
for i in range(n):
    x, y = input().split()
    x = int(x)-1
    y = int(y)-1
    for j in range(19):
        #가로 
        if d[j][y] == 1:
            d[j][y] = 0
        else:
            d[j][y] = 1
        #세로    
        if d[x][j] == 1:
            d[x][j] = 0
        else:
            d[x][j] = 1 

#출력         
for i in range(19):
    for j in range(19):
        print(d[i][j], end=' ')
    print()

 

6097

h, w = input().split()
h = int(h)
w = int(w)

k =[[0 for j in range(w)]for i in range(h)]

n = int(input())

for i in range(n):
    l, d, x, y = input().split()
    l = int(l)
    d = int(d)
    x = int(x)
    y = int(y)
    if d == 0:
        for j in range(l):
            k[x-1][y+j-1] = 1
    else:
        for j in range(l):
            k[x+j-1][y-1] = 1

for i in range(h):
    for j in range(w):
        print(k[i][j], end=' ')
    print()

 

6098

d = []
for i in range(10):
    a = list(input().split())
    d.append(a)
d = [[int(d[i][j]) for j in range(10)]for i in range(10)]

i, j = 1, 1
d[i][j] = 9
while d[i][j] != 2:
    if d[i][j+1] == 0: #오른쪽 이동
        j += 1
        d[i][j]=9
    elif d[i][j+1] == 2: #오른쪽 먹이  
        j += 1
        d[i][j] = 9
        break 
    elif d[i+1][j] == 0: #아래로 이동 
        i += 1
        d[i][j]=9
    elif d[i+1][j] == 2: #아래 먹이 
        i += 1
        d[i][j] = 9
        break
    else:
        break

for i in range(10):
    for j in range(10):
        print(d[i][j], end=' ')
    print()