✔ 1330 (두 수 비교하기)
👍 나의 코드 결과
a,b = map(int, input().split())
# 두 수를 입력받을 때, 가운데 공백을 포함한 하나의 문자열로 입력받자 (split함수)
# map 함수를 이용해 split 함수로 나눈 두개의 문자를 int타입으로 변환 시키자
if a > b:
print(">") # if 조건식이 참일때 리턴
elif a < b:
print("<") # if 조건식이 참이 아닌경우 elif 조건식이 참일때 리턴
else :
print("==") # 위 모든 조건식이 거짓일 때 리턴
✔ 9498 (시험 성적)
👍 나의 코드 결과
cnt = int(input())
if cnt >= 90 and 100:
print ("A")
elif cnt >= 80 and 89:
print ("B")
elif cnt >= 70 and 79:
print ("C")
elif cnt >= 60 and 69:
print ("D")
else:
print("F")
🙌 다른 방법
cnt = int(input())
if 90 <= cnt <= 100:
print ("A")
elif 80 <= cnt <= 89:
print ("B")
elif 70 <= cnt <= 79:
print ("C")
elif 60 <= cnt <= 69:
print ("D")
else:
print("F")
✔ 2753 (윤년)
👍 나의 코드 결과
years = int(input())
if years % 4 == 0 and years % 100 !=0:
print ("1")
elif years % 4 == 0 and years % 400 == 0:
print ("1")
else:
print("0")
🙌 다른 방법
years = int(input())
# 공통조건이면 ( ) 로 묶어서 출력하자!
if (years % 4 == 0 and years % 100 != 0) or years % 400 == 0:
# 꼭 문자열로 출력받지 않아도 된다.
print(1)
else:
print(0)
✔ 14681 (사분면 고르기)
👍 나의 코드 결과
x = int(input())
y = int(input())
if x > 0 and y > 0:
print(1)
elif x < 0 and y > 0:
print(2)
elif x < 0 and y < 0:
print(3)
else:
print(4)
🙌 다른 방법
a = int(input())
b = int(input())
if(a > 0):
if(b > 0):
print(1)
else:
print(4)
else:
if(b > 0):
print(2)
else:
print(3)
✔ 2884 (알람시계)
😢 나의 코드 결과 (1 오답)
H,M = map(int, input().split())
if 0 < (M-45) <= 59:
print(H, M-45)
elif H == 0:
print(23, M+15)
else:
print(H-1, M+15)
👍 나의 코드 결과
H,M = map(int, input().split())
if M >= 45:
print(H, M-45)
elif M < 45 and H >= 1:
print(H-1, M+15)
else:
print(23,M+15)
🙌 다른 방법
H, M = map(int, input().split())
if M < 45:
hour = H-1
minute = M+15
if H == 0:
hour=23
print(hour,minute)
elif M >= 45:
minute = M - 45
print(H,minute)
'|Developer_Study > Python' 카테고리의 다른 글
백준 _ for문 (0) | 2021.05.20 |
---|---|
백준 _ 입출력과 사칙연산 (0) | 2021.05.10 |
210501_프로그래머스 Lv1 수포자 (0) | 2021.05.01 |
210429_클래스 4-2 (0) | 2021.04.30 |
210415_ 시계열 데이터란? (1) | 2021.04.15 |
댓글