Interactive Activities
There are different interactive activities to be used in your apps:
True or False question
This functionality allows to ask a true/false type of question. It requires a question and the solution as a True/False value. Optionally, the texts for success, error and button can be customized.
- true_or_false(question, answer, success='Correct answer', error='Wrong answer', button='Check answer')
Renders a true or false question from arguments.
- Parameters:
question (str) – question to be displayed before the true or false options
answer (str) – expected answer to the question, can be True or False
success (str, optional) – message to be displayed when the user answers correctly. If empty, no message is displayed.
error (str, optional) – message to be displayed when the user answers incorrectly. If empty, no message is displayed.
button (str, optional) – message to be displayed on the button that checks the answer
- Returns:
tuple of booleans(button_pressed, answer_correct) with the button status and correctness of answer
- Return type:
tuple of bool
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
Multiple choice question
This functionality allows to ask a multiple choice question. It requires a question, the alternatives and the answer(s). Optionally, the texts for success, error and button can be customized.
- multiple_choice(question, options_dict, success='Correct answer', error='Wrong answer', button='Check answer')
Render a multiple choice question from the given parameters.
- Parameters:
question (str) – question to be displayed before the multiple-choice options
options_dict – dictionary of options to be displayed, with the option text as key and the boolean answer as value
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
To do list
This functionality allows to create to-do list. It only has as optional argument the text for success.
- to_do_list(tasks, header='', success='Bravo!')
Renders the tasks as a to-do list, with optional header and success message. The tasks are a dictionary of tasks (supposed to be ordered as Python +3.6) with their completed (True) or to-do (False) status as a checkbox.
- Parameters:
tasks (dict) – dictionary of tasks in format string:bool
header (str, optional) – description of the tasks
success (str, optional) – success message
- Returns:
boolean with the exit status of the function
- Return type:
bool