Computer Science/백준 (Python)

[2단계] 조건문

inee0727 2022. 5. 31. 16:01

 

1330번. 두 수 비교하기

 

 

▼해설보기

더보기

 

a, b = map(int, input().split())

if a>b:
    print('>')
elif a<b:
    print('<')
else:
    print('==')

 

def 는 사용자 정의 함수를 만들기 위해서 사용

만약 limit안에 들어간 숫자가 10000보다 크거나 -10000보다 작을 경우, 해당 변수에 값을 다시 받도록 코드 작성

 

9498번. 시험 성적

 

▼해설보기

더보기

방법 1

score = int(input())

if score == 100 or score >= 90 :
  print('A')
elif score >= 80 and score < 90 :
  print('B')
elif score >= 70 and score < 80 :      
  print('C')
elif score >= 60 and score < 70 : 
  print('D')  
else :
  print('F')

 

방법 2

score = int(input())

if score >= 90 :
  print('A')
elif 80 <= score < 90 :
  print('B')
elif 70 <= score < 80 :      
  print('C')
elif 60 <= score < 70 : 
  print('D')  
else :
  print('F')

 

2753번. 윤년

 

▼해설보기

더보기

 

year = int(input())

if year % 4 == 0 and (year % 100 != 0 or year % 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('4')
elif (x<0 and y>0):
    print('2')
elif( x< 0 and y<0):
    print('3')