-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created example of times table sheet generator
- Loading branch information
Janis Lesinskis
committed
Oct 3, 2017
1 parent
e055c67
commit 68ef676
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
examples/elementary_mathematics_examples/multiplication_worksheets.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Example quiz containing elementary multiplication exercies. | ||
""" | ||
|
||
import random | ||
|
||
import jinja2 | ||
|
||
from quiz_generator.ranged_question import RangedQuestion | ||
from quiz_generator.input_variation import Variation | ||
from quiz_generator.quiz import Quiz | ||
|
||
# 3 times tables questions | ||
|
||
inputs = {"x": Variation(random.sample(range(15), 5))} | ||
|
||
def multiplication_answer_function(input_values): | ||
return {"answer": 3 * input_values['x']} | ||
|
||
three_times_questions = RangedQuestion( | ||
question_template=jinja2.Template("3 \\times {{x}} = ?"), | ||
answer_template=jinja2.Template("{{answer}}"), | ||
inputs=inputs, | ||
answer_generation_function=multiplication_answer_function | ||
) | ||
|
||
quiz_version1 = Quiz( | ||
questions=three_times_questions.create_all_questions(), | ||
quiz_name="Three times table quiz", | ||
quiz_version="1", | ||
preamble="Questions to test your three times tables", | ||
) | ||
|
||
print(quiz_version1.render()) | ||
print(quiz_version1.create_marking_sheet()) |