From ed5473c15bdb472219056b30850605cf7e3b9a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mo=C5=BEina?= Date: Mon, 26 Oct 2015 17:50:22 +0100 Subject: Corrected tests in for-loop problems. Fixed some typos. --- python/problems/functions/assign_numbers/sl.py | 36 +++++++++++++++++++--- python/problems/functions/body_mass_index/sl.py | 17 +++++++--- python/problems/functions/greatest/sl.py | 2 +- .../problems/functions/greatest_absolutist/sl.py | 8 ++--- .../introduction/fahrenheit_to_celsius/sl.py | 7 +++-- .../problems/lists_and_for/contains_42/common.py | 2 +- .../lists_and_for/contains_multiples/common.py | 2 +- .../lists_and_for/contains_string/common.py | 2 +- python/problems/lists_and_for/counting/common.py | 2 +- .../problems/lists_and_for/every_third/common.py | 2 +- python/problems/lists_and_for/places/common.py | 2 +- 11 files changed, 59 insertions(+), 23 deletions(-) (limited to 'python/problems') 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 = '''\

-Napišite funkcijo numbers(xs), ki vrne seznam oblike [(0, xs[0]), (1, xs[1]), ..., (n, xs[n])]. +Napiši funkcijo numbers(xs), ki vrne seznam oblike [(0, xs[0]), (1, xs[1]), ..., (n, xs[n])]. Število n je enako dolžini seznama xs minus ena.

 >>> numbers([4, 4, 4])
@@ -20,11 +20,37 @@ Napišite funkcijo numbers(xs), ki vrne seznam oblike [(0, xs
 

''' -plan = ['''\ -

-''', +range_function = [ '''\ -

'''] +

+Uporabi funkcijo range. +

''', + '''\ +

Poskusi, kaj naredi naslednji program:

+
+xs = [2,3,4,5]
+for i in range(len(xs)):
+    print (i, xs[i])
+
'''] + +tuples = [ + '''\ +

+Več elementov skupaj v navadnih oklepajih imenujemo terka oz. tuple. +

''', + '''\ +

+V seznam lahko dodajam poljubne objekte. Lahko dodamo tudi terko, poskusi: +

+
+xs = [1,2]
+xs.append((1,2))
+print (xs)
+
''' +] + +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 bmi(osebe), ki na podlagi podanega seznama osebe

''' -plan = ['''\ -

-''', +for_multiple = [ '''\ -

'''] +

Kadar imamo v seznamu strukture z enako elementi, lahko v for +zanko napišemo več spremenljivk:

+
+for ime, teza, visina in osebe:
+
'''] + +bmi = [ + '''\ +

Link'''] + + +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 = ['''\

Namesto, da izpišemo rezultat, ga vračamo s stavkom return.

'''] plan = [['''\ -

Najprej poskusite napisati program (brez funkcije), ki v xs poišče največji element

''', +

Najprej poskusi napisati program (brez funkcije), ki v xs poišče največji element

''', '''\
 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 = '''\
-

Napišite funkcijo max_abs(xs), ki vrne največje število po +

Napiši funkcijo max_abs(xs), ki vrne največje število po absolutni vrednosti v seznamu xs.

 >>> max_abs([5, 1, -6, -7, 2])
@@ -17,7 +17,7 @@ absolutni vrednosti v seznamu xs.

''' function = ['''\ -

Napišite definicijo funkcije max_abs(xs).

''', +

Napiši definicijo funkcije max_abs(xs).

''', '''\

Definicijo funkcije začnemo z def, temu sledi ime, potem oklepaji, v katerih naštejemo argumente funkcije, nato zaklepaj in na koncu dvopičje

''', @@ -50,7 +50,7 @@ plan = [function, return_clause] for_loop = ['''\ -

Preglejte elemente z zanko

. +

Preglej elemente z zanko

. ''', '''\
@@ -59,7 +59,7 @@ for x in xs:
 
 
 if_clause = ['''\
-

Preverite, če je trenutni element večji od največjega (po absolutni vrednosti)

''', +

Preveri, če je trenutni element večji od največjega (po absolutni vrednosti)

''', '''\
 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 ime.

'''] expressions_python = ['''\ -

Pythonu vse izraze izračuna.

''', +

Kot kaže, imaš temperaturo v Fahrenheitih že prebrano. +Zdaj pa izračunaj temperaturo v Celzijevih stopinjah.

''', '''\ -

Če napišemo

+

Python izraze izračuna. Če napišemo

 3 + 6 * 5
 
-

bo Python izračunal 3 + 6 * 5.

''', +

bo izračunal 3 + 6 * 5.

''', '''\

Kadar želimo rezultat shraniti, za to uporabimo prireditveni stavek, kjer na levo napišemo ime spremenljivke, na desno pa izraz:

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'}) -- cgit v1.2.1