Complete the code to define a risk monitoring function that logs risk status.
def monitor_risk(risk_level): if risk_level > 5: [1]("High risk detected")
The print function outputs the message to the console, which is suitable for simple risk monitoring logs.
Complete the code to check if the risk status is 'critical' and trigger an alert.
risk_status = 'critical' if risk_status == [1]: print('Alert: Critical risk!')
The code checks if risk_status equals the string 'critical' to trigger the alert.
Fix the error in the code to correctly update the risk level in the dictionary.
risk_data = {'level': 3}
risk_data['level'] [1] 7The single equals sign = assigns the value 7 to the key 'level'. Using == is a comparison, not assignment.
Fill both blanks to create a dictionary comprehension that filters risks with level greater than 4.
filtered_risks = {k: v for k, v in risks.items() if v [1] [2]The comprehension filters items where the value v is greater than 4.
Fill all three blanks to create a dictionary comprehension that converts risk names to uppercase and filters risks with level at least 3.
result = { [1]: [2] for [3] in risk_dict.items() if [2] >= 3 }The comprehension uses k.upper() as the key, v as the value, and iterates over k, v in risk_dict.items(). It filters values where v is at least 3.