Skip to content

Python Reference

Codecov

These helpers are available in the Python environment when running a PrairieLearn question or element. They are organized by category. The most commonly used helpers are the grading, conversion, and question helpers.

Here are the recommended ways to import the helpers:

import prairielearn as pl
from prairielearn.colors import Y
from prairielearn.to_precision import Z
import prairielearn.sympy_utils as psu
More info

You can use the following import to access most of the helpers:

from prairielearn import ...

These modules must be imported directly:

from prairielearn.colors import Y
from prairielearn.to_precision import Z
from prairielearn.sympy_utils import Z

You should not directly import the remaining dotted modules (e.g. prairielearn.conversion_utils), as they do not have a stable interface.

Warning

The following imports are now deprecated. They will be removed in a future release. Please update your code to use the new imports

import colors
import to_precision
import python_helper_sympy
import prairielearn.colors
import prairielearn.to_precision
import prairielearn.sympy_utils

A collection of utilities for writing custom questions and elements in PrairieLearn.

Modules:

Name Description
misc_utils

Miscellaneous utilities.

sympy_utils

Utility functions for parsing and evaluating SymPy expressions.

extension_utils

Utilities for element extensions in PrairieLearn.

question_utils

Utilities for dealing with questions.

grading_utils

Utilities for grading in PrairieLearn.

conversion_utils

Utilities for converting and serializing between different data formats.

html_utils

Utilities for working with HTML elements. Used for reading attributes and sanitizing HTML.

colors

Custom colors for the PrairieLearn project based on Coloraide.