본문 바로가기

코딩테스트/프로그래밍 기초 | 조건문

[코드트리] if else if else 조건문

두 숫자의 짝홀 여부

https://www.codetree.ai/missions/4/problems/parity-of-two-numbers?&utm_source=clipboard&utm_medium=text

i = input()
j = i.split(" ")
a = int(j[0])
b = int(j[1])

if a % 2 == 0:
    print("even")
else:
    print("odd")

if b % 2 == 0:
    print("even")
else:
    print("odd")

 

 

 

 

특정 조건 두 정수 비교

https://www.codetree.ai/missions/4/problems/specific-comparison-of-two-natural-numbers?&utm_source=clipboard&utm_medium=text

i = input()
j = i.split(" ")
a = int(j[0])
b = int(j[1])

if a < b:
    result1 = "1"
else:
    result1 = "0"

if a == b:
    result2 = "1"
else:
    result2 = "0"

print(result1, result2)

 

 

 

 

3 또는 5의 배수

https://www.codetree.ai/missions/4/problems/multiples-of-3-or-5?&utm_source=clipboard&utm_medium=text

a = int(input())

if a % 3 == 0:
    print("YES")
else:
    print("NO")

if a % 5 == 0:
    print("YES")
else:
    print("NO")