<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ask(question, default_answer=False, default_answer_str="no"):
 """ Ask for user input. This asks a yes/no question with a preset default. You can bypass the user-input and fetch the default answer, if you set Args: question: The question to ask on stdout. default_answer: The default value to return. default_answer_str: The default answer string that we present to the user. Tests: True False """

    response = default_answer

    def should_ignore_tty():
        """
        Check, if we want to ignore an opened tty result.
        """
        ret_to_bool = {"yes": True, "no": False, "true": True, "false": False}
        envs = [os.getenv("CI", default="no"), os.getenv("TEST", default="no")]
        vals = [ret_to_bool[val] for val in envs if val in ret_to_bool]
        return any(vals)

    ignore_stdin_istty = should_ignore_tty()
    has_tty = sys.stdin.isatty() and not ignore_stdin_istty
    if has_tty:
        response = query_yes_no(question, default_answer_str)
    else:
        LOG.debug("NoTTY: %s -> %s", question, response)

    return response