풀이 1 )
n = int(input("숫자입력: "))
for i in range(n,0,-1):
for j in range(1,i+1):
print(" "*(n-i),str(j),end="")
print()
풀이 2 )
n = int(input())
k = 2 * n - 1 if n < 10 else 17 + 3 * (n - 9)
for i in range(1, n + 1):
print((' '.join(map(str, range(1, i + 1)))).rjust(k))
풀이 3 )
number = int(input(''))
pnumber = 1
line = 1
space = number - line
space_ex = 0
while line <= number:
if space_ex == 0:
print(' '*space, end='')
space_ex = 1
space -= 1
elif pnumber == line:
print(pnumber)
line += 1
pnumber = 1
space_ex = 0
else:
print(pnumber, end=' ')
pnumber += 1
풀이 4 )
def num_tri(num):
num_line = ''
for i in range(1,num+1):
num_line = num_line + str(i)
print(num_line.rjust(num))
num = int(input())
num_tri(num)
'배운다 > 파이썬' 카테고리의 다른 글
148 : 반복제어문3 - 형성평가9 (0) | 2020.07.25 |
---|---|
147 : 반복제어문3 - 형성평가8 (0) | 2020.07.25 |
144 : 반복제어문3 - 형성평가5 (0) | 2020.07.25 |
143 : 반복제어문3 - 형성평가4 (0) | 2020.07.25 |
142 : 반복제어문3 - 형성평가3 (0) | 2020.07.25 |