📖 Scenario: You are part of a software project team. You need to keep track of risks that might affect your project. Each risk has a description and a status showing if it is currently active or resolved.
🎯 Goal: Build a simple program to monitor risks by storing them, setting a threshold for active risks, filtering active risks, and displaying the active risks to help the team focus on important issues.
📋 What You'll Learn
Create a dictionary called risks with exact risk descriptions as keys and their status ('active' or 'resolved') as values.
Create a variable called active_threshold and set it to the number 2.
Use a dictionary comprehension to create a new dictionary called active_risks that contains only the risks with status 'active'.
Print the active_risks dictionary.
💡 Why This Matters
🌍 Real World
In real projects, teams track risks to avoid surprises. This simple program helps monitor which risks need attention.
💼 Career
Understanding how to organize and filter risk data is useful for project managers, DevOps engineers, and software team leads to keep projects on track.
Progress0 / 4 steps
1
Create the initial risk dictionary
Create a dictionary called risks with these exact entries: 'Server downtime': 'active', 'Data loss': 'resolved', 'Security breach': 'active', 'Budget overrun': 'resolved'.
Software Engineering
Hint
Use curly braces to create a dictionary. Each entry has a risk description as a string key and its status as a string value.
2
Set the active risk threshold
Create a variable called active_threshold and set it to the number 2.
Software Engineering
Hint
Just assign the number 2 to the variable named active_threshold.
3
Filter active risks using dictionary comprehension
Use a dictionary comprehension to create a new dictionary called active_risks that contains only the risks from risks where the status is 'active'.
Software Engineering
Hint
Use {key: value for key, value in risks.items() if value == 'active'} to filter active risks.
4
Display the active risks
Write a print statement to display the active_risks dictionary.
Software Engineering
Hint
Use print(active_risks) to show the filtered risks.
Practice
(1/5)
1. What is the main goal of risk monitoring and control in DevOps projects?
easy
A. To ignore risks until they cause problems
B. To create risks so the team can practice handling them
C. To document risks once at the start and never update
D. To continuously watch risks and act quickly to reduce their impact
Solution
Step 1: Understand risk monitoring purpose
Risk monitoring means watching risks regularly to see if they change or get worse.
Step 2: Identify the correct goal
The goal is to act fast to reduce risk impact, not ignore or create risks.
Final Answer:
To continuously watch risks and act quickly to reduce their impact -> Option D
Quick Check:
Risk monitoring = watch and act fast [OK]
Hint: Risk monitoring means watch and act fast, not ignore [OK]
Common Mistakes:
Thinking risk monitoring means ignoring risks
Believing risks should be created intentionally
Assuming risks are documented once and never updated
2. Which of the following commands is commonly used to check the status of running services for risk monitoring in a Linux environment?
easy
A. docker build
B. git commit
C. systemctl status
D. kubectl apply
Solution
Step 1: Identify commands related to service status
In Linux, systemctl status shows the current status of system services.
Step 2: Eliminate unrelated commands
git commit is for version control, docker build builds images, kubectl apply manages Kubernetes resources.
Final Answer:
systemctl status -> Option C
Quick Check:
Check service status = systemctl status [OK]
Hint: Use systemctl status to check Linux services quickly [OK]
Common Mistakes:
Confusing git commands with system monitoring
Using docker build instead of status commands
Mixing Kubernetes commands with local service checks
3. Given this snippet of a monitoring script output:
ALERT: Disk space usage at 92% on /dev/sda1
ACTION: Trigger cleanup script
STATUS: Cleanup completed successfully
ALERT: CPU usage at 85%
What is the next logical step in risk control?
medium
A. Ignore the CPU alert since cleanup was successful
B. Investigate and reduce CPU usage to prevent overload
C. Reboot the server immediately without checking
D. Delete all logs to free disk space
Solution
Step 1: Analyze the alerts and actions
The disk space alert was handled by cleanup successfully, but CPU usage is still high at 85%.
Step 2: Decide the correct risk control action
Ignoring CPU alert risks overload; rebooting immediately or deleting logs are extreme or unsafe actions.
Final Answer:
Investigate and reduce CPU usage to prevent overload -> Option B
Quick Check:
High CPU alert = investigate and reduce [OK]
Hint: Address each alert; don't ignore new ones after fixing old [OK]
Common Mistakes:
Ignoring new alerts after fixing previous ones
Taking drastic actions without investigation
Deleting logs which may be needed for diagnosis
4. You have a monitoring script that should alert when memory usage exceeds 80%, but it never triggers alerts even when usage is 90%. What is the most likely cause?
medium
A. The alert threshold is set incorrectly above 90%
B. The script is missing execution permissions
C. The monitoring tool is not installed
D. The server has no memory usage
Solution
Step 1: Check alert threshold settings
If alerts never trigger at 90%, the threshold might be set higher than 90%, so condition never met.
Step 2: Evaluate other options
Missing permissions or tool not installed would cause no script run or errors, not silent no alerts. Server always uses some memory.
Final Answer:
The alert threshold is set incorrectly above 90% -> Option A
Quick Check:
Alerts not triggering = check threshold settings [OK]
Hint: Check alert thresholds first if alerts never trigger [OK]
Common Mistakes:
Assuming script permission issues without checking thresholds
Thinking server can have zero memory usage
Ignoring tool installation status
5. In a DevOps pipeline, you want to implement risk monitoring that automatically pauses deployment if test failures exceed 5%. Which combination of tools and steps best achieves this?
hard
A. Use a CI tool with test reports and configure a gate to stop deployment on failure threshold
B. Manually check test logs after deployment and rollback if needed
C. Deploy first, then run tests and notify team by email only
D. Ignore test failures and deploy continuously without checks
Solution
Step 1: Identify automated risk monitoring needs
Automatic pause on failure requires integration of test results with deployment control.
Step 2: Choose correct tool and configuration
CI tools can generate test reports and enforce gates to stop deployment if failures exceed limits.
Final Answer:
Use a CI tool with test reports and configure a gate to stop deployment on failure threshold -> Option A
Quick Check:
Automate risk control = CI gate on test failures [OK]
Hint: Use CI gates to auto-stop deployment on test failures [OK]
Common Mistakes:
Relying on manual checks after deployment
Running tests post-deployment without blocking
Ignoring test failures completely
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.