U E D R , A S I H C RSS

초코파이썬/시즌2/2강 (rev. 1.33)

초코파이썬/시즌2/2강


2. 진행

  • 장소 : 중앙도서관 3층 스터디룸1
  • 시간 : 9월 16일 20시 15분 ~ 22시

3. 내용

  • 공유 PPT
  • 지난 시간 복습
  • if, elif, else
  • for, while
  • 함수
  • 리스트 및 문자열 활용

4. 과제

4.1. 이길상

4.1.1. 별 찍기 - 6

a = int(input())
for i in range(a):
    for j in range(2*a-1-i) : 
        if j>=i :
            print('*', end='')
        else :
            print(' ', end='')
    print('')

4.1.2. 별 찍기 - 7

a = int(input())
for i in range(2*a-1):
    for j in range(2*a-1 - abs(i+1-a)) : 
        if (i+j)>(a-2) and (i-j)<a :
            print('*', end='')
        else :
            print(' ', end='')
    print('')

4.1.3. 별 찍기 - 8

a = int(input())
for i in range(2*a-1):
    for j in range(2*a) : 
        if abs(i+1-a) < abs(j+0.5-a) :
            print('*', end='')
        else :
            print(' ', end='')
    print('')

4.1.4. 별 찍기 - 9

a = int(input())
for i in range(2*a-1):
    for j in range(a + abs(a-i-1)) : 
        if abs(i+1-a) >= (a-j-1) :
            print('*', end='')
        else :
            print(' ', end='')
    print('')

4.2. 이호민

4.2.1. 별 찍기 - 6

#백준 2443번 별 찍기 - 6

a=int(input())
for i in range(2*a-1, 0, -2):
    for j in range(a-int(i/2)-1):
        print(' ', end='')
    for j in range(i):
        print('*', end='')
    print('')

4.2.2. 별 찍기 - 7

#백준 2444번 별 찍기 - 7

a=int(input())
for i in range(1, 2*a-1, 2):
    for j in range(a-int(i/2)-1):
        print(' ', end='')
    for j in range(i):
        print('*', end='')
    print('')

for i in range(2*a-1, 0, -2):
    for j in range(a-int(i/2)-1):
        print(' ', end='')
    for j in range(i):
        print('*', end='')
    print('')

4.2.3. 별 찍기 - 8

#백준 2445 별 찍기 - 8

n=int(input())
mid=2
def printstar(j):
    for i in range(j):
        print('*', end='')
def printspace(j):
    for i in range(j):
        print(' ', end='')
for i in range(1, 2*n):
    if i<=n:
        printstar(i)
        printspace(2*(n-i))
        printstar(i)
        print('')
    else:
        tmp=i-mid
        printstar(tmp)
        printspace(2*(n-tmp))
        printstar(tmp)
        print('')
        mid+=2

4.2.4. 별 찍기 - 9

#백준 2446 별 찍기 - 9

a=int(input())
for i in range(2*a-1, 0, -2):
    for j in range(a-int(i/2)-1):
        print(' ', end='')
    for j in range(i):
        print('*', end='')
    print('')
for i in range(3, 2*a+1, 2):
    for j in range(a-int(i/2)-1):
        print(' ', end='')
    for j in range(i):
        print('*', end='')
    print('')



4.3. 신연진

4.3.1. 별 찍기 - 6

n = int(input())
stars = 2 * n - 1
space = 0

for i in range(n):
    for j in range(space):
        print(' ', end='')
    for j in range(stars):
        print('*', end='')
    for j in range(space):
        print(' ', end='')
    print('\n', end='')
    stars -= 2
    space += 1

4.3.2. 별 찍기 - 7

n = int(input())

starModifier = 2
stars = 1
for i in range(2 * n - 1):
    space = (2 * n - 1 - stars) // 2
    for j in range(space):
        print(' ', end='')
    for j in range(stars):
        print('*', end='')
    for j in range(space):
        print(' ', end='')
    print('\n', end='')
    if stars == (2 * n - 1):
        starModifier = -starModifier
    stars += starModifier

4.3.3. 별 찍기 - 8

n = int(input())

starModifier = 1
stars = 1
for i in range(2 * n - 1):
    space = (n - stars) * 2
    for j in range(stars):
        print('*', end='')
    for j in range(space):
        print(' ', end='')
    for j in range(stars):
        print('*', end='')
    print('\n', end='')
    if stars == n:
        starModifier = -starModifier
    stars += starModifier

4.3.4. 별 찍기 - 9

n = int(input())

stars = 2 *n - 1
starModifier = -2
for i in range(2 * n - 1):
    space = (2 * n - 1 - stars) // 2
    for j in range(space):
        print(' ', end='')
    for j in range(stars):
        print('*', end='')
    for j in range(space):
        print(' ', end='')
    print('\n', end='')
    if stars == 1:
        starModifier = -starModifier
    stars += starModifier


4.4. 김희민

4.4.1. 별 찍기 - 6

def blank (n):
  for i in range (n):
    print(' ',end = "")


def point (n):
  for i in range (n):
    print('*',end='')

N = int(input())

for i in range(N):
    blank(i)
    point(2*N - (2*i +1))
    print()


4.4.2. 별 찍기 - 7

def blank (n):
  for i in range (n):
    print(' ',end = "")

def point (n):
  for i in range (n):
    print('*',end='')


N = int(input())

for i in range(N):
  blank(N - i - 1)
  point(2*i + 1)
  print()

for i in range(N-1):
  blank(i + 1)
  point(2*(N-1) - (2*i+1))
  print()

4.4.3. 별 찍기 - 8

def blank (n):
  for i in range (n):
    print(' ',end = '')

def point (n):
  for i in range (n):
    print('*',end='')


N = int(input())

for i in range(1,N+1):
  point(i)
  blank(2*N - 2*i)
  point(i)
  print()

for i in range(1,N):
  point(N - i)
  blank(2*i)
  point(N - i)
  print()


4.4.4. 별 찍기 - 9

def blank (n):
  for i in range (n):
    print(' ',end = '')

def point (n):
  for i in range (n):
    print('*',end='')


N = int(input())

for i in range(1,N+1):
  blank(i - 1)
  point(2*N - 2*i + 1)
  print()

for i in range(2,N+1):
  blank(N - i)
  point(2*i - 1)
  print()


4.5. 박예솔

4.5.1. 별 찍기 - 6

n = int(input())

for i in range(n):
    num = 2 * n - (i * 2 + 1)
    print(" " * i + "*" * num)

4.5.2. 별 찍기 - 7

n = int(input())

for i in range(1, n):
        print(" " * (n-i) + "*" * (2*i - 1))

for i in range(0, n):
        print(" " * i + "*" * (2*(n-i) - 1))

4.5.3. 별 찍기 - 8

여기에 코드 입력

4.5.4. 별 찍기 - 9

여기에 코드 입력

4.6. 이윤동

4.6.1. 별 찍기 - 6


n = int(input())


for i in range(n, 0, -1):

    for j in range(n-i):
        print(' ', end='')

    for j in range(i*2-1, 0, -1):
        print('*', end='')
    print("")


4.6.2. 별 찍기 - 7

n = int(input())


for i in range(1, n):

    for j in range(n-i):
        print(' ', end='')

    for j in range(i*2-1):
        print("*", end='')
    print(" ")


for i in range(n, 0, -1):

    for j in range(n-i):
        print(' ', end='')

    for j in range(i*2-1, 0, -1):
        print('*', end='')
    print("")


4.6.3. 별 찍기 - 8

n = int(input())


for i in range(2*n-1, 0, -1):

    # 위에서 반까지
    if(i >= n):
        c = 0
        for j in range(2*n - i):
            c = c+1
            print("*", end='')

        for j in range(2*n - 2*c):
            c = c+1
            print(' ', end='')
        for j in range(2*n - c):
            print('*', end='')
        print("")

    # 아래 부분
    else:
        c = 0
        for j in range(i):
            c = c+1
            print("*", end='')

        for j in range(2*n - 2*c):
            c = c+1
            print(' ', end='')

        for j in range(2*n - c):
            print('*', end='')
        print("")


4.6.4. 별 찍기 - 9

n = int(input())


for i in range(n, 0, -1):

    for j in range(n-i):
        print(' ', end='')

    for j in range(i*2-1, 0, -1):
        print('*', end='')
    print("")


for i in range(2, n+1):

    for j in range(n-i):
        print(' ', end='')

    for j in range(i*2-1):
        print("*", end='')
    print(" ")

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-16 14:08:00
Processing time 0.0305 sec