def get_param_value(mode, memory, ptr):
    """Returns the value of the parameter at memory[ptr] based on the mode"""
    # position mode
    if mode == 0:
        return memory[memory[ptr]]
    # immediate mode
    elif mode == 1:
        return memory[ptr]
    else:
        raise Exception