< 문제  2439 >


첫째 줄에는 별 1개, 둘째 줄에는 별 2개,  N번째 줄에는 별 N개를 찍는 문제.

단, 오른쪽 정렬로 출력한다.





< 2439 코드 >



1
2
3
4
n = int(input())

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


처음엔 print 함수에서 'sep' 파라미터를 안 쓰고 계속 오답 제출했다. 
공백을 지워주기 위해 'sep = ' ' 파라미터를 추가해야 함!


참고 : help(print) 


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
'''Help on built-in function print in module builtins:

print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
    
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.'''





< 문제 2753 > - 윤년

연도가 주어졌을 때 윤년이면 1, 아니면 0을 출력하는 프로그램을 작성하시오.

윤년은 연도가 4의 배수이면서, 100의 배수가 아닐 때 또는 400의 배수일 때다.

예로, 2012년은 4의 배수라서 윤년이지만, 1990년은 4의 배수이지만, 100의 배수이기 때문에 윤년이 아니다. 하지만, 2000년은 400의 배수이기 때문에 윤년이다.



< 코드 - 맞았습니다 ! > 

1
2
3
4
5
6
year = int(input())

if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
    print('1')
else:
    print('0')


참고 : 연산자들의 우선 순위








cf )


1
2
3
4
def actual_mind(x):
    print('이렇게 연습해서 어느 세월에 뭘 할 수 있을지 모르겠다 ^^',  '젠장 ^^' * x)

print(actual_mind(2))