summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/problems/for-fkkt/all_multiple/common.py88
-rw-r--r--python/problems/for-fkkt/all_multiple/sl.py40
-rw-r--r--python/problems/for-fkkt/all_primes/common.py83
-rw-r--r--python/problems/for-fkkt/all_primes/sl.py34
-rw-r--r--python/problems/for-fkkt/any_multiple/common.py88
-rw-r--r--python/problems/for-fkkt/any_multiple/sl.py39
-rw-r--r--python/problems/for-fkkt/common.py2
-rw-r--r--python/problems/for-fkkt/en.py3
-rw-r--r--python/problems/for-fkkt/is_prime/common.py82
-rw-r--r--python/problems/for-fkkt/is_prime/sl.py35
-rw-r--r--python/problems/for-fkkt/min/common.py101
-rw-r--r--python/problems/for-fkkt/min/sl.py62
-rw-r--r--python/problems/for-fkkt/sl.py3
-rw-r--r--python/problems/for-fkkt/star_tree/common.py73
-rw-r--r--python/problems/for-fkkt/star_tree/sl.py34
-rw-r--r--python/problems/for-fkkt/star_triangle/common.py73
-rw-r--r--python/problems/for-fkkt/star_triangle/sl.py34
-rw-r--r--python/problems/for-fkkt/sum_and_average/common.py84
-rw-r--r--python/problems/for-fkkt/sum_and_average/sl.py33
-rw-r--r--python/problems/for-fkkt/sum_to_n/common.py74
-rw-r--r--python/problems/for-fkkt/sum_to_n/sl.py31
21 files changed, 1096 insertions, 0 deletions
diff --git a/python/problems/for-fkkt/all_multiple/common.py b/python/problems/for-fkkt/all_multiple/common.py
new file mode 100644
index 0000000..18087dc
--- /dev/null
+++ b/python/problems/for-fkkt/all_multiple/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 = 25016
+number = 4
+visible = True
+
+solution = '''\
+seznam = eval(input("Vpišite seznam števil: "))
+st = int(input("Vnesite število: "))
+
+samo_veckratniki = True
+for elt in seznam:
+ if elt % st != 0:
+ samo_veckratniki = False
+ break
+if samo_veckratniki:
+ print("Vsebuje.")
+else:
+ print("Ne vsebuje.")
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'no_eval_call' : Hint('no_eval_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '[]\n42\n'),
+ (None, '[3, 0]\n3\n'),
+ (None, '[27, 21, 3, 33, 60, -3]\n3\n'),
+ (None, '[27, 21, 3, 33, 60, -3]\n9\n')
+ ]
+ test_out = [
+ 'Vsebuje samo večkratnike',
+ 'Vsebuje samo večkratnike',
+ 'Vsebuje samo večkratnike',
+ 'Ne vsebuje samo večkratnikov'
+ ]
+
+ # 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 "Ne vsebuje" in correct and "ne vsebuje" in output.lower() \
+ or "Ne vsebuje" not in correct and "ne vsebuje" not in output.lower() and "vsebuje" in output.lower():
+ 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
+ answer = python(code=aux_code+code, inputs=[(None, '[12]\n12\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['eval']):
+ return [{'id': 'no_eval_call'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/for-fkkt/all_multiple/sl.py b/python/problems/for-fkkt/all_multiple/sl.py
new file mode 100644
index 0000000..8aa2333
--- /dev/null
+++ b/python/problems/for-fkkt/all_multiple/sl.py
@@ -0,0 +1,40 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Samo večkratniki'
+slug = 'Samo večkratniki'
+
+
+description = '''\
+<p>Napišite program, ki preveri, če seznam vsebuje le večkratnike števila, ki ga vnese uporabnik. Poskusite uporabiti tudi <code>break</code>.<br>
+Seznam števil naj vpiše uporabnik. Za pretvorbo vhodnega niza v seznam uporabite funkcijo <code>eval()</code>.<br>
+1. primer uporabe:</p>
+
+<pre><code>Vpišite seznam števil: <span style="color: rgb(239, 69, 64);">[27, 21, 3, 33, 60, -3]</span>
+Vnesite število: <span style="color: rgb(239, 69, 64);">3</span>
+Vsebuje samo večkratnike.
+</code></pre>
+
+<p>2. primer uporabe:</p>
+<pre><code>Vpišite seznam števil: <span style="color: rgb(239, 69, 64);">[27, 21, 3, 33, 60, -3]</span>
+Vnesite število: <span style="color: rgb(239, 69, 64);">9</span>
+Ne vsebuje samo večkratnikov.
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'no_eval_call': '''<p>Za pretvorbo niza v seznam uporabi funkcijo <code>eval</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/all_primes/common.py b/python/problems/for-fkkt/all_primes/common.py
new file mode 100644
index 0000000..3c121d8
--- /dev/null
+++ b/python/problems/for-fkkt/all_primes/common.py
@@ -0,0 +1,83 @@
+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 = 25021
+number = 9
+visible = True
+
+solution = '''\
+n = int(input("Vpiši število: "))
+stevec = 0
+for i in range(2, n + 1):
+ prastevilo = True
+ for j in range(2, int(i**(1/2))+1):
+ if i % j == 0:
+ prastevilo = False
+ break
+ if prastevilo:
+ stevec += 1
+print(stevec)
+
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '2\n'),
+ (None, '3\n'),
+ (None, '7\n'),
+ (None, '12\n')
+ ]
+ test_out = [
+ '0',
+ '1',
+ '3',
+ '5'
+ ]
+
+ # 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
+ answer = python(code=aux_code+code, inputs=[(None, '2\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ 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/for-fkkt/all_primes/sl.py b/python/problems/for-fkkt/all_primes/sl.py
new file mode 100644
index 0000000..b86dbae
--- /dev/null
+++ b/python/problems/for-fkkt/all_primes/sl.py
@@ -0,0 +1,34 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Praštevila'
+slug = 'Praštevila'
+
+
+description = '''\
+<p>Napišite program, ki izpiše, koliko praštevil je manjših od števila n.
+<br>
+Primer uporabe:</p>
+
+<pre><code>Vpiši število: <span style="color: rgb(239, 69, 64);">12</span>
+5
+</code></pre>
+
+
+<p>Če si bo program za število 50000 vzel preveč časa (beri: se ne bo izvedel dovolj hitro), poskusi optimizirati rešitev. Za še večja števila (npr. 1000000) se pa poskusi poigrati z <a href="https://sl.wikipedia.org/wiki/Eratostenovo_sito">Eratostenovim sitom</a>.</p>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/any_multiple/common.py b/python/problems/for-fkkt/any_multiple/common.py
new file mode 100644
index 0000000..7ebf397
--- /dev/null
+++ b/python/problems/for-fkkt/any_multiple/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 = 25015
+number = 3
+visible = True
+
+solution = '''\
+seznam = eval(input("Vpišite seznam števil: "))
+st = int(input("Vnesite število: "))
+
+vsebuje = False
+for elt in seznam:
+ if elt % st == 0:
+ vsebuje = True
+ break
+if vsebuje:
+ print("Vsebuje.")
+else:
+ print("Ne vsebuje.")
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'no_eval_call' : Hint('no_eval_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '[]\n42\n'),
+ (None, '[3, 0]\n3\n'),
+ (None, '[23, 42, 87, 34, 1, -3, 2]\n3\n'),
+ (None, '[23, 42, 87, 34, 1, -3, 2]\n8\n')
+ ]
+ test_out = [
+ 'Ne vsebuje',
+ 'Vsebuje',
+ 'Vsebuje',
+ 'Ne vsebuje'
+ ]
+
+ # 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 "Ne vsebuje" in correct and "ne vsebuje" in output.lower() \
+ or "Ne vsebuje" not in correct and "ne vsebuje" not in output.lower() and "vsebuje" in output.lower():
+ 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
+ answer = python(code=aux_code+code, inputs=[(None, '[12]\n12\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['eval']):
+ return [{'id': 'no_eval_call'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/for-fkkt/any_multiple/sl.py b/python/problems/for-fkkt/any_multiple/sl.py
new file mode 100644
index 0000000..ba24187
--- /dev/null
+++ b/python/problems/for-fkkt/any_multiple/sl.py
@@ -0,0 +1,39 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Iskanje večkratnikov'
+slug = 'Iskanje večkratnikov'
+
+
+description = '''\
+<p>Napišite program, ki preveri, če seznam vsebuje vsaj en večkratnik števila, ki ga vnese uporabnik. Poskusite uporabiti tudi <code>break</code>.<br>
+Seznam števil naj vpiše uporabnik. Za pretvorbo vhodnega niza v seznam uporabite funkcijo <code>eval()</code>.<br>
+1. primer uporabe:</p>
+
+<pre><code>Vpišite seznam števil: <span style="color: rgb(239, 69, 64);">[23, 42, 87, 34, 1, -3, 2]</span>
+Vnesite število: <span style="color: rgb(239, 69, 64);">3</span>
+Vsebuje.</code></pre>
+
+<p>2. primer uporabe:</p>
+<pre><code>Vpišite seznam števil: <span style="color: rgb(239, 69, 64);">[23, 42, 87, 34, 1, -3, 2]</span>
+Vnesite število: <span style="color: rgb(239, 69, 64);">8</span>
+Ne vsebuje.
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'no_eval_call': '''<p>Za pretvorbo niza v seznam uporabi funkcijo <code>eval</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/common.py b/python/problems/for-fkkt/common.py
new file mode 100644
index 0000000..ab348a2
--- /dev/null
+++ b/python/problems/for-fkkt/common.py
@@ -0,0 +1,2 @@
+id = 2502
+number = 12
diff --git a/python/problems/for-fkkt/en.py b/python/problems/for-fkkt/en.py
new file mode 100644
index 0000000..5757341
--- /dev/null
+++ b/python/problems/for-fkkt/en.py
@@ -0,0 +1,3 @@
+name = 'For loop - FKKT'
+description = 'For loop'
+
diff --git a/python/problems/for-fkkt/is_prime/common.py b/python/problems/for-fkkt/is_prime/common.py
new file mode 100644
index 0000000..1b80247
--- /dev/null
+++ b/python/problems/for-fkkt/is_prime/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 = 25020
+number = 8
+visible = True
+
+solution = '''\
+n = int(input("Vpiši število: "))
+
+if n == 1:
+ print(False)
+else:
+ prastevilo = True
+ for j in range(2, n):
+ if n % j == 0:
+ prastevilo = False
+ break
+ print(prastevilo)
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '1\n'),
+ (None, '191\n'),
+ (None, '22\n'),
+ (None, '13\n')
+ ]
+ test_out = [
+ 'False',
+ 'True',
+ 'False',
+ 'True'
+ ]
+
+ # 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
+ answer = python(code=aux_code+code, inputs=[(None, '2\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ 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/for-fkkt/is_prime/sl.py b/python/problems/for-fkkt/is_prime/sl.py
new file mode 100644
index 0000000..34316be
--- /dev/null
+++ b/python/problems/for-fkkt/is_prime/sl.py
@@ -0,0 +1,35 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Praštevilo'
+slug = 'Praštevilo'
+
+
+description = '''\
+<p>Napišite program, ki za vnešeno število preveri, ali je praštevilo.
+<br>
+1. primer uporabe:</p>
+<pre><code>Vpiši število: <span style="color: rgb(239, 69, 64);">13</span>
+True
+</code></pre>
+
+<p>2. primer uporabe:</p>
+<pre><code>Vpiši število: <span style="color: rgb(239, 69, 64);">22</span>
+False
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/min/common.py b/python/problems/for-fkkt/min/common.py
new file mode 100644
index 0000000..ede7619
--- /dev/null
+++ b/python/problems/for-fkkt/min/common.py
@@ -0,0 +1,101 @@
+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 = 25013
+number = 1
+visible = True
+
+solution = '''\
+seznam = [23, 42, 87, 34, 1, -3, 2]
+minimum = seznam[0]
+for elt in seznam:
+ if elt < minimum:
+ minimum = elt
+print(minimum)
+'''
+
+hint_type = {
+ 'no_xs': Hint('no_xs'),
+ 'for_loop': Hint('for_loop'),
+ 'if_clause': Hint('if_clause'),
+ 'printing': Hint('printing'),
+ 'no_min': Hint('no_min'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ if has_token_sequence(tokens, ['min', '(']):
+ return False, [{'id': 'no_min'}]
+
+ test_xs = [[5, 4, -7, 2, 12, -3, -4, 11, 2],
+ [0],
+ [3, 1, 2, 8],
+ [1, 2, 3, 42],
+ [23, 42, 87, 34, 1, -3, 2]]
+ test_out = [
+ '-7',
+ '0',
+ '1',
+ '1',
+ '-3'
+ ]
+
+ 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 output.rstrip().endswith(test_out[xs_i]):
+ 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 does not have for: instruct him on loops
+ if not has_token_sequence(tokens, ['for']):
+ return [{'id' : 'for_loop'}]
+
+ if has_token_sequence(tokens, ['min', '(']):
+ return [{'id': 'no_min'}]
+
+ 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/for-fkkt/min/sl.py b/python/problems/for-fkkt/min/sl.py
new file mode 100644
index 0000000..58b5e11
--- /dev/null
+++ b/python/problems/for-fkkt/min/sl.py
@@ -0,0 +1,62 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Najmanjše število v seznamu'
+slug = 'Najmanjše število v seznamu'
+
+
+description = '''\
+<p>Napišite program, ki poišče in izpiše najmanjši element v seznamu brez uporabe funkcije <code>min()</code>!<br>
+Seznam definirajte na vrhu programa <code>seznam = [23, 42, 87, 34, 1, -3, 2]</code><br>
+Izpis:</p>
+
+<pre><code>-3</code></pre>
+
+<p>Seveda mora program delovati tudi za vse druge sezname!</p>
+'''
+
+if_clause = ['''\
+<p>Uporabi pogojni stavek <code>if</code>!</p>''',
+ '''\
+<pre>
+if elt < minimum:
+</pre>''']
+
+for_loop = ['''\
+<p>Pregledati bo treba vse elemente v seznamu <code>seznam</code>''',
+ '''\
+<p>Najlažje bo s <code>for</code> zanko.
+''',
+ '''\
+<p>Poskusi naslednji dve vrstici:</p>
+<pre>
+for elt in seznam:
+ print (elt)
+</pre>''',
+ '''\
+<p>V zgornjem primeru z zanko <code>for</code> Pythonu naročimo naj se sprehodi čez seznam <code>seznam</code>
+in na vsakem koraku trenutni element seznama shrani v spremenljivko <code>elt</code>.
+Kaj naj Python naredi s to spremenljivko, je zapisano v zamaknjenih vrsticah.
+Tokrat vrednost le izpišemo.</p>''']
+
+
+plan = []
+
+hint = {
+ 'no_xs': ['''\
+<p>Program mora imeti na začetku definiran seznam <code>seznam</code>.</p>'''],
+
+ 'no_min': '''Funkcija <code>min()</code> ni dovoljena pri tej nalogi!''',
+
+ 'for_loop': for_loop,
+
+ 'if_clause': if_clause,
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/sl.py b/python/problems/for-fkkt/sl.py
new file mode 100644
index 0000000..7a277c0
--- /dev/null
+++ b/python/problems/for-fkkt/sl.py
@@ -0,0 +1,3 @@
+name = 'For zanka - FKKT'
+description = 'Naloge s for zanko'
+
diff --git a/python/problems/for-fkkt/star_tree/common.py b/python/problems/for-fkkt/star_tree/common.py
new file mode 100644
index 0000000..607e0a9
--- /dev/null
+++ b/python/problems/for-fkkt/star_tree/common.py
@@ -0,0 +1,73 @@
+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 = 25019
+number = 7
+visible = True
+
+solution = '''\
+n = int(input('Vpiši višino: '))
+
+for i in range(1, n + 1):
+ print(' ' * (n - i) + '*' * (2 * i - 1))
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '1\n'),
+ (None, '3\n'),
+ (None, '4\n')
+ ]
+ test_out = [
+ '*',
+ ' *\n ***\n*****',
+ ' *\n ***\n *****\n*******',
+ ]
+
+ # 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
+ answer = python(code=aux_code+code, inputs=[(None, '2\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ 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/for-fkkt/star_tree/sl.py b/python/problems/for-fkkt/star_tree/sl.py
new file mode 100644
index 0000000..484632c
--- /dev/null
+++ b/python/problems/for-fkkt/star_tree/sl.py
@@ -0,0 +1,34 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Izris smrekice'
+slug = 'Izris smrekice'
+
+
+description = '''\
+<p>Napišite program, ki bo namesto trikotnikov izrisoval smrekice.
+<br>
+Primer uporabe:</p>
+
+<pre><code>Vpiši višino: <span style="color: rgb(239, 69, 64);">4</span>
+ *
+ ***
+ *****
+*******
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/star_triangle/common.py b/python/problems/for-fkkt/star_triangle/common.py
new file mode 100644
index 0000000..ff4c5a4
--- /dev/null
+++ b/python/problems/for-fkkt/star_triangle/common.py
@@ -0,0 +1,73 @@
+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 = 25018
+number = 6
+visible = True
+
+solution = '''\
+n = int(input('Vpiši višino: '))
+
+for i in range(1, n + 1):
+ print('*' * i)
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '1\n'),
+ (None, '3\n'),
+ (None, '4\n')
+ ]
+ test_out = [
+ '*',
+ '*\n**\n***',
+ '*\n**\n***\n****',
+ ]
+
+ # 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
+ answer = python(code=aux_code+code, inputs=[(None, '2\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ 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/for-fkkt/star_triangle/sl.py b/python/problems/for-fkkt/star_triangle/sl.py
new file mode 100644
index 0000000..9ed5a5e
--- /dev/null
+++ b/python/problems/for-fkkt/star_triangle/sl.py
@@ -0,0 +1,34 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Izris trikotnika'
+slug = 'Izris trikotnika'
+
+
+description = '''\
+<p>Po programerski tradiciji eden prvih programov, ki jih napišemo v določenem programskem jeziku, nariše trikotnik iz zvezdic. Napišite program, ki vpraša uporabnika po višini trikotnika, nato pa izpiše takšen trikotnik iz zvezdic.
+<br>
+Primer uporabe:</p>
+
+<pre><code>Vpiši višino: <span style="color: rgb(239, 69, 64);">4</span>
+*
+**
+***
+****
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/sum_and_average/common.py b/python/problems/for-fkkt/sum_and_average/common.py
new file mode 100644
index 0000000..44815ec
--- /dev/null
+++ b/python/problems/for-fkkt/sum_and_average/common.py
@@ -0,0 +1,84 @@
+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 = 25014
+number = 2
+visible = True
+
+solution = '''\
+seznam = eval(input("Vpišite seznam števil: "))
+vsota = 0
+for elt in seznam:
+ vsota += elt
+print(vsota)
+if len(seznam) != 0:
+ print(vsota/len(seznam))
+else:
+ print(0)
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'no_eval_call' : Hint('no_eval_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '[]\n'),
+ (None, '[-1, -2, -3]\n'),
+ (None, '[2, 4, 6, 8, 10]\n'),
+ (None, '[23, 42, 87, 34, 1, -3, 2]\n')
+ ]
+ test_out = [
+ '0\n0',
+ '-6\n-2.0',
+ '30\n6.0',
+ '186\n26.571428571428573'
+ ]
+
+ # 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
+ answer = python(code=aux_code+code, inputs=[(None, '[-1, -2, -3]\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ if not has_token_sequence(tokens, ['input']):
+ return [{'id': 'no_input_call'}]
+
+ if not has_token_sequence(tokens, ['eval']):
+ return [{'id': 'no_eval_call'}]
+
+ # student is not using print function
+ if not has_token_sequence(tokens, ['print']):
+ return [{'id' : 'printing'}]
+
+ return None
diff --git a/python/problems/for-fkkt/sum_and_average/sl.py b/python/problems/for-fkkt/sum_and_average/sl.py
new file mode 100644
index 0000000..4ed8b69
--- /dev/null
+++ b/python/problems/for-fkkt/sum_and_average/sl.py
@@ -0,0 +1,33 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Vsota in povprečje'
+slug = 'Vsota in povprečje'
+
+
+description = '''\
+<p>Napišite program, ki za podani seznam izračuna vsoto in povprečje elementov.<br>
+Seznam števil naj vpiše uporabnik. Za pretvorbo vhodnega niza v seznam uporabite funkcijo <code>eval()</code>.<br>Primer uporabe:</p>
+
+<pre><code>Vpišite seznam števil: <span style="color: rgb(239, 69, 64);">[23, 42, 87, 34, 1, -3, 2]</span>
+186
+26.571428571428573
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'no_eval_call': '''<p>Za pretvorbo niza v seznam uporabi funkcijo <code>eval</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}
diff --git a/python/problems/for-fkkt/sum_to_n/common.py b/python/problems/for-fkkt/sum_to_n/common.py
new file mode 100644
index 0000000..d61612e
--- /dev/null
+++ b/python/problems/for-fkkt/sum_to_n/common.py
@@ -0,0 +1,74 @@
+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 = 25017
+number = 5
+visible = True
+
+solution = '''\
+st = int(input("Vpiši število: "))
+vsota = 0
+for x in range(1, st + 1):
+ vsota += x
+print(vsota)
+'''
+
+hint_type = {
+ 'no_input_call' : Hint('no_input_call'),
+ 'printing': Hint('printing'),
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code, aux_code=''):
+ tokens = get_tokens(code)
+
+ test_in = [
+ (None, '0\n'),
+ (None, '120\n'),
+ (None, '7\n')
+ ]
+ test_out = [
+ '0',
+ '7260',
+ '28'
+ ]
+
+ # 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
+ answer = python(code=aux_code+code, inputs=[(None, '12\n')], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ tokens = get_tokens(code)
+
+ 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/for-fkkt/sum_to_n/sl.py b/python/problems/for-fkkt/sum_to_n/sl.py
new file mode 100644
index 0000000..c7c11de
--- /dev/null
+++ b/python/problems/for-fkkt/sum_to_n/sl.py
@@ -0,0 +1,31 @@
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+name = 'Vsota n naravnih števil'
+slug = 'Vsota n naravnih števil'
+
+
+description = '''\
+<p>Napišite program, ki izračuna vsoto prvih <code>n</code> naravnih števil. Število <code>n</code> poda uporabnik. Če uporabnik vpiše <code>7</code>, mora program izpisati <code>28</code>, saj je <code>1 + 2 + 3 + 4 + 5 + 6 + 7 = 28</code>.
+<br>
+Primer uporabe:</p>
+
+<pre><code>Vpiši število: <span style="color: rgb(239, 69, 64);">7</span>
+28
+</code></pre>
+'''
+
+
+plan = []
+
+hint = {
+ 'no_input_call': '''<p>Za branje uporabi funkcijo <code>input</code></p>''',
+
+ 'printing': ['''\
+<p>Izpiši rezultat.</p>'''],
+
+ 'final_hint': ['''\
+<p>Program deluje pravilno!</p>'''],
+
+}