📖 Scenario: You work for a company that provides online services. Your team needs to track the uptime of different services to make sure they meet the Service Level Agreement (SLA).Each service has a name and a list of uptime percentages recorded daily. You want to calculate which services meet the SLA threshold.
🎯 Goal: Build a simple program that stores uptime data for services, sets an SLA threshold, calculates which services meet the SLA, and prints the results.
📋 What You'll Learn
Create a dictionary with service names as keys and lists of daily uptime percentages as values
Create a variable for the SLA threshold percentage
Use a dictionary comprehension to find services that meet or exceed the SLA threshold on average
Print the dictionary of services that meet the SLA
💡 Why This Matters
🌍 Real World
Tracking uptime is important for companies to ensure their services are reliable and meet promised standards.
💼 Career
Many IT and DevOps roles require monitoring service performance and reporting SLA compliance.
Progress0 / 4 steps
1
Create the uptime data dictionary
Create a dictionary called services_uptime with these exact entries: 'Email': [99.9, 99.7, 99.8], 'Storage': [99.5, 99.6, 99.4], 'Chat': [99.8, 99.9, 99.7]
Rest API
Hint
Use curly braces to create a dictionary. Each key is a service name string, and each value is a list of floats.
2
Set the SLA threshold
Create a variable called sla_threshold and set it to 99.7
Rest API
Hint
Just create a variable and assign the number 99.7 to it.
3
Find services meeting the SLA
Use a dictionary comprehension to create a dictionary called services_meeting_sla that includes only services from services_uptime whose average uptime is greater than or equal to sla_threshold. Use sum() and len() to calculate the average uptime for each service.
Rest API
Hint
Use dictionary comprehension syntax: {key: value for key, value in dict.items() if condition}.
4
Print the services meeting SLA
Write a print() statement to display the services_meeting_sla dictionary.
Rest API
Hint
Use print(services_meeting_sla) to show the final dictionary.
Practice
(1/5)
1. What does SLA stand for in the context of uptime tracking?
easy
A. Service Level Agreement
B. System Log Analysis
C. Server Load Average
D. Standard Latency Assessment
Solution
Step 1: Understand SLA meaning
SLA is a contract that defines expected service performance and uptime.
Step 2: Match SLA to options
Only "Service Level Agreement" correctly describes this contract.
Final Answer:
Service Level Agreement -> Option A
Quick Check:
SLA = Service Level Agreement [OK]
Hint: Remember SLA means agreement on service quality [OK]
Common Mistakes:
Confusing SLA with system logs
Thinking SLA measures latency
Mixing SLA with server load
2. Which HTTP method is typically used to retrieve uptime data from a REST API?
easy
A. POST
B. DELETE
C. PUT
D. GET
Solution
Step 1: Identify REST API methods for data retrieval
GET method is used to request data without changing server state.
Step 2: Match method to uptime data retrieval
Since uptime data is fetched, GET is the correct method.