From e63627ad942a7d2c9eebb86f15c96191e7408eb8 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 5 Oct 2015 11:57:31 +0200 Subject: Added problem "counting". Some other small text corrections. --- .../while_and_if/consumers_anonymous/common.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'python/problems/while_and_if/consumers_anonymous/common.py') diff --git a/python/problems/while_and_if/consumers_anonymous/common.py b/python/problems/while_and_if/consumers_anonymous/common.py index ff3f928..07a0ebf 100644 --- a/python/problems/while_and_if/consumers_anonymous/common.py +++ b/python/problems/while_and_if/consumers_anonymous/common.py @@ -32,6 +32,7 @@ hint_type = { 'final_hint': Hint('final_hint'), 'summation': Hint('summation'), 'counting': Hint('counting'), + 'counting_with_0': Hint('counting_with_0'), 'problematic_test_case': Hint('problematic_test_case'), } @@ -53,7 +54,8 @@ def test(python, code): (105, 3), (10, 10), (10, 10), - (9, 9) + (9, 9), + (0, 0) ] # List of outputs: (expression result, stdout, stderr, exception). @@ -114,14 +116,18 @@ def hint(python, code): # student's answer is not correct (three possibilities) if not string_almost_equal(answer[0][1], 15) or \ - not string_almost_equal(answer[0][2], 105) or \ - not string_almost_equal(answer[0][3], 20): + not string_almost_equal(answer[1][1], 105) or \ + not string_almost_equal(answer[2][1], 20): return [{'id' : 'summation'}] - # student's answer is not correct (three possibilities) - if not string_almost_equal(answer[0][1], 2) or \ - not string_almost_equal(answer[0][2], 3) or \ - not string_almost_equal(answer[0][3], 10): + # student's counting of items, when last price iz zero is incorrect + if not string_almost_equal(answer[0][1], 2) and \ + string_almost_equal(answer[0][1], 3): + return [{'id' : 'counting_with_0'}] + + # counting in general is incorrect + if not string_almost_equal(answer[1][1], 3) or \ + not string_almost_equal(answer[2][1], 10): return [{'id' : 'counting'}] return None -- cgit v1.2.1