diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-07 09:18:22 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-07 09:18:22 +0200 |
commit | f05346555a512281762db4c0166edf2129cee7a6 (patch) | |
tree | 15b73b90fb475ceed479281b8d1e31131691cd09 /python/problems | |
parent | 0e92e87812a7c11edbdee9c1590a2cad53f3577c (diff) |
Added final hint to average problem.
Diffstat (limited to 'python/problems')
-rw-r--r-- | python/problems/introduction/average/common.py | 13 | ||||
-rw-r--r-- | python/problems/introduction/average/sl.py | 7 |
2 files changed, 17 insertions, 3 deletions
diff --git a/python/problems/introduction/average/common.py b/python/problems/introduction/average/common.py index 4e7e97c..c61f7e6 100644 --- a/python/problems/introduction/average/common.py +++ b/python/problems/introduction/average/common.py @@ -26,6 +26,9 @@ hint_type = { 'error': Hint('error'), 'radians': Hint('radians'), 'printing': Hint('printing'), + 'average': Hint('average'), + 'median': Hint('median'), + 'final_hint': Hint('final_hint') } @@ -38,6 +41,7 @@ def test(python, code): (None, '2\n5\n1\n'), (None, '3\n1\n1\n'), (None, '5\n1\n5\n'), + (None, '1\n1\n1\n') ] test_out = [ @@ -45,7 +49,8 @@ def test(python, code): [2, 1], [2.67, 2], [1.67, 1], - [3.67, 5] + [3.67, 5], + [1, 1] ] # List of outputs: (expression result, stdout, stderr, exception). @@ -55,8 +60,8 @@ def test(python, code): n_correct = 0 tin = None for i, (output, correct) in enumerate(zip(outputs, test_out)): - if string_almost_equal(output, correct[0]) and \ - string_almost_equal(output, correct[1]): + if string_almost_equal(output, correct[0], prec=2) and \ + string_almost_equal(output, correct[1], prec=2): n_correct += 1 else: tin = test_in[i][1].replace('\n', ' ') @@ -66,6 +71,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 diff --git a/python/problems/introduction/average/sl.py b/python/problems/introduction/average/sl.py index 7e3c7f4..d7eafbb 100644 --- a/python/problems/introduction/average/sl.py +++ b/python/problems/introduction/average/sl.py @@ -69,4 +69,11 @@ ki jo moramo najprej pretvoriti v tip <code>float</code>, če želimo z njo rač v = float(input(" ... </pre> '''], + 'final_hint': [ + '''\ +<p>Odlično, program deluje pravilno! <br> +Pa še to: za funkciji <code>min</code> in <code>max</code> nismo rabili uvoziti nobene +knjižnice (<code>import</code>...), ker sta +<a href="https://docs.python.org/3/library/functions.html">vgrajeni funkciji</a>.'''] + } |