Skip to main content

Module to display dynamic quizzes in Jupyter notebooks and Jupyter Books. Uses JavaScript to provide

Project description

JupyterQuiz

JupyterQuiz is a tool for displaying interactive self-assessment quizes in Jupyter notebooks and Jupyter Book. These animated GIFs illustrate the two basic question types:

Many Choice Question

Example many-choice question using JupyterQuiz.


Numerical Answer Question

Example numerical answer question using JupyterQuiz.


For more examples with various types of functionality, check out the Review section of Chapter 3 of the Introduction to Data Science for Engineers Jupyter Book:

Example of JupyterQuiz in Action

The notebook test.ipynb shows more features but must be run on your own local Jupyter or in nbviewer -- GitHub only renders the static HTML that does not include the interactive quizzes. (If viewing on GitHub, there should be a little circle with a minus sign at the top of the file that offers you the ability to launch the notebook in nbviewer.)

It currently supports two types of quiz questions:

  1. Multiple/ Many Choice Questions: Users are given a predefined set of choices and click on answer(s) they believe are correct.
  2. Numerical: Users are given a text box in which they can submit answers in decimal or fraction form.

Each type of question offers different ways to provide feedback to help users understand what they did wrong (or right). Questions can be written as JSON or loaded from a dictionary in Python.

Multiple/Many Choice Questions

Multiple/Many Choice questions are defined by a Question, an optional Code block, and a list of possible Answers. Answers include a text component and/or a code block, details on whether the Answer is correct, and Feedback to be displayed for that Answer. The schema for Multiple/Many Choice Questions is shown below: Schema for Multiple/Many Choice Questions in JupyterQuiz

* = Required parameter, (+) = At least one of these parameters is required

Example JSON for a many-choice question is below:

  {
        "question": "Choose all of the following that can be included in Jupyter notebooks?",
        "type": "many_choice",
        "answers": [
            {
                "answer": "Text and graphics output from Python",
                "correct": true,
                "feedback": "Correct."
            },
            {
                "answer": "Typeset mathematics",
                "correct": true,
                "feedback": "Correct."
            },
            {
                "answer": "Python executable code",
                "correct": true,
                "feedback": "Correct."
            },
            {
                "answer": "Formatted text",
                "correct": true,
                "feedback": "Correct."
            },
            {
                "answer": "Live snakes via Python",
                "correct": false,
                "feedback": "I hope not."
            }
        ]
    }

Numerical Questions

Numerical questions consist of a Question, an optional Precision, and one or more Answers. Each Answer can be a Value, a Range, or the Default, and each of these can include Feedback text. Values and Ranges can be marked as correct or incorrect. Ranges are in the form [A,B), where endpoint A is included in the range and endpoint B is not included in the range. When Precision is specified, numerical inputs are rounded to the specified precision before comparing to the Answers. The schema for Numerical questions is shown below:

Schema for Numerical Questions in JupyterQuiz

* = Required parameter

Example JSON for a numerical question is below:

  {
        "question": "Enter the value of pi (will be checked to 2 decimal places):",
        "type": "numeric",
        "precision": 2,
        "answers": [
            {
                "type": "value",
                "value": 3.14,
                "correct": true,
                "feedback": "Correct."
            },
            {
                "type": "range",
                "range": [ 3.142857, 3.142858], 
                "correct": true,
                "feedback": "True to 2 decimal places, but you know pi is not really 22/7, right?"
            },
            {
                "type": "range",
                "range": [ -100000000, 0], 
                "correct": false,
                "feedback": "pi is the AREA of a circle of radius 1. Try again."
            },
            {
                "type": "default",
                "feedback": "pi is the area of a circle of radius 1. Try again."
            }
        ]
    }

If you find this useful... Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterquiz-1.3.2.tar.gz (496.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterquiz-1.3.2-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file jupyterquiz-1.3.2.tar.gz.

File metadata

  • Download URL: jupyterquiz-1.3.2.tar.gz
  • Upload date:
  • Size: 496.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for jupyterquiz-1.3.2.tar.gz
Algorithm Hash digest
SHA256 87d69f52d4536a3da4f6fb00258a90b624c497193b2b54a2c94a9de6ba7c15be
MD5 63b53f897798da46ac29c127fd31d006
BLAKE2b-256 c1ea75a44138fc68070db0f336dbc4bbd295a111c1741c7756a8d889ccf17603

See more details on using hashes here.

File details

Details for the file jupyterquiz-1.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: jupyterquiz-1.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for jupyterquiz-1.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0de5b2069aff696192502a044198a98b0c5516750898551252250ceb8fbca1d8
MD5 3515b2b9242c639074639129a7e17d6a
BLAKE2b-256 3410c31254c67d697404d0a0d08fd4e857e11e695d5746f6a1bdb906ad345bde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page