-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efd5d9b
commit d413041
Showing
3 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
Empty file.
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,71 @@ | ||
import random | ||
|
||
|
||
def generate_question(): | ||
# generate required data | ||
k = random.randint(2, 4) # value of k, m and n | ||
|
||
# generate required content | ||
|
||
question_body = ( | ||
"Let $m \geq " | ||
+ str(k) | ||
+ "$ and $n \geq " | ||
+ str(k) | ||
+ "$ be integers. What does $${{m}\choose{" | ||
+ str(k) | ||
+ "}} + {{n}\choose{" | ||
+ str(k) | ||
+ "}} + m\cdot n$$ count?" | ||
) | ||
|
||
answer_options = [ | ||
"The number of ways to choose a subset from a set consisting of $m + n$ elements.", | ||
"The number of ways to choose an ordered pair of {} elements from a set consisting of $m + n$ elements.".format( | ||
k | ||
), | ||
"The number of ways to choose a {}-element subset from a set consisting of $m + n$ elements.".format( | ||
k | ||
), | ||
"None of the above.", | ||
] | ||
for answer in answer_options: | ||
if "-element" in answer: | ||
correct_answer = answer | ||
|
||
# return generated question | ||
return { | ||
"title": "set_theory_question", | ||
"body": question_body, | ||
"bodyFormat": "text", | ||
"pseudocode": "", | ||
"multipleChoiceAnswers": [ | ||
{ | ||
"body": answer_options[0], | ||
"bodyFormat": "mathjax", | ||
"correct": "true", | ||
}, | ||
{ | ||
"body": answer_options[1], | ||
"bodyFormat": "mathjax", | ||
"correct": "false", | ||
}, | ||
{ | ||
"body": correct_answer, | ||
"bodyFormat": "mathjax", | ||
"correct": "false", | ||
}, | ||
{ | ||
"body": answer_options[3], | ||
"bodyFormat": "mathjax", | ||
"correct": "false", | ||
}, | ||
], | ||
} | ||
|
||
|
||
def call(): | ||
return generate_question() | ||
|
||
|
||
print(call()) |
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