Skip to main content
3 of 3
fix logic error (re-read question)

This python function implements the logic you described in your question:

def calculate_X(A,B,C,D):
    if A == 0 and B == 0:
        X = calculation_1(A,B,C,D)
        
    elif A == 0 and B != 0 and C != 0 and D != 0:
        X = calculation_2(A,B,C,D)
        
    elif B == 0 and A != 0 and C != 0 and D != 0:
        X = calculation_3(A,B,C,D)
        
    else:
        X = calculation_4(A,B,C,D)

    return X

Then access the function using the expression

calculate_X(!A!, !B!, !C!, !D!)

It is a little unclear based on the question whether the values of "C" and "D" should be tested for calculations 2 and 3 (since they are not tested for calculation 1). If "C" and "D" should not be tested, then just use A == 0 and B != 0 instead of A == 0 and B != 0 and C != 0 and D != 0