포스트

[Python] 백준 2753번 - 윤년

Python 논리 연산자 or 및 and 활용, Java 및 C와의 논리 연산자 차이 비교

For the English version of this post, see here.
[Python] 백준 2753번 - 윤년

BaekJoon 2753

풀이

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

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

Python에서는 Java나 C와 달리, ||&& 연산자를 orand로 사용해야한다.

댓글

궁금한 점, 피드백, 오류 제보를 남겨 주세요.