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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started