YZ ZONE

2단계 if문 본문

코테/BAEKJOON (Python 3)

2단계 if문

러블리YZ 2022. 1. 21. 21:41

1. 두 수 비교하기

A, B= map(int, input().split())
if A > B :
    print(">")
if A < B :
    print("<")
if A == B :
    print("==")

2. 시험성적

score = int(input())
if 90 <= score <= 100 :
    print ("A")
if 80 <= score < 90 :
    print ("B")
if 70 <= score < 80 :
    print ("C")
if 60 <= score < 70 :
    print ("D")
if score < 60 :
    print ("F")

3. 윤년

y = int(input())
if y%4==0 and y%100!=0 or y%400==0 :
    print ("1")
else:
    print("0")

4. 사분면 고르기

x = int(input())
y = int(input())
if x > 0 and y > 0 :
    print ("1")
if x < 0 and y > 0 :
    print ("2")
if x < 0 and y < 0 :
    print ("3")
if x > 0 and y < 0 :
    print ("4")

5. 알람 시계

H, M= map(int, input().split())
if M > 44 :
    print(H, M-45) # 분에서 -45분
elif M < 45 and H>0:
    print (H-1, M+15) #시간에서 45분 뺴고 남은 분 더하기
else :
    print (23, M+15) # 0시 일 때

'코테 > BAEKJOON (Python 3)' 카테고리의 다른 글

1단계 입출력과 사칙연산  (0) 2022.01.15