summaryrefslogtreecommitdiff
path: root/python/problems/while_and_if/top_shop
diff options
context:
space:
mode:
authorMartin <martin@leo.fri1.uni-lj.si>2015-09-29 10:05:55 +0200
committerMartin <martin@leo.fri1.uni-lj.si>2015-09-29 10:05:55 +0200
commitd06dade8c75dfa5aceacaf1a1b47f61c5fef31c4 (patch)
treee8fd42d9569788d06726690eb37012a8a8bd667f /python/problems/while_and_if/top_shop
parentfc7d6323fbdb776cfdba3cd58dc14048c39b8078 (diff)
Added three problems to while and if section.
Diffstat (limited to 'python/problems/while_and_if/top_shop')
-rw-r--r--python/problems/while_and_if/top_shop/common.py7
-rw-r--r--python/problems/while_and_if/top_shop/sl.py4
2 files changed, 6 insertions, 5 deletions
diff --git a/python/problems/while_and_if/top_shop/common.py b/python/problems/while_and_if/top_shop/common.py
index 5e8c951..db98212 100644
--- a/python/problems/while_and_if/top_shop/common.py
+++ b/python/problems/while_and_if/top_shop/common.py
@@ -27,6 +27,7 @@ hint_type = {
'while_condition': Hint('while_condition'),
'average': Hint('while_condition'),
'final_hint': Hint('final_hint'),
+ 'minimax': Hint('minimax')
}
def test(python, code):
@@ -54,8 +55,7 @@ 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 all(string_almost_equal(output, correct[i]) for i in range(2)):
n_correct += 1
else:
tin = test_in[i][1]
@@ -66,7 +66,8 @@ def test(python, code):
if tin:
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin),
'sum': str(tout[0]),
- 'avg': str(tout[1])}})
+ 'avg': str(tout[1]),
+ }})
if n_correct == len(test_in): # add an iteresting hint
tokens = get_tokens(code)
if has_token_sequence(tokens, ['!=', '0.', ':']):
diff --git a/python/problems/while_and_if/top_shop/sl.py b/python/problems/while_and_if/top_shop/sl.py
index 7eada34..ee9d02d 100644
--- a/python/problems/while_and_if/top_shop/sl.py
+++ b/python/problems/while_and_if/top_shop/sl.py
@@ -29,7 +29,7 @@ main_plan = ['''\
1. Ponavljaj dokler je cena večja od 0:
2. Preberi ceno.
3. Prištej vsoti.
-4. Izpiši vsoto.
+4. Izpiši vsoto in povprečje.
</pre>''']
while_condition = ['''\
@@ -94,7 +94,7 @@ while cena != 0:
...'''],
'final_hint': ['''\
-<p>Kaj bi moral narediti, da bi število -1 pomenilo konec?</p>''',
+<p><b>Odlično!</b> Kaj bi pa moral narediti, da bi število -1 pomenilo konec?</p>''',
'''\
<p>Spremeniti pogoj in paziti,
da se vrednost -1 ne prišteje vsoti!</p>'''],