ReadingBat Python content repository — Python programming challenges served via a Kotlin-based ReadingBat server. Students solve challenges in the browser; the server evaluates answers by running the Python functions against test cases defined in each file's main().
Two-language system: Kotlin defines and serves challenges; Python files are the challenges.
Challenges are registered two ways:
- Individually:
challenge("name") { returnType = ReturnType.BooleanType }— explicit per-file - Bulk via glob:
includeFilesWithType = "pattern*.py" returns ReturnType.Type— auto-includes matching files
Return types (referenced via the ReturnType enum): BooleanType, StringType, IntType, BooleanListType, IntListType, StringListType. Content.kt imports ReturnType directly rather than wildcard-importing its members, so always qualify (e.g., ReturnType.IntType) when adding entries.
Source switching: Production reads from GitHub (GitHubRepo); development reads from local filesystem (FileSystemSource), controlled by isProduction().
The main() prints define the test cases — each print() call produces an expected answer that the server checks against student submissions.
Run make help for a self-documenting list of the build, test, lint, run, and packaging targets.
.gitattributes normalizes line endings on commit: LF for *.py, *.sh, and gradlew; CRLF for *.bat. Write new challenge files with LF and let Git handle the rest — do not hand-convert.
- Create
python/<group_dir>/challenge_name.pyfollowing the file pattern above - Register in
Content.kt— either add achallenge()call or ensure filename matches an existingincludeFilesWithTypeglob (qualify return types asReturnType.IntType, etc.) - The return type in
Content.ktmust match what the Python function actually returns - Run
make lintto catch style issues, thenmake teststo verify the challenge works end-to-end