Skip to main content
Mathematics LibreTexts

44.1: AnswerCheck tool

  • Page ID
    70566
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The jupytercheck Package is intended to provide students with immediate feedback to check answers inside of a Jupyter notebook. This was written with a Linear Algebra class in mind so it tries to do a robust comparison and take into consideration different object types as well as round off errors.

    It works by providing a function called answercheck that takes in a variable to be checked and a “hash” which is a one-way function encoding the answer. The program generates a new hash based on the input variable and compares the two hash values. An output is provided that the answer appears correct or incorrect.

    The program is also designed to run without installing anything in python. However, it does require the download of the correct file.

    Do This

    Two use answercheck we will need to download answercheck.py to your current working directory. You only really need to do this once. However, if you delete this file by mistake sometime during the semester, you can come back to this notebook and download it again by running the following cell:

    from urllib.request import urlretrieve
    
    urlretrieve('https://raw.githubusercontent.com/colbrydi/jupytercheck/master/answercheck.py', 
                'answercheck.py');

    Verify you have answercheck installed by running the following cell

    from answercheck import checkanswer
    checkanswer("Check Answer",'bd8337cd5327e54b2b4b15c6ec3703ed');
    Testing Check Answer
    Answer seems to be correct
    
    

    For more information about how answercheck works watch the following video:

    Direct Link to the Youtube video.

    from IPython.display import YouTubeVideo
    YouTubeVideo("d4a9Xag-yc8",width=640,height=320, cc_load_policy=True)
    Note

    Make sure you do not change the checkanswer commands. The long string with numbers and letters is the secret code that encodes the true answer. This code is also called the HASH. Feel free to look at the answercheck.py code and see if you can figure out how it works?


    This page titled 44.1: AnswerCheck tool is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?