[백준/파이썬] 6763번 Speed fines are not fine! 풀이

업데이트:



문제 정보


풀이

문제

제한 속도와 실제 속도를 비교해 과속 벌금 메시지 또는 정상 주행 메시지를 출력하는 문제입니다.

코드

a, b = int(input()), int(input())

def fine(a, b):
    if b - a <= 20: return 100
    if b - a <= 30: return 270
    return 500

print(f'You are speeding and your fine is ${fine(a, b)}.' if a < b else 'Congratulations, you are within the speed limit!')

설명

b-a 초과 구간에 따라 벌금을 계산하고, 과속 여부에 맞는 문장을 출력합니다.



댓글남기기