From f05346555a512281762db4c0166edf2129cee7a6 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 7 Oct 2015 09:18:22 +0200 Subject: Added final hint to average problem. --- python/problems/introduction/average/common.py | 13 ++++++++++--- python/problems/introduction/average/sl.py | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'python') 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 float, če želimo z njo rač v = float(input(" ... '''], + 'final_hint': [ + '''\ +

Odlično, program deluje pravilno!
+Pa še to: za funkciji min in max nismo rabili uvoziti nobene +knjižnice (import...), ker sta +vgrajeni funkciji.'''] + } -- cgit v1.2.1