This course has already ended.

Exercises with Python grader utils

This chapter includes exercises that utilise the Python-grader-utils framework, which is recommended if you are creating Python exercises.

In this exercise you must implement a function hello that returns a string "Hello Python!".

The following is an example of a graderutils exercise, where the problem is to implement a simple prime number checker primes.is_prime. An incorrect solution can be found in, which is compared against the reference solution

Run the tests to get test results in JSON (use develop mode to generate all errors and warnings): python3 -m graderutils.main test_config.yaml --develop-mode > results.json Convert the JSON results into HTML: cat results.json | python3 -m graderutils_format.html --full-document > results.html You can now view results.html in a browser.

If you don’t want to render the base template, you can omit –full-document. This renders only the feedback body using the default feedback template.

In this exercise, you must implement the function is_prime that returns True if the argument (integer) is a prime number, False otherwise.

Paths to custom Jinja2 HTML templates that extend or replace the default template at graderutils_format/templates/feedback.html can be defined in the test_config.yaml as follows:

feedback_template: my_feedback_template.html

A+ presents the exercise submission form here.

The following example shows how to embed arbitrary JavaScript into the feedback template, and make data from grader tests available for the scripts.


You need to first install the plotting library used by this example: pip install -r requirements.txt

Then run the tests and render the results into HTML: python3 -m graderutils.main test_config.yaml --develop-mode | python3 -m graderutils_format.html --full-document > results.html You can now view results.html in a browser.

A container image with bokeh installed does not currently exist, so this exercise cannot be submitted.
Posting submission...