#6063_ ์ ์ ๋ ๊ฐ ์
๋ ฅ๋ฐ์ ํฐ ๊ฐ ์ถ๋ ฅํ๊ธฐ. (์ผํญ์ฐ์ฐ์ ์ฌ์ฉํ ๊ฒ)
์
๋ ฅ : 123 456
์ถ๋ ฅ : 456
๋ดํ์ด
a,b = map(int,input().split())
c = a if a>b else b
print(c)
๋ดํ์ด
a,b = map(int,input().split())
print(a) if a>b else print(b)
์ ๋ตํ์ด
a, b = input().split()
a = int(a)
b = int(b)
c = a if a>=b else b
print(c)
์ผํญ์ฐ์ฐ์๋ [์ฐธ์ผ๋] if [์กฐ๊ฑด๋ฌธ] else [๊ฑฐ์ง์ผ๋] ํํ๋ก ์ฐ์ด๋ฉฐ ์ฝ๋๊ฐ ๊ฐ๊ฒฐํด๋ณด์ธ๋ค๋ ์ฅ์ ์ด ์์ง๋ง, ์คํ๋ ค ๋ณต์กํ ์ฐ์ฐ์ ๊ฒฝ์ฐ ๊ฐ๋ ์ฑ์ด ๋ ๋จ์ด์ ธ ๋ณด์ผ ์ ์๋ค.
[python] ํ์ด์ฌ ์ผํญ ์ฐ์ฐ์ (if ~ else ~)
์๋ ํ์ธ์. BlockDMask์ ๋๋ค. ์ค๋์ ํ์ด์ฌ์์ ์ฌ์ฉํ๋ ์ผํญ ์ฐ์ฐ์์ ๋ํด์ ์์๋ณด๊ฒ ์ต๋๋ค. 1. ํ์ด์ฌ์์์ ์ผํญ ์ฐ์ฐ์ 2. ํ์ด์ฌ ์ผํญ ์ฐ์ฐ์ ์์ 1. ์ผํญ ์ฐ์ฐ์ (Ternary Operators) 1-1) ์ผ
blockdmask.tistory.com
#6071_ 0์ด ์
๋ ฅ๋ ๋๊น์ง ๋ฌดํ ์ถ๋ ฅํ๊ธฐ.
์ถ๋ ฅ : 7
4
2
3
0
1
์
๋ ฅ : 7
4
2
3
๋ดํ์ด
while True :
a = int(input())
if a == 0 :
break
print(a)
์ ๋ตํ์ด
while True:
a=input()
a=int(a)
if a==0:
break
else:
print(a)
์ ๋ตํ์ด
n = 1
while n != 0 :
n = int(input())
if n != 0 :
print(n)
#6074_ ๋ฌธ์ ํ ๊ฐ ์ ๋ ฅ๋ฐ์ ์ํ๋ฒณ ์ถ๋ ฅํ๊ธฐ
์
๋ ฅ : f
์ถ๋ ฅ : a b c d e f
๋ดํ์ด
a = ord(input())
c = 97
while a >= c :
print(chr(c), end = " ")
c = c+1
์ ๋ตํ์ด
c = input()
i = ord('a')
c = ord(c)
while i<=c:
print(chr(i), end=' ')
i+=1
ord('A')๋ 65์ด๊ณ , ord('a')๋ 97์ด๋ค.
#6081_ 16์ง์ ๊ตฌ๊ตฌ๋จ ์ถ๋ ฅํ๊ธฐ.
์
๋ ฅ : B
์ถ๋ ฅ : B*1=B
...
B*F=A5
๋ดํ์ด
a = int(input(),16)
b = int('F',16)
c = int('1', 16)
while c <= b :
print('%X'%a+'*'+'%X'%c+'='+'%X'%(a*c))
c = c+1
์ ๋ตํ์ด
n = int(input(), 16)
for i in range(1, 16) :
print('%X'%n, '*%X'%i, '=%X'%(n*i), sep='')
16์ง์๋ฅผ ํํํ ๋ %X(๋๋ฌธ์ํํ)์ %x(์๋ฌธ์ํํ)๋ฅผ ์ฌ์ฉํ๋ค. 8์ง์๋ฅผ ํํํ ๋ %O(๋๋ฌธ์ํํ)์ %o(์๋ฌธ์ํํ)๋ฅผ ์ฌ์ฉํ๋ค. 16์ง์์ 8์ง์๋ฅผ ์ฌ์ฉํ๋ ์ด์ ๋ 2์ง์๋ก ๊ฐ์ ํํํ๊ธฐ์ ๋๋ฌด ๊ธธ๊ธฐ ๋๋ฌธ์ด๋ค. 16์ง์์ 8์ง์ ๋ชจ๋ 2์ง์์ ์ ๊ณฑ์ ํํ๋ก ๊ธธ์ด์ง 2์ง์์ ๊ฐ์ ์งง๊ฒ ํํํ ์ ์๋ค.
- 2์ง์ 8์ง์ 16์ง์๋ฅผ ์ฐ๋ ์ด์
์ปดํจํฐ์์ 2์ง์, 8์ง์ 16์ง์๋ฅผ ์ฐ๋ ์ด์
๊ธฐ๋ณธ์ ์ผ๋ก ์ธ๊ฐ์ 10์ง์๋ฅผ ์ด๋ค. ํ์ง๋ง ์ปดํจํฐ๋ 0,1 ๋๊ฐ์ง ๋ฐ์ ๋ชจ๋ฅธ๋ค๊ณ ํ๋ค. ๊ทธ๋์ 2์ง๋ฒ์ ์ด๋ค๊ณ ๋ณด๋ฉด ๋๋๋ฐ ์ฌ์ฌ์น์๊ฒ 8์ง์์ 16์ง์๋ฅผ ์ฝ๋ฉํ ๋ ์ฐ๊ฒ๋๋ค. ํ์ผ ๊ฐ์๊ฑธ ๋ค๋ฃฐ ๋
velog.io
#6082_ 3 6 9 ๊ฒ์์ ์์ด ๋์.
์
๋ ฅ : 9
์ถ๋ ฅ : 1 2 X 4 5 X 7 8 X
๋ดํ์ด
a = int(input())
for i in range (1, a+1) :
b = i%10
if b==3 or b==6 or b==9 :
print('X',end=" ")
else :
print(i, end=" ")
๋ดํ์ด
a = int(input())
for i in range(1, a+1):
if str(i).count('3')+str(i).count('6')+str(i).count('9') :
print("X", end =" ")
else :
print(i, end=" ")
์ ๋ตํ์ด
n = int(input())
for i in range(1, n+1) :
if i%10==3 or i%10==6 or i%10==9 :
print("X", end=' ')
else :
print(i, end=' ')
i๊ฐ์ str์ธ ๋ฌธ์์ด๋ก ๋ฐ๊ณ , ๋ฌธ์์ด i์ 3๊ณผ 6 ๊ทธ๋ฆฌ๊ณ 9๋ผ๋ ๋ฌธ์๊ฐ ํ ๋ฒ์ด๋ผ๋ ๋์ค๋ฉด X๊ฐ ์ถ๋ ฅ๋๋๋ก ๋ง๋ค์๋ค. ์ฌ๊ธฐ์ count( )๋ ๊ดํธ ์์ ์ ์ธ ๊ธ์๊ฐ ๋ช ๋ฒ ๋์ค๋์ง ์ธ๋ ํจ์๋ค.
'๐ง CodingTest' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ๋ฆฌ์คํธ์ ๋ฐฐ์ด (3) | 2025.06.28 |
---|---|
[Python] CodeUp ๊ธฐ์ด 100์ _ 6096 : ๋ฐ๋์ ์ญ์ ๋ค์ง๊ธฐ (1) | 2025.06.27 |
[Python] CodeUp ๊ธฐ์ด 100์ _ 6083, 6089, 6091, 6092, 6093 (0) | 2025.06.12 |
[Python] CodeUp ๊ธฐ์ด 100์ _ 6033, 6042, 6048, 6054, 6059 (0) | 2025.06.11 |
[Python] CodeUp ๊ธฐ์ด 100์ _ 6027, 6028, 6029, 6030, 6031 (0) | 2025.05.12 |