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 | |
parent | 6bda47fb45788f7464b7846bc58d7b90cc65240f (diff) |
Added problem "counting".
Some other small text corrections.
Diffstat (limited to 'python/problems/while_and_if')
-rw-r--r-- | python/problems/while_and_if/consumers_anonymous/common.py | 20 | ||||
-rw-r--r-- | python/problems/while_and_if/consumers_anonymous/sl.py | 10 |
2 files changed, 20 insertions, 10 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 diff --git a/python/problems/while_and_if/consumers_anonymous/sl.py b/python/problems/while_and_if/consumers_anonymous/sl.py index ee2700c..284abbc 100644 --- a/python/problems/while_and_if/consumers_anonymous/sl.py +++ b/python/problems/while_and_if/consumers_anonymous/sl.py @@ -96,6 +96,9 @@ hint = { 'counting': ['''<p>Napaka pri štetju stvari.<p>'''], + 'counting_with_0': ['''<p>Napaka pri štetju, kadar je zadnja cena 0.<p>''', + '''<p>Števec povečaj, le če je cena > 0</p>'''], + 'name_error' : [mod.general_msg['error_head'], mod.general_msg['general_exception'], mod.general_msg['name_error'], @@ -107,9 +110,10 @@ hint = { Pravilna vsota [%=sum%], pravilno število stvari: [%=count%]'''], 'final_hint': ['''\ -<p><b>Odlično!</b>Naloga rešena.</p> -Še zanimivost: v while zanki smo negirali ustavitveni pogoj tako, da smo negirali posamezne pogoje in -spremenili pogoj <code>or</code> v <code>and</code>. Temu pravimo De Morganov zakon. +<p><b>Odlično!</b> Naloga rešena.</p> +Še zanimivost: v while zanki smo dobili ustavitveni pogoj tako, da smo negirali pogoj iz teksta (ali vnesemo 0 ali je +vnešenih deset števil ali ko vsota cen doseže ali preseže 100 evrov). Pri tem smo ali (or) spremenili v in (and): +<code>cena > 0 and stevec < 10 and vsota < 100</code>. Temu pravimo De Morganov zakon. '''], 'eof_error':[mod.general_msg['eof_error'], |