[Baekjoon] #6763 (Speed fine is not fine!)

REi·2024년 12월 20일

Baekjoon 브론즈 IV

목록 보기
23/28

> 문제


> 핵심내용

  • 범위 조건식
    x <= y <= z
    첫 번째 조건이 참이어야 두 번째 조건도 평가됨.

    -20 <= condition <= -1
    음수인것을 까먹었음 ㅎㅎ;;

> 결과

> 결과 코드

# 백준 브론즈 4 #6763

# 1 ~ 20 ==> 100불, 21 ~ 30 ==> 270, 31 ~ ==> 500불

# Limit 속도 제한 입력
Limit = int(input())

# Your_Speed 차량의 기록된 속도 입력 
Your_Speed = int(input())

# print(Limit,Your_Speed)

Fine = 0
condition = Limit - Your_Speed

if condition >= 0 :
    print("Congratulations, you are within the speed limit!")
else :
    # 범위 조건식 !!! x <= y <= z  첫 번째 조건이 참이어야 두 번째 조건도 평가됨 
    if -20 <= condition <= -1 :
        Fine = 100
    elif -30 <= condition <= -21 :
        Fine = 270
    elif condition <=  31   :
        Fine = 500

    print(f"You are speeding and your fine is ${Fine}.") # 출력 .format

0개의 댓글