-
Notifications
You must be signed in to change notification settings - Fork 1
/
module4_question_text_generation.py
29 lines (22 loc) · 1.33 KB
/
module4_question_text_generation.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
def get_question_text(formula_identifiers,identifier_values):
"""Get question text from identifier names, symbols, and units."""
# Get identifier information (name,symbol,value,unit)
identifier_information = []
for identifier_index in range(len(formula_identifiers)):
identifier_name = formula_identifiers[identifier_index][1]
identifier_symbol = formula_identifiers[identifier_index][0]
identifier_unit = formula_identifiers[identifier_index][2]
identifier_value = str(identifier_values[identifier_index])
identifier_information.append((identifier_name,identifier_symbol,identifier_value,identifier_unit))
# Generate question text
# Left-hand side identifiers
left_hand_side_identifier = identifier_information[0]
question_text = 'What is the '
question_text += ' '.join([left_hand_side_identifier[1],left_hand_side_identifier[0]]) + ', given '
# Right-hand side identifiers
right_hand_side_identifiers = identifier_information[1:]
for right_hand_side_identifier in right_hand_side_identifiers:
question_text += right_hand_side_identifier[1] + ' ' + right_hand_side_identifier[0] + ' = ' + str(right_hand_side_identifier[2]) + ' ' + right_hand_side_identifier[3] + ', '
# Finalize
question_text = question_text[:-2] + ' ?'
return question_text