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 +++++++++++++------- .../problems/while_and_if/consumers_anonymous/sl.py | 10 +++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'python/problems/while_and_if') 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': ['''

Napaka pri štetju stvari.

'''], + 'counting_with_0': ['''

Napaka pri štetju, kadar je zadnja cena 0.

''', + '''

Števec povečaj, le če je cena > 0

'''], + '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': ['''\ -

Odlično!Naloga rešena.

-Še zanimivost: v while zanki smo negirali ustavitveni pogoj tako, da smo negirali posamezne pogoje in -spremenili pogoj or v and. Temu pravimo De Morganov zakon. +

Odlično! Naloga rešena.

+Š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): +cena > 0 and stevec < 10 and vsota < 100. Temu pravimo De Morganov zakon. '''], 'eof_error':[mod.general_msg['eof_error'], -- cgit v1.2.1