Challenge - 5 Problems
SLA and Uptime Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Calculate uptime percentage from logs
Given a list of service status logs with timestamps and status ("up" or "down"), what is the output of the following code that calculates the uptime percentage?
Rest API
logs = [
{"timestamp": "2024-06-01T00:00:00Z", "status": "up"},
{"timestamp": "2024-06-01T01:00:00Z", "status": "down"},
{"timestamp": "2024-06-01T02:00:00Z", "status": "up"},
{"timestamp": "2024-06-01T03:00:00Z", "status": "up"}
]
up_count = sum(1 for log in logs if log["status"] == "up")
total = len(logs)
uptime_percentage = (up_count / total) * 100
print(f"Uptime: {uptime_percentage:.2f}%")Attempts:
2 left
💡 Hint
Count how many logs have status 'up' and divide by total logs.
✗ Incorrect
There are 3 logs with status 'up' out of 4 total logs, so uptime is (3/4)*100 = 75.00%.
🧠 Conceptual
intermediate1:30remaining
Understanding SLA breach conditions
Which of the following conditions correctly describes when an SLA breach occurs for a service with 99.9% uptime guarantee over a 30-day period?
Attempts:
2 left
💡 Hint
Calculate allowed downtime as 0.1% of total minutes in 30 days.
✗ Incorrect
30 days = 43200 minutes. 0.1% downtime allowed = 43.2 minutes. Exceeding this breaches SLA.
🔧 Debug
advanced2:00remaining
Identify the error in uptime calculation code
What error does the following code produce when calculating uptime percentage from a list of status logs?
Rest API
logs = [
{"timestamp": "2024-06-01T00:00:00Z", "status": "up"},
{"timestamp": "2024-06-01T01:00:00Z", "status": "down"}
]
up_count = sum(1 for log in logs if log.status == "up")
total = len(logs)
uptime_percentage = (up_count / total) * 100
print(f"Uptime: {uptime_percentage:.2f}%")Attempts:
2 left
💡 Hint
Check how dictionary keys are accessed in Python.
✗ Incorrect
Dictionaries use bracket notation with keys as strings, not dot notation.
📝 Syntax
advanced1:30remaining
Find the syntax error in SLA JSON response
Which option contains a syntax error in this JSON response representing SLA status?
Rest API
{
"service": "API",
"uptime": 99.95,
"status": "up",
"last_downtime": null
}Attempts:
2 left
💡 Hint
Check for trailing commas in JSON objects.
✗ Incorrect
JSON does not allow trailing commas after the last key-value pair.
🚀 Application
expert3:00remaining
Calculate monthly SLA uptime from daily logs
Given daily uptime percentages for a 30-day month, which option correctly calculates the overall monthly uptime percentage?
Rest API
daily_uptimes = [99.9, 100, 99.8, 99.7, 100, 99.9, 99.95, 100, 99.85, 99.9, 100, 99.9, 99.8, 99.7, 100, 99.9, 99.95, 100, 99.85, 99.9, 100, 99.9, 99.8, 99.7, 100, 99.9, 99.95, 100, 99.85] # Calculate monthly uptime here
Attempts:
2 left
💡 Hint
Monthly uptime is the product of daily uptimes as fractions, not the average.
✗ Incorrect
To get overall uptime, multiply daily uptime fractions, then convert back to percentage.