diff options
author | Martin Možina <martin.mozina@fri.uni-lj.si> | 2015-10-26 17:50:22 +0100 |
---|---|---|
committer | Martin Možina <martin.mozina@fri.uni-lj.si> | 2015-10-26 17:50:22 +0100 |
commit | ed5473c15bdb472219056b30850605cf7e3b9a18 (patch) | |
tree | 4df880722b9865a2c5ef5bc23032e77144e5a763 /python/problems | |
parent | ce6b6b0bc9af3cff176bd995ee25c8334eea632c (diff) |
Corrected tests in for-loop problems.
Fixed some typos.
Diffstat (limited to 'python/problems')
11 files changed, 59 insertions, 23 deletions
diff --git a/python/problems/functions/assign_numbers/sl.py b/python/problems/functions/assign_numbers/sl.py index 97c0c3a..767e045 100644 --- a/python/problems/functions/assign_numbers/sl.py +++ b/python/problems/functions/assign_numbers/sl.py @@ -10,7 +10,7 @@ slug = 'Oštevilči' description = '''\ <p> -Napišite funkcijo <code>numbers(xs)</code>, ki vrne seznam oblike <code>[(0, xs[0]), (1, xs[1]), ..., (n, xs[n])]</code>. +Napiši funkcijo <code>numbers(xs)</code>, ki vrne seznam oblike <code>[(0, xs[0]), (1, xs[1]), ..., (n, xs[n])]</code>. Število <code>n</code> je enako dolžini seznama <code>xs</code> minus ena. <pre> >>> numbers([4, 4, 4]) @@ -20,11 +20,37 @@ Napišite funkcijo <code>numbers(xs)</code>, ki vrne seznam oblike <code>[(0, xs </pre> </p>''' -plan = ['''\ -<p></p> -''', +range_function = [ '''\ -<p></p>'''] +<p> +Uporabi funkcijo <code>range</code>. +</p>''', + '''\ +<p>Poskusi, kaj naredi naslednji program: </p> +<pre> +xs = [2,3,4,5] +for i in range(len(xs)): + print (i, xs[i]) +</pre>'''] + +tuples = [ + '''\ +<p> +Več elementov skupaj v navadnih oklepajih imenujemo terka oz. <code>tuple</code>. +</p>''', + '''\ +<p> +V seznam lahko dodajam poljubne objekte. Lahko dodamo tudi terko, poskusi: +</p> +<pre> +xs = [1,2] +xs.append((1,2)) +print (xs) +</pre>''' +] + +plan = [range_function, + tuples] hint = { 'final_hint': ['''\ diff --git a/python/problems/functions/body_mass_index/sl.py b/python/problems/functions/body_mass_index/sl.py index fd67c88..995e974 100644 --- a/python/problems/functions/body_mass_index/sl.py +++ b/python/problems/functions/body_mass_index/sl.py @@ -21,11 +21,20 @@ Napišite funkcijo <code>bmi(osebe)</code>, ki na podlagi podanega seznama osebe </pre> </p>''' -plan = ['''\ -<p></p> -''', +for_multiple = [ '''\ -<p></p>'''] +<p>Kadar imamo v seznamu strukture z enako elementi, lahko v <code>for</code> +zanko napišemo več spremenljivk:</p> +<pre> +for ime, teza, visina in osebe: +</pre>'''] + +bmi = [ + '''\ +<p><a href="//sl.wikipedia.org/wiki/Indeks_telesne_mase">Link</a>'''] + + +plan = [bmi, for_multiple] hint = { 'final_hint': ['''\ diff --git a/python/problems/functions/greatest/sl.py b/python/problems/functions/greatest/sl.py index 12e07fe..a32aada 100644 --- a/python/problems/functions/greatest/sl.py +++ b/python/problems/functions/greatest/sl.py @@ -51,7 +51,7 @@ return_clause = ['''\ <p>Namesto, da izpišemo rezultat, ga vračamo s stavkom <code>return</code>.</p>'''] plan = [['''\ -<p>Najprej poskusite napisati <b>program</b> (brez funkcije), ki v <code>xs</code> poišče največji element</p>''', +<p>Najprej poskusi napisati <b>program</b> (brez funkcije), ki v <code>xs</code> poišče največji element</p>''', '''\ <pre> xs = [5, 1, -6, -7, 2] diff --git a/python/problems/functions/greatest_absolutist/sl.py b/python/problems/functions/greatest_absolutist/sl.py index a45f483..79cfb06 100644 --- a/python/problems/functions/greatest_absolutist/sl.py +++ b/python/problems/functions/greatest_absolutist/sl.py @@ -8,7 +8,7 @@ slug = 'Največji absolutist' description = '''\ -<p>Napišite funkcijo <code>max_abs(xs)</code>, ki vrne največje število po +<p>Napiši funkcijo <code>max_abs(xs)</code>, ki vrne največje število po absolutni vrednosti v seznamu <code>xs</code>.</p> <pre> >>> max_abs([5, 1, -6, -7, 2]) @@ -17,7 +17,7 @@ absolutni vrednosti v seznamu <code>xs</code>.</p> ''' function = ['''\ -<p>Napišite <b>definicijo funkcije</b> <code>max_abs(xs)</code>.</p>''', +<p>Napiši <b>definicijo funkcije</b> <code>max_abs(xs)</code>.</p>''', '''\ <p>Definicijo funkcije začnemo z <code>def</code>, temu sledi ime, potem oklepaji, v katerih naštejemo argumente funkcije, nato zaklepaj in na koncu dvopičje</p>''', @@ -50,7 +50,7 @@ plan = [function, return_clause] for_loop = ['''\ -<p>Preglejte elemente z zanko</p>. +<p>Preglej elemente z zanko</p>. ''', '''\ <pre> @@ -59,7 +59,7 @@ for x in xs: if_clause = ['''\ -<p>Preverite, če je trenutni element večji od največjega (po absolutni vrednosti)</p>''', +<p>Preveri, če je trenutni element večji od največjega (po absolutni vrednosti)</p>''', '''\ <pre> if abs(x) > abs(najvecji): diff --git a/python/problems/introduction/fahrenheit_to_celsius/sl.py b/python/problems/introduction/fahrenheit_to_celsius/sl.py index 9d6650c..4b53978 100644 --- a/python/problems/introduction/fahrenheit_to_celsius/sl.py +++ b/python/problems/introduction/fahrenheit_to_celsius/sl.py @@ -24,13 +24,14 @@ ime = input("Kako ti je ime?") shrani uporabnikov odgovor v spremenljivko <code>ime</code>.</p>'''] expressions_python = ['''\ -<p>Pythonu vse izraze izračuna.</p>''', +<p>Kot kaže, imaš temperaturo v Fahrenheitih že prebrano. +Zdaj pa izračunaj temperaturo v Celzijevih stopinjah. </p>''', '''\ -<p>Če napišemo</p> +<p>Python izraze izračuna. Če napišemo</p> <pre> 3 + 6 * 5 </pre> -<p>bo Python izračunal <code>3 + 6 * 5</code>.</p>''', +<p>bo izračunal <code>3 + 6 * 5</code>.</p>''', '''\ <p>Kadar želimo rezultat shraniti, za to uporabimo <em>prireditveni stavek</em>, kjer na levo napišemo ime spremenljivke, na desno pa izraz:</p> diff --git a/python/problems/lists_and_for/contains_42/common.py b/python/problems/lists_and_for/contains_42/common.py index fb2089e..312b601 100644 --- a/python/problems/lists_and_for/contains_42/common.py +++ b/python/problems/lists_and_for/contains_42/common.py @@ -73,7 +73,7 @@ def test(python, code): passed = n_correct == len(test_xs) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}] - if tin: + if tin != None: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) else: if has_token_sequence(tokens, ['break']): diff --git a/python/problems/lists_and_for/contains_multiples/common.py b/python/problems/lists_and_for/contains_multiples/common.py index 59a5743..055cc3e 100644 --- a/python/problems/lists_and_for/contains_multiples/common.py +++ b/python/problems/lists_and_for/contains_multiples/common.py @@ -65,7 +65,7 @@ def test(python, code): passed = n_correct == len(test_in) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}] - if tin: + if tin != None: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) if passed: hints.append({'id': 'final_hint'}) diff --git a/python/problems/lists_and_for/contains_string/common.py b/python/problems/lists_and_for/contains_string/common.py index 62fef4e..5470251 100644 --- a/python/problems/lists_and_for/contains_string/common.py +++ b/python/problems/lists_and_for/contains_string/common.py @@ -67,7 +67,7 @@ def test(python, code): passed = n_correct == len(test_xs) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}] - if tin: + if tin != None: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) if passed: hints.append({'id': 'final_hint'}) diff --git a/python/problems/lists_and_for/counting/common.py b/python/problems/lists_and_for/counting/common.py index 73d0071..d80d1c9 100644 --- a/python/problems/lists_and_for/counting/common.py +++ b/python/problems/lists_and_for/counting/common.py @@ -70,7 +70,7 @@ def test(python, code): passed = n_correct == len(test_xs) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}] - if tin: + if tin != None: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) if passed: hints.append({'id': 'final_hint'}) diff --git a/python/problems/lists_and_for/every_third/common.py b/python/problems/lists_and_for/every_third/common.py index 2d5b907..1529184 100644 --- a/python/problems/lists_and_for/every_third/common.py +++ b/python/problems/lists_and_for/every_third/common.py @@ -60,7 +60,7 @@ def test(python, code): passed = n_correct == len(test_in) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}] - if tin: + if tin != None: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) if passed: hints.append({'id': 'final_hint'}) diff --git a/python/problems/lists_and_for/places/common.py b/python/problems/lists_and_for/places/common.py index e7d1adf..56b3f1d 100644 --- a/python/problems/lists_and_for/places/common.py +++ b/python/problems/lists_and_for/places/common.py @@ -63,7 +63,7 @@ def test(python, code): passed = n_correct == len(test_in) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}] - if tin: + if tin != None: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) if passed: hints.append({'id': 'final_hint'}) |