summaryrefslogtreecommitdiff
path: root/python/problems/introduction/pythagorean_theorem/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/introduction/pythagorean_theorem/common.py')
-rw-r--r--python/problems/introduction/pythagorean_theorem/common.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/python/problems/introduction/pythagorean_theorem/common.py b/python/problems/introduction/pythagorean_theorem/common.py
index d11dae0..ed49b1a 100644
--- a/python/problems/introduction/pythagorean_theorem/common.py
+++ b/python/problems/introduction/pythagorean_theorem/common.py
@@ -23,7 +23,8 @@ hint_type = {
'unsupported_operand': Hint('unsupported_operand'),
'no_input_call' : Hint('no_input_call'),
'printing': Hint('printing'),
- 'math_functions': Hint('math_functions')
+ 'math_functions': Hint('math_functions'),
+ 'final_hint': Hint('final_hint')
}
def test(python, code):
@@ -55,7 +56,7 @@ def test(python, code):
n_correct = 0
tin = None
for i, (output, correct) in enumerate(zip(outputs, test_out)):
- if string_almost_equal(output, float(correct)):
+ if string_almost_equal(output, float(correct), prec=2):
n_correct += 1
else:
tin = test_in[i][1]
@@ -65,6 +66,8 @@ def test(python, code):
hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
if tin:
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
return passed, hints
def hint(python, code):
@@ -85,7 +88,7 @@ def hint(python, code):
# if input is not present in code, student needs to learn about input
if not has_token_sequence(tokens, ['input']) or \
- not has_token_sequence(tokens, ['float']) or \
+ (not has_token_sequence(tokens, ['float']) and not has_token_sequence(tokens, ['int'])) or \
not has_token_sequence(tokens, ['=']):
return [{'id': 'no_input_call'}]