def f1_score(precision: float, recall: float) -> float:
    """
    Calculates F1 score according to:

    .. math:: 2 (P*R)/(P+R)

    Parameters
    ----------
    precision
        Precision
    recall
        Recall

    Returns
    -------
    F1 score

    """
    try:
        return (precision * recall) / ((precision + recall) / 2)
    except ZeroDivisionError as err:
        return 0.