-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiplication.py
53 lines (38 loc) · 1.17 KB
/
multiplication.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys
import htmlcreator
from equation import Equation
from operation import Operation
from random import sample
from promptuser import PromptUser
"""print list of 12 times table"""
print("\n\n")
prompter = PromptUser()
prompter.test_yaml()
options = prompter.prompt()
LHS_LIST = list(range(options.lhs_min, options.lhs_max+1))
RHS_LIST = list(range(options.rhs_min, options.rhs_max+1))
OPERATION = options.operation
NUMBER_OF_QUESTIONS = options.number_of_questions
def ordered_question_list(lhs, rhs):
"""take the lhs and rhs and produce an ordered list of questions"""
result = []
for l_n in lhs:
for r_n in rhs:
result.append(Equation(l_n, OPERATION, r_n))
return result
def print_list(questions):
"""Create html table"""
for q_item in questions:
print(q_item)
return
question_list = ordered_question_list(LHS_LIST, RHS_LIST)
random_index = list(range(0,len(question_list)))
random_index = sample(random_index, len(random_index))
result = []
for i in range(0,NUMBER_OF_QUESTIONS):
index = random_index[i%len(random_index)]
question = question_list[index]
result.append(question)
f = open("results.html", "w")
f.write(htmlcreator.create_html(result))
f.close()