Ask Question
12 July, 13:45

One thing we might want to know, given an input to a chatbot, is if the input is a question.

We are going to use a very simple heuristic to check this: we will consider any input that has a question mark ('?') in it to be a question.

To do so, write a function called is_question.

This function should have the following inputs, outputs, and internal procedures:

Input (s) : input_string - string

Output (s) : output - boolean

Procedure (s) : if there is a '?' in input_string, set output to True

otherwise, set output to False.

return output

+3
Answers (1)
  1. 12 July, 16:22
    0
    Following are the code to this question:

    def is_question (input_string) : # defining method is_question

    output = '?' in input_string # checking question mark symbol in value

    return output #return value

    input_string = input ('Enter any string value: ') # defining variable input_string to input value

    print (is_question (input_string)) # call method and print return value

    Output:

    Enter any string value: what is your name?

    True

    Explanation:

    In the given python program code, a method "is_question" is declared, which accepts an "input_string" value in its parameter.

    Inside the method, an output variable is used, that search question symbol in the parameter value and return its value. In the next step, the input_string variable is declared, which uses the input method to accepts string value and passes into method calling time and print its return value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “One thing we might want to know, given an input to a chatbot, is if the input is a question. We are going to use a very simple heuristic to ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers