Skip to content
Iron Codex logoIRON-CODEXCYBERSECURITY
Cybersecurity › Security Fundamentals

Snippets

12 Controls
Copy-Paste Snippets
Python: Simple Risk Score Calculation
def calculate_risk_score(likelihood: int, impact: int) -> int:
    """
    Calculate the risk score based on likelihood and impact.
    Both should be an integer usually between 1-5.
    Returns: The final priority score.
    """
    score = likelihood * impact
    if score >= 15:
        return "CRITICAL"
    elif score >= 10:
        return "HIGH"
    elif score >= 5:
        return "MEDIUM"
    return "LOW"