<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(self, question_text, question=None):
 """Ask Watson a question via the Question and Answer API :param question_text: question to ask Watson :type question_text: str :param question: if question_text is not provided, a Question object representing the question to ask Watson :type question: WatsonQuestion :return: Answer """

        if question is not None:
            q = question.to_dict()
        else:
            q = WatsonQuestion(question_text).to_dict()
        r = requests.post(self.url + '/question', json={'question': q}, headers={
            'Accept': 'application/json',
            'X-SyncTimeout': 30
        }, auth=(self.username, self.password))
        try:
            response_json = r.json()
        except ValueError:
            raise Exception('Failed to parse response JSON')
        return WatsonAnswer(response_json)