Find the highest response time
Problem statement
You collected response times in milliseconds from a load test: times = [120, 340, 95, 410, 230]. Print the slowest and the fastest time on two lines: Slowest: 410 ms and Fastest: 95 ms.
Examples
Example 1
Input: times = [120, 340, 95, 410, 230]
Output: Slowest: 410 ms
Fastest: 95 ms
Hints
Approach
Optimal
The built-in functions max() and min() take a list and return its largest and smallest values, which is the simplest correct solution. It is still worth knowing how they work: start with slowest = times[0], loop over the list, and whenever a value is bigger than slowest, replace it. That "best so far" pattern is how you find things max() cannot do directly, such as the name of the slowest server. The solution uses the built-ins and prints each result with its unit.
times = [120, 340, 95, 410, 230] print(f"Slowest: {max(times)} ms")print(f"Fastest: {min(times)} ms")Follow-up questions
- Print how many times were above 300 ms.
- Write the maximum-finding loop yourself without
max().
Frequently asked questions
max([]) raises ValueError. If the list might be empty, check if times: first, or use max(times, default=0).
Averages hide outliers. A few very slow requests can hurt users even when the average looks fine, which is why SRE teams track high percentiles and maximums.