diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-05 11:57:31 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-05 11:57:31 +0200 |
commit | e63627ad942a7d2c9eebb86f15c96191e7408eb8 (patch) | |
tree | 84e7bc342d8a534ed23e81e1bc5699184be18013 /python/problems/while_and_if/consumers_anonymous/common.py | |
parent | 6bda47fb45788f7464b7846bc58d7b90cc65240f (diff) |
Added problem "counting".
Some other small text corrections.
Diffstat (limited to 'python/problems/while_and_if/consumers_anonymous/common.py')
-rw-r--r-- | python/problems/while_and_if/consumers_anonymous/common.py | 20 |
1 files changed, 13 insertions, 7 deletions
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 |