summaryrefslogtreecommitdiff
path: root/python/problems/lists_and_if-fkkt
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/lists_and_if-fkkt')
-rw-r--r--python/problems/lists_and_if-fkkt/common.py2
-rw-r--r--python/problems/lists_and_if-fkkt/contains_number/common.py88
-rw-r--r--python/problems/lists_and_if-fkkt/contains_number/sl.py49
-rw-r--r--python/problems/lists_and_if-fkkt/contains_word/common.py88
-rw-r--r--python/problems/lists_and_if-fkkt/contains_word/sl.py49
-rw-r--r--python/problems/lists_and_if-fkkt/en.py3
-rw-r--r--python/problems/lists_and_if-fkkt/even_odd/common.py82
-rw-r--r--python/problems/lists_and_if-fkkt/even_odd/sl.py37
-rw-r--r--python/problems/lists_and_if-fkkt/is_palindrome/common.py75
-rw-r--r--python/problems/lists_and_if-fkkt/is_palindrome/sl.py33
-rw-r--r--python/problems/lists_and_if-fkkt/itm/common.py86
-rw-r--r--python/problems/lists_and_if-fkkt/itm/sl.py53
-rw-r--r--python/problems/lists_and_if-fkkt/min_and_max/common.py96
-rw-r--r--python/problems/lists_and_if-fkkt/min_and_max/sl.py43
-rw-r--r--python/problems/lists_and_if-fkkt/sl.py3
-rw-r--r--python/problems/lists_and_if-fkkt/square_equation/common.py89
-rw-r--r--python/problems/lists_and_if-fkkt/square_equation/sl.py53
-rw-r--r--python/problems/lists_and_if-fkkt/temp_converter/common.py87
-rw-r--r--python/problems/lists_and_if-fkkt/temp_converter/sl.py51
19 files changed, 1067 insertions, 0 deletions
diff --git a/python/problems/lists_and_if-fkkt/common.py b/python/problems/lists_and_if-fkkt/common.py
new file mode 100644
index 0000000..4bc01ee
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/common.py
@@ -0,0 +1,2 @@
+id = 2501
+number = 11
diff --git a/python/problems/lists_and_if-fkkt/contains_number/common.py b/python/problems/lists_and_if-fkkt/contains_number/common.py
new file mode 100644
index 0000000..b20d7b9
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/contains_number/common.py
@@ -0,0 +1,88 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25006
+number = 2
+visible = True
+
+solution = '''\
+seznam = [3, 7, 9, 10, 12]
+st = int(input("Vpišite število: "))
+if st in seznam:
+ print("Seznam vsebuje število", st)
+else:
+ print("Seznam ne vsebuje števila", st)
+'''
+
+hint_type = {
+ 'no_xs': Hint('no_xs'),
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '9\n'),
+ (None, '4\n'),
+ (None, '3\n'),
+ (None, '1\n')
+ ]
+ test_out = [
+ 'Seznam vsebuje število 9',
+ 'Seznam ne vsebuje števila 4',
+ 'Seznam vsebuje število 3',
+ 'Seznam ne vsebuje števila 1'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if output.rstrip().endswith(correct):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '1\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if has no xs, tell him to ask for values
+ if not has_token_sequence(tokens, ['seznam', '=', '[']):
+ return [{'id' : 'no_xs'}]
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['if']):
+ return [{'id' : 'if_clause'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/contains_number/sl.py b/python/problems/lists_and_if-fkkt/contains_number/sl.py
new file mode 100644
index 0000000..69b9c7c
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/contains_number/sl.py
@@ -0,0 +1,49 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Števila v seznamu'
+slug = 'Števila v seznamu'
+
+
+description = '''\
+<p>Napišite program, ki ugotovi, ali je število, ki ga vpiše uporabnik, v seznamu. Seznam definirajte na vrhu programa: <code>seznam = [3, 7, 9, 10, 12, 17, 21, 33]</code><br>
+Primer uporabe:</p>
+
+<pre><code>Vpišite število: <span style="color: rgb(239, 69, 64);">9</span>
+Seznam vsebuje število 9
+
+Vpišite število: <span style="color: rgb(239, 69, 64);">4</span>
+Seznam ne vsebuje števila 4
+</code></pre>
+
+<p>Seveda mora program delati za poljubne sezname in ne samo za seznam iz primera.</p>
+'''
+
+if_clause = ['''\
+<p>Preveri, ali imamo dano število v seznamu?</p>''',
+ '''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if x in seznam:
+</pre>''']
+
+
+plan = []
+
+hint = {
+ 'no_xs': ['''\
+<p>Program mora imeti na začetku definiran seznam <code>seznam</code>.</p>'''],
+
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/lists_and_if-fkkt/contains_word/common.py b/python/problems/lists_and_if-fkkt/contains_word/common.py
new file mode 100644
index 0000000..1c4843c
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/contains_word/common.py
@@ -0,0 +1,88 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25007
+number = 3
+visible = True
+
+solution = '''\
+seznam = ["beseda", "spremenljivka", "niz", "zanka", "stavek", "slovar"]
+niz = input("Vpišite niz: ")
+if niz in seznam:
+ print("Seznam vsebuje niz", niz)
+else:
+ print("Seznam ne vsebuje niza", niz)
+'''
+
+hint_type = {
+ 'no_xs': Hint('no_xs'),
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, 'zanka\n'),
+ (None, 'vrednost\n'),
+ (None, 'slovar\n'),
+ (None, 'število\n')
+ ]
+ test_out = [
+ 'Seznam vsebuje niz zanka',
+ 'Seznam ne vsebuje niza vrednost',
+ 'Seznam vsebuje niz slovar',
+ 'Seznam ne vsebuje niza število'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if output.rstrip().endswith(correct):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '1\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if has no xs, tell him to ask for values
+ if not has_token_sequence(tokens, ['seznam', '=', '[']):
+ return [{'id' : 'no_xs'}]
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['if']):
+ return [{'id' : 'if_clause'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/contains_word/sl.py b/python/problems/lists_and_if-fkkt/contains_word/sl.py
new file mode 100644
index 0000000..d92e966
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/contains_word/sl.py
@@ -0,0 +1,49 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Niz v seznamu'
+slug = 'Niz v seznamu'
+
+
+description = '''\
+<p>Napišite program, ki ugotovi, ali je niz, ki ga vpiše uporabnik, v seznamu. Seznam definirajte na vrhu programa: <code>seznam = ["beseda", "spremenljivka", "niz", "zanka", "stavek", "slovar"]</code><br>
+Primer uporabe:</p>
+
+<pre><code>Vpišite niz: <span style="color: rgb(239, 69, 64);">zanka</span>
+Seznam vsebuje niz zanka
+
+Vpišite niz: <span style="color: rgb(239, 69, 64);">vrednost</span>
+Seznam ne vsebuje niza vrednost
+</code></pre>
+
+<p>Seveda mora program delati za poljubne sezname in ne samo za seznam iz primera.</p>
+'''
+
+if_clause = ['''\
+<p>Preveri, ali imamo dan niz v seznamu?</p>''',
+ '''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if x in seznam:
+</pre>''']
+
+
+plan = []
+
+hint = {
+ 'no_xs': ['''\
+<p>Program mora imeti na začetku definiran seznam <code>seznam</code>.</p>'''],
+
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/lists_and_if-fkkt/en.py b/python/problems/lists_and_if-fkkt/en.py
new file mode 100644
index 0000000..a9f86aa
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/en.py
@@ -0,0 +1,3 @@
+name = 'Lists and if - FKKT'
+description = 'Lists and conditional statements'
+
diff --git a/python/problems/lists_and_if-fkkt/even_odd/common.py b/python/problems/lists_and_if-fkkt/even_odd/common.py
new file mode 100644
index 0000000..a6b7f64
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/even_odd/common.py
@@ -0,0 +1,82 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25005
+number = 1
+visible = True
+
+solution = '''\
+seznam = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+seznam_lihi = seznam[::2]
+seznam_sodi = seznam[1::2]
+print(seznam_lihi)
+print(seznam_sodi)
+'''
+
+hint_type = {
+ 'no_xs': Hint('no_xs'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_xs = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
+ [1, 2, 3, 4],
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
+ ]
+ test_out = [
+ '[1, 3, 5, 7, 9]\n[2, 4, 6, 8, 10]',
+ '[1, 3]\n[2, 4]',
+ '[1, 3, 5, 7, 9, 11, 13]\n[2, 4, 6, 8, 10, 12, 14]'
+ ]
+
+ n_correct = 0
+ tin = None
+ for xs_i, xs in enumerate(test_xs):
+ # change code to contain new xs instead of the one
+ # given by user
+ tcode = re.sub(r'^seznam\s*=\s*\[.*?\]',
+ 'seznam = ' + str(xs),
+ code,
+ flags = re.DOTALL | re.MULTILINE)
+
+ # use python session to call tcode
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
+ output = answers[0][1]
+
+ if re.sub("\s", "", test_out[xs_i]) in re.sub("\s", "", output):
+ n_correct += 1
+ else:
+ tin = test_xs[xs_i]
+ tout = test_out[xs_i]
+
+ passed = n_correct == len(test_xs)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if has no xs, tell him to ask for values
+ if not has_token_sequence(tokens, ['seznam', '=', '[']):
+ return [{'id' : 'no_xs'}]
+
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/even_odd/sl.py b/python/problems/lists_and_if-fkkt/even_odd/sl.py
new file mode 100644
index 0000000..c3fa17b
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/even_odd/sl.py
@@ -0,0 +1,37 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+name = 'Liha in soda števila'
+slug = 'Liha in soda števila'
+
+description = '''\
+<p>V spremenljivki&nbsp;<code>seznam</code>&nbsp;imamo podan seznam vseh naravnih števil na intervalu [1, n].<br>Z uporabo pravil naslavljanja in rezanja seznamov ustvarite dva nova podseznama in jih izpišite:</p><ul><li><code>seznam_lihi</code>, ki vsebuje vsa liha števila iz seznama&nbsp;<code>seznam</code></li><li><code>seznam_sodi</code>, ki vsebuje vsa soda števila iz seznama&nbsp;<code>seznam</code></li>
+</ul>
+<p>Seznam definiraj na vrhu programa: <code>seznam = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</code><br>
+Izpis:</p>
+
+<pre><code>[1, 3, 5, 7, 9]
+[2, 4, 6, 8, 10]
+</code></pre>
+'''
+
+plan = ['''\
+<p>Z uporabo pravil naslavljanja in rezanja seznamov ustvarite dva nova podseznama in jih izpišite.</p>
+''']
+
+hint = {
+ 'no_xs': ['''\
+<p>Program mora imeti na začetku definiran seznam <code>seznam</code>.</p>'''],
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+ 'problematic_test_case': ['''\
+<p>Program ne dela pravilno!<br>
+Poskusi seznam = [%=testin%] <br>
+pravilen rezultat: [%=testout%]</p>
+'''],
+}
diff --git a/python/problems/lists_and_if-fkkt/is_palindrome/common.py b/python/problems/lists_and_if-fkkt/is_palindrome/common.py
new file mode 100644
index 0000000..7e9dfac
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/is_palindrome/common.py
@@ -0,0 +1,75 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25008
+number = 4
+visible = True
+
+solution = '''\
+niz = input("Vpišite niz: ")
+print(niz == niz[::-1])
+'''
+
+hint_type = {
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, 'kisik\n'),
+ (None, 'vnos\n'),
+ (None, 'cepec\n'),
+ (None, 'kemija\n')
+ ]
+ test_out = [
+ 'True',
+ 'False',
+ 'True',
+ 'False'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if output.rstrip().endswith(correct):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '1\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/is_palindrome/sl.py b/python/problems/lists_and_if-fkkt/is_palindrome/sl.py
new file mode 100644
index 0000000..90c9bff
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/is_palindrome/sl.py
@@ -0,0 +1,33 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Palindrom'
+slug = 'Palindrom'
+
+
+description = '''\
+<p>Napišite program, ki uporabnika vpraša po nizu, nato pa izpiše, ali je niz <a href="https://sl.wikipedia.org/wiki/Palindrom">palindrom</a>.<br>
+Primer uporabe:</p>
+
+<pre><code>Vpišite niz: <span style="color: rgb(239, 69, 64);">kisik</span>
+True
+
+Vpišite niz: <span style="color: rgb(239, 69, 64);">vnos</span>
+False
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/lists_and_if-fkkt/itm/common.py b/python/problems/lists_and_if-fkkt/itm/common.py
new file mode 100644
index 0000000..f8ae83a
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/itm/common.py
@@ -0,0 +1,86 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25011
+number = 7
+visible = True
+
+solution = '''\
+visina = float(input("Telesna višina [cm]: "))
+teza = float(input("Teža [kg]: "))
+indeks = teza / (visina/100) ** 2
+print("Vaš indeks telesne mase je: ", round(indeks,2))
+if indeks > 25:
+ print("Potrebno se bo več gibati in jesti bolj zdravo!")
+elif indeks < 18.5:
+ print("Pojejte kakšen kos torte več! ;)")
+else:
+ print("Super, nadaljujte s svojim življenskim stilom!")
+'''
+
+hint_type = {
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '189\n70\n'),
+ (None, '165\n70\n'),
+ (None, '170\n53\n')
+
+ ]
+ test_out = [
+ 'Vaš indeks telesne mase je: 19.6\nSuper, nadaljujte s svojim življenskim stilom!',
+ 'Vaš indeks telesne mase je: 25.71\nPotrebno se bo več gibati in jesti bolj zdravo!',
+ 'Vaš indeks telesne mase je: 18.34\nPojejte kakšen kos torte več! ;)'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if re.sub('\s', '', output).endswith(re.sub('\s', '', correct)):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '189\n70\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['if']):
+ return [{'id' : 'if_clause'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/itm/sl.py b/python/problems/lists_and_if-fkkt/itm/sl.py
new file mode 100644
index 0000000..329ebff
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/itm/sl.py
@@ -0,0 +1,53 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Indeks telesne mase'
+slug = 'Indeks telesne mase'
+
+
+description = '''\
+<p>Napišite program, ki uporabnika vpraša po telesni višini in teži ter izračuna indeks telesne mase. Če je indeks manjši od 18.5, uporabniku sporočite, da je presuh in mu priporočite, da naj poje kakšen kos torte. Če je indeks telesne mase večji od 25, spodbudite uporabnika, da se začne več gibati in jesti bolj zdravo. Drugače pa uporabniku sporočite, da naj kar nadaljuje s svojim življenjskim stilom.<br>
+Primer uporabe:</p>
+
+<pre><code>Telesna višina [cm]: <span style="color: rgb(239, 69, 64);">189</span>
+Teža [kg]: <span style="color: rgb(239, 69, 64);">70</span>
+Vaš indeks telesne mase je: 19.6
+Super, nadaljujte s svojim življenskim stilom!
+
+Telesna višina [cm]: <span style="color: rgb(239, 69, 64);">170</span>
+Teža [kg]: <span style="color: rgb(239, 69, 64);">53</span>
+Vaš indeks telesne mase je: 18.34
+Pojejte kakšen kos torte več! ;)
+
+Telesna višina [cm]: <span style="color: rgb(239, 69, 64);">165</span>
+Teža [kg]: <span style="color: rgb(239, 69, 64);">70</span>
+Vaš indeks telesne mase je: 25.71
+Potrebno se bo več gibati in jesti bolj zdravo!
+</code></pre>
+'''
+
+if_clause = ['''\
+<p>Preveri, če ITM presega določeno mejo?</p>''',
+ '''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if x in seznam:
+</pre>''']
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/lists_and_if-fkkt/min_and_max/common.py b/python/problems/lists_and_if-fkkt/min_and_max/common.py
new file mode 100644
index 0000000..2b1d0b3
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/min_and_max/common.py
@@ -0,0 +1,96 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25009
+number = 5
+visible = True
+
+solution = '''\
+st1 = int(input("Vpišite 1. število: "))
+st2 = int(input("Vpišite 2. število: "))
+st3 = int(input("Vpišite 3. število: "))
+max = st1
+min = st1
+if st2 > max:
+ max = st2
+if st3 > max:
+ max = st3
+if st2 < min:
+ min = st2
+if st3 < min:
+ min = st3
+print("Minimum: ", min, ", Maksimum: ", max)
+'''
+
+hint_type = {
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'no_min_max': Hint('no_min_max'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ if has_token_sequence(tokens, ['min', '(']) or has_token_sequence(tokens, ['max', '(']):
+ return False, [{'id': 'no_min_max'}]
+
+ test_in = [
+ (None, '5\n8\n7\n'),
+ (None, '4\n3\n2\n'),
+ (None, '1\n0\n2\n')
+ ]
+ test_out = [
+ 'Minimum: 5 , Maksimum: 8',
+ 'Minimum: 2 , Maksimum: 4',
+ 'Minimum: 0 , Maksimum: 2'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if re.sub('\s', '', output).endswith(re.sub('\s', '', correct)):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '5\n8\n7\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if has_token_sequence(tokens, ['min', '(']) or has_token_sequence(tokens, ['max', '(']):
+ return [{'id': 'no_min_max'}]
+
+ if not has_token_sequence(tokens, ['if']):
+ return [{'id' : 'if_clause'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/min_and_max/sl.py b/python/problems/lists_and_if-fkkt/min_and_max/sl.py
new file mode 100644
index 0000000..581dd5e
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/min_and_max/sl.py
@@ -0,0 +1,43 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Največje in najmanjše število'
+slug = 'Največje in najmanjše število'
+
+
+description = '''\
+<p>Izpišite največjo in najmanjšo izmed treh števil, ki jih vnese uporabnik. Ne uporabite funkcij <code>min()</code> in <code>max()</code>.<br>
+Primer uporabe:</p>
+
+<pre><code><span style="color: rgb(12, 23, 255);">Vpišite 1. število:</span> <span style="color: rgb(239, 69, 64);">5</span>
+<span style="color: rgb(12, 23, 255);">Vpišite 2. število:</span> <span style="color: rgb(239, 69, 64);">8</span>
+<span style="color: rgb(12, 23, 255);">Vpišite 3. število:</span> <span style="color: rgb(239, 69, 64);">7</span>
+<span style="color: rgb(12, 23, 255);">Minimum: 5 , Maksimum: 8</span>
+</code></pre>
+'''
+
+if_clause = ['''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if x > y:
+</pre>''']
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'no_min_max': '''Funkciji <code>min()</code> in <code>max()</code> nista dovoljeni pri tej nalogi!''',
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/lists_and_if-fkkt/sl.py b/python/problems/lists_and_if-fkkt/sl.py
new file mode 100644
index 0000000..493d9a7
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/sl.py
@@ -0,0 +1,3 @@
+name = 'Pogojni stavki in seznami'
+description = 'Naloge s seznami in pogojnimi stavki'
+
diff --git a/python/problems/lists_and_if-fkkt/square_equation/common.py b/python/problems/lists_and_if-fkkt/square_equation/common.py
new file mode 100644
index 0000000..45e0f02
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/square_equation/common.py
@@ -0,0 +1,89 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25012
+number = 8
+visible = True
+
+solution = '''\
+a = int(input('Vpiši a: '))
+b = int(input('Vpiši b: '))
+c = int(input('Vpiši c: '))
+
+d = b**2 - 4 * a * c
+if d < 0:
+ print('Enačba nima realnih rešitev.')
+elif d == 0:
+ x = -b / (2 * a)
+ print('Enačba ima eno realno rešitev:', x)
+else:
+ x1 = (-b + pow(d, 1/2)) / (2 * a)
+ x2 = (-b - pow(d, 1/2)) / (2 * a)
+ print('Enačba ima dve realni rešitvi:', x1, 'in', x2)
+'''
+
+hint_type = {
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '1\n2\n1\n'),
+ (None, '1\n2\n0\n'),
+ (None, '1\n2\n2\n')
+ ]
+ test_out = [
+ 'Enačba ima eno realno rešitev: -1.0',
+ 'Enačba ima dve realni rešitvi: 0.0 in -2.0',
+ 'Enačba nima realnih rešitev.'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if output.rstrip().endswith(correct):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '1\n2\n1\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['if']):
+ return [{'id' : 'if_clause'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/square_equation/sl.py b/python/problems/lists_and_if-fkkt/square_equation/sl.py
new file mode 100644
index 0000000..1ad813d
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/square_equation/sl.py
@@ -0,0 +1,53 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Kvadratna enačba'
+slug = 'Kvadratna enačba'
+
+
+description = '''\
+<p>Napišite program <code>kvadratna_enacba.py</code>, ki izračuna vse realne rešitve <a href="https://sl.wikipedia.org/wiki/Kvadratna_ena%C4%8Dba">kvadratne enačbe</a> <code>ax^2 + bx + c = 0</code>,
+podane z argumenti a, b in c. Vaš program naj se obnaša kot je prikazano spodaj.</p>
+
+<pre><code class="brush: python">Vpiši a: <span style="color: rgb(239, 69, 64);">1</span>
+Vpiši b: <span style="color: rgb(239, 69, 64);">2</span>
+Vpiši c: <span style="color: rgb(239, 69, 64);">1</span>
+Enačba ima eno realno rešitev: -1.0
+
+Vpiši a: <span style="color: rgb(239, 69, 64);">1</span>
+Vpiši b: <span style="color: rgb(239, 69, 64);">2</span>
+Vpiši c: <span style="color: rgb(239, 69, 64);">0</span>
+Enačba ima dve realni rešitvi: 0.0 in -2.0
+
+Vpiši a: <span style="color: rgb(239, 69, 64);">1</span>
+Vpiši b: <span style="color: rgb(239, 69, 64);">2</span>
+Vpiši c: <span style="color: rgb(239, 69, 64);">2</span>
+Enačba nima realnih rešitev.
+</code></pre>
+'''
+
+if_clause = ['''\
+<p>Preveri, koliko rešitev ima enačba?</p>''',
+ '''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if d == 0:
+</pre>''']
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/lists_and_if-fkkt/temp_converter/common.py b/python/problems/lists_and_if-fkkt/temp_converter/common.py
new file mode 100644
index 0000000..1b41ef1
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/temp_converter/common.py
@@ -0,0 +1,87 @@
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 25010
+number = 6
+visible = True
+
+solution = '''\
+temp_C = float(input("Vpiši temperaturo [°C]: "))
+pretvorba = input("Želite pretvoriti v Kelvine (vpiši K) ali Fahrenheite (vpiši F)? ")
+if pretvorba == "K":
+ temp_K = temp_C + 273.15
+ print(str(temp_C) + " °C je enako " + str(temp_K) + " K")
+elif pretvorba == "F":
+ temp_F = temp_C * 9/5 + 32
+ print(str(temp_C) + " °C je enako " + str(temp_F) + " °F")
+else:
+ print("Vnesli ste napačno enoto!")
+'''
+
+hint_type = {
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_input_call' : Hint('no_input_call'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '32\nK\n'),
+ (None, '23\nF\n'),
+ (None, '3\n1\n'),
+ (None, '13\nC\n')
+ ]
+ test_out = [
+ '32.0 °C je enako 305.15 K',
+ '23.0 °C je enako 73.4 °F',
+ 'Vnesli ste napačno enoto!',
+ 'Vnesli ste napačno enoto!'
+ ]
+
+ # List of outputs: (expression result, stdout, stderr, exception).
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ outputs = [ans[1] for ans in answers]
+
+ n_correct = 0
+ tin = None
+ for i, (output, correct) in enumerate(zip(outputs, test_out)):
+ if output.rstrip().endswith(correct):
+ n_correct += 1
+ else:
+ tin = test_in[i][1]
+ tout = correct
+
+ passed = n_correct == len(test_in)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin != None:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ hints.append({'id' : 'final_hint'})
+ return passed, hints
+
+def hint(python, code, aux_code=''):
+ # run one test first to see if there are any exceptions
+ test_in = [(None, '1\n')]
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ # if input is not present in code, student needs to learn about input
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['if']):
+ return [{'id' : 'if_clause'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/lists_and_if-fkkt/temp_converter/sl.py b/python/problems/lists_and_if-fkkt/temp_converter/sl.py
new file mode 100644
index 0000000..1ba9b5d
--- /dev/null
+++ b/python/problems/lists_and_if-fkkt/temp_converter/sl.py
@@ -0,0 +1,51 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Pretvarjanje temperatur'
+slug = 'Pretvarjanje temperatur'
+
+
+description = '''\
+<p>Napišite program, ki uporabnika vpraša po stopinjah Celzija in v katero enoto naj jih spremeni (Fahrenheit ali Kelvin). Program izpiše pretvorjeno vrednost. Če uporabnik vnese napačno vrednost, mu to tudi izpiše.<br>
+Iz Celzijev v Kelvine pretvarjamo tako, da stopinjam prištejemo 273,15. Iz Celzijev v Fahrenheite pa pretvarjamo tako, da stopinje pomnožimo z 9/5 in prištejemo 32.<br>
+Primer uporabe:</p>
+
+<pre><code>Vpiši temperaturo [°C]: <span style="color: rgb(239, 69, 64);">32</span>
+Želite pretvoriti v Kelvine (vpiši K) ali Fahrenheite (vpiši F)? <span style="color: rgb(239, 69, 64);">K</span>
+32.0 °C je enako 305.15 K
+
+Vpiši temperaturo [°C]: <span style="color: rgb(239, 69, 64);">23</span>
+Želite pretvoriti v Kelvine (vpiši K) ali Fahrenheite (vpiši F)? <span style="color: rgb(239, 69, 64);">F</span>
+23.0 °C je enako 73.4 °F
+
+Vpiši temperaturo [°C]: <span style="color: rgb(239, 69, 64);">13</span>
+Želite pretvoriti v Kelvine (vpiši K) ali Fahrenheite (vpiši F)? <span style="color: rgb(239, 69, 64);">C</span>
+Vnesli ste napačno enoto!
+</code></pre>
+'''
+
+if_clause = ['''\
+<p>Preveri, v katere enote želiš pretvoriti stopinje?</p>''',
+ '''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if pretvorba == 'K':
+</pre>''']
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabimo funkcijo <code>input</code></p>''',
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}