def calculate_cycling_factor(
    quality_id: int,
    n_cycles: float,
) -> float:
    """Calculate the cycling factor (piCYC) for the relay.

    :param quality_id: the quality level identifier.
    :param n_cycles: the number of relay cycles per hour in application.
    :return: _pi_cyc; the calculated cycling factor.
    :rtype: float
    """
    if quality_id in {1, 2, 3, 4, 5, 6} and n_cycles < 1.0:
        return 0.1
    elif quality_id == 7 and n_cycles > 1000.0:
        return (n_cycles / 100.0) ** 2.0
    elif quality_id == 7 and 10.0 < n_cycles < 1000.0:
        return n_cycles / 10.0
    else:
        return 0.0