Alerts Calculation in Python Assignment Answers
Your question:
1. Threshold Alerts
A compliance system monitors incoming and
outbound calls. It sends an alert whenever the
average number of calls over a trailing number of
minutes exceeds a threshold. If the number of trailing
minutes to consider, precedingMinutes = 5, at time T,
take the average the call volumes for times T-(5-1), T-
(5-2)...T-(5-5).
Example
n = 8
numCalls = [2, 2, 2, 2, 5, 5, 5, 8]
alertThreshold = 4
precedingMinutes = 3
No alerts are sent until at least T = 3 because there
are not enough values to consider. When T = 3, the
average calls = (2+2+2)/3 = 2. Additionally, average
calls from T=3 to 8 are 2, 2, 3, 4, 5, and 6. A total
of two alerts are sent during the last two
periods. Given the data as described, determine the
number of alerts sent by the end of the timeframe.
Function Description
Complete the numberOfAlerts function in the editor
below. It should return an integer that represents the
number of alerts sent over the timeframe.
numberOfAlerts has the following parameter(s):
int preceding Minutes: the trailing number of
minutes to consider

Assignment Help Answers with Step-by-Step Explanation:
alerts = 0 # Initialize the alert count to 0
window_sum = sum(numCalls[:precedingMinutes]) # Initialize the sum of the first precedingMinutes values
if average > alertThreshold:
alerts += 1
n = 8
numCalls = [2, 2, 2, 2, 5, 5, 5, 8]


