Question: Functions Write a Python program that implements the algorithm given below. This program takes the details of road accidents at a location and finds whether

Functions Write a Python program that implements the algorithm given below. This program takes the details of road accidents at a location and finds whether it is an accident hotspot.

Main program 1) Start 2) Input avg_accident_rate 3) Input stdev_accident_rate 4) Input number of accidents: n_acc 5) Input traffic volume: traffic 6) Find accident rate: call function: rate=findRate(n_acc, traffic) 7) If rate>=0.5, find whether this is accident hotspot; call function isHotspot(avg_accrate,stdev_accrate,rate) 8) end

Function: isHotspot(avg_accrate,stdev_accrate,rate) 1)start 2)cutoff=avg_accrate+1.645*stdev_accrate 3)if rate>=cutoff then print Hotspot, return True else print not a Hotspot, return False 4)end Function findRate(n,trVol) 1)start 2)rate=n/trVol*1000 3)return rate 4)end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!