Skip to main content
fix logic error (re-read question)
Source Link

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

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!)

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

fix logic error (re-read question)
Source Link

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!)

The if and elif conditions are tested in order from top to bottom, so there is no need to explicitly test e.g A == 0 and B != 0 for calculation_2 instead of just A == 0, because it is already certain at that point that A == 0 and B == 0 if False

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:
        X = calculation_2(A,B,C,D)
        
    elif B == 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!)

The if and elif conditions are tested in order from top to bottom, so there is no need to explicitly test e.g A == 0 and B != 0 for calculation_2 instead of just A == 0, because it is already certain at that point that A == 0 and B == 0 if False

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!)

Source Link

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:
        X = calculation_2(A,B,C,D)
        
    elif B == 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!)

The if and elif conditions are tested in order from top to bottom, so there is no need to explicitly test e.g A == 0 and B != 0 for calculation_2 instead of just A == 0, because it is already certain at that point that A == 0 and B == 0 if False