From d06dade8c75dfa5aceacaf1a1b47f61c5fef31c4 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 29 Sep 2015 10:05:55 +0200 Subject: Added three problems to while and if section. --- python/problems/while_and_if/top_shop/common.py | 7 ++++--- python/problems/while_and_if/top_shop/sl.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'python/problems/while_and_if/top_shop') 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. '''] while_condition = ['''\ @@ -94,7 +94,7 @@ while cena != 0: ...'''], 'final_hint': ['''\ -

Kaj bi moral narediti, da bi število -1 pomenilo konec?

''', +

Odlično! Kaj bi pa moral narediti, da bi število -1 pomenilo konec?

''', '''\

Spremeniti pogoj in paziti, da se vrednost -1 ne prišteje vsoti!

'''], -- cgit v1.2.1