Skip to content

Commit 5660bc6

Browse files
committed
Speed limit
Signed-off-by: Brian342 <migelbrian3@gmail.com>
1 parent da8a4a4 commit 5660bc6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

if_set_1_5.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Write a program that can be used by a policeman to determine if a vehicle has exceeded the speed limit and to levy
2+
# a fine.The policeman should enter the vehicles speed and the speed limit.
3+
# If the speed limit is exceeded by less than 30kph a fine of Kshs.
4+
# 2500 should be charged. Otherwise, a fine of Kshs 4000 is charged.
5+
# Your program should then output (in a suitable format) the vehicle speed,
6+
# the speed limit, the excess speed and the fine levied.
7+
8+
vehicleSpeed = int(input("Enter the vehicle speed: "))
9+
speedLimit = int(input("Enter the speed limit: "))
10+
11+
excessSpeed = vehicleSpeed - speedLimit
12+
fineLevied = speedLimit + 30
13+
if speedLimit < vehicleSpeed < fineLevied:
14+
output = (f'The speed limit is: {speedLimit}, The VehicleSpeed is: {vehicleSpeed},The excessSpeed is:{excessSpeed},'
15+
f'Your fine will be 2500Kshs!')
16+
print(output)
17+
elif vehicleSpeed > fineLevied:
18+
output = (f'The speed limit is: {speedLimit}, The VehicleSpeed is: {vehicleSpeed},The excessSpeed is:{excessSpeed},'
19+
f'Your fine will be 4000Kshs!')
20+
print(output)
21+
else:
22+
print("you are traveling at the right speed have a safe journey!!!")
23+

0 commit comments

Comments
 (0)