# coding=utf-8 from python.util import has_token_sequence from server.hints import Hint, HintSequence id = 180 group = 'introduction' number = 1 visible = True solution = '''\ f = float(input("Temperatura [F]: ")) c = 5/9 * (f – 32) print("Temperatura je", c, "C") ''' hint_type = { 'plan': Hint('plan'), 'no_input_call': Hint('no_input_call'), } def test(python, code): # List of inputs: (expression to eval, stdin). test_in = [ (None, '0\n'), (None, '100\n'), ] test_out = [ '-17.7', '37.7', ] # List of outputs: (expression result, stdout, stderr, exception). answers = python(code=code, inputs=test_in, timeout=1.0) outputs = [ans[1] for ans in answers] n_correct = 0 for output, correct in zip(outputs, test_out): if correct in output: n_correct += 1 return n_correct, len(test_in) def hint(python, code): if not code: return [{'id': 'plan'}] if not has_token_sequence(code, ['input']): return [{'id': 'no_input_call'}] return None