Single choice question

This functionality allows to ask a single choice question. It requires a question, the alternatives and the (unique) answer. Optionally, the texts for success, error and button can be customized.

single_choice(question, options, answer_index, success='Correct answer', error='Wrong answer', button='Check answer')

Renders a single-choice question from arguments.

Parameters:
  • question (str) – question to be displayed before the single-choice options

  • options (str) – list of options to be displayed.

  • answer (int) – index (starting at 0) of the expected answer to the question

  • success (str, optional) – message to be displayed when the user answers correctly

  • error (str, optional) – message to be displayed when the user answers incorrectly

  • button (str, optional) – message to be displayed on the button that checks the answer

Returns:

tuple of booleans with button press status and correctness of answer

Return type:

tuple of bool