diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-07 08:34:21 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-07 08:34:21 +0200 |
commit | a451016b9efa919d7564fc75ab812052d1cd25f5 (patch) | |
tree | e4312f6e27916b24c5734e16455acfa77bd2aab4 /python/problems/introduction/pythagorean_theorem | |
parent | 5a1b4202dfa99bb88fab6b1f23594bd2def811c6 (diff) |
Added final hints to ballistics and pythagorean.
Diffstat (limited to 'python/problems/introduction/pythagorean_theorem')
-rw-r--r-- | python/problems/introduction/pythagorean_theorem/common.py | 9 | ||||
-rw-r--r-- | python/problems/introduction/pythagorean_theorem/sl.py | 9 |
2 files changed, 14 insertions, 4 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'}] diff --git a/python/problems/introduction/pythagorean_theorem/sl.py b/python/problems/introduction/pythagorean_theorem/sl.py index b3424cb..21aec9a 100644 --- a/python/problems/introduction/pythagorean_theorem/sl.py +++ b/python/problems/introduction/pythagorean_theorem/sl.py @@ -89,6 +89,13 @@ ki jo moramo najprej pretvoriti v tip <code>float</code>, če želimo z njo rač <pre> v = float(input(" ... </pre> -'''] +'''], + + 'final_hint' : [ + '''\ +<p>Program deluje pravilno! <br> +To pomeni, da znaš uporabljati matematične funkcije, ki so v modulu +<a href="https://docs.python.org/3.5/library/math.html"><code>math</code></a>. +Tekom tega sklopa si bomo pogledali še modula za delo z nakjučnimi števili in za delo s časom. </p>'''] } |