반응형
백준: 6763번 Speed fines are not fine! (Python3)
Speed fines are not fine! 성공다국어
시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 | 512 MB | 2113 | 1219 | 1141 | 58.483% |
문제
Many communities now have “radar” signs that tell drivers what their speed is, in the hope that they will slow down.
You will output a message for a “radar” sign. The message will display information to a driver based on his/her speed according to the following table:
km/h over the limit | Fine |
1 to 20 | $100 |
21 to 30 | $270 |
31 or above | $500 |
입력
The input will be two integers. The first line of input will be speed limit. The second line of input will be the recorded speed of the car.
출력
If the driver is not speeding, the output should be:
Congratulations, you are within the speed limit!
If the driver is speeding, the output should be:
You are speeding and your fine is $F.
where F is the amount of the fine as described in the table above.
예제 입력 1
100
131
예제 출력 1
You are speeding and your fine is $500.
예제 입력 2
40
39
예제 출력 2
Congratulations, you are within the speed limit!
예제 입력 3
100
120
예제 출력 3
You are speeding and your fine is $100.
답안
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
criteria = int(input())
mySpeed = int(input())
fine=0
pr = f'You are speeding and your fine is ${fine}.'
if mySpeed <= criteria:
print("Congratulations, you are within the speed limit!")
else:
if (mySpeed-criteria<=20):
fine = 100
pr = f'You are speeding and your fine is ${fine}.'
print(pr)
elif (mySpeed-criteria<=30):
fine = 270; pr = f'You are speeding and your fine is ${fine}.'
print(pr)
else:
fine = 500; pr = f'You are speeding and your fine is ${fine}.'
print(pr)
|
cs |
반응형
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 6778번 Which Alien? (Python3) (0) | 2022.08.03 |
---|---|
백준: 6764번 Sounds fishy! (Python3) (0) | 2022.08.03 |
백준: 6749번 Next in line (Python3) (0) | 2022.08.03 |
백준: 5928번 Contest Timing (Python3) (0) | 2022.08.03 |
백준: 9653번 스타워즈 로고 (Python3) (0) | 2022.08.03 |
댓글