Write a function which prints the fine for breaking traffic rules. The function should take two parameters: Speed and Helmet.
Input Format
helmet = 0 (worn)
helmet = 1 (not worn)
speed = 60 km/hr
Constraints
Speed limit = 60 km/hr
Rules:
1. If speed > speed limit and helmet is worn, then fine = Rs 1000;
2. If speed <= speed limit and helmet is not worn, then fine = Rs 2000;
3. If speed > speed limit and helmet is not worn, then fine = Rs 5000;
4. If speed <= speed limit and helmet is worn, then print 'No Fine'
Output Format
Fine: Rs 1000
(or)
No Fine
def traffic_rules(helmet, speed, speed_lim = 60):
if(helmet == 0 and speed > speed_lim):
print("Fine: Rs 1000")
if(helmet == 1 and speed <= speed_lim):
print("Fine: Rs 2000")
if(helmet == 1 and speed > speed_lim):
print("Fine: Rs 5000")
if(helmet == 0 and speed <= speed_lim):
print("No Fine")
traffic_rules(1, 61)
Comments
Leave a comment