示例#1
0
def make_transformations():

    ''
    global a
    global d
    global str_a
    global int_a
    global dic
    global _2
    global _3_decision
    global _4
    global _4_decision
    global _5
    
    # question
    _135 = str(randint(1000000, 2000000))
    [a, n, x, d, dic] = sample(string.ascii_lowercase, 5)
    _13 = randint(19000, 20000)
    _3 = randint(0, 5)
    _33 = randint(_3, 500)
    str_a = 'str_' + a
    int_a = 'int_' + a
    
    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('n', n)
    change_token_all_occurrences('x', x)
    change_token_all_occurrences('d', d)
    change_token_all_occurrences('dic', dic)
    change_token_all_occurrences('str_a', str_a)
    change_token_all_occurrences('int_a', int_a)
    change_all_occurrences('13', str(_13))
    change_all_occurrences('3', str(_3))
    change_all_occurrences('33', str(_33))

    # answers
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')
    change_all_occurrences(r'\verb+d+', r'\verb+' + d + '+')
    change_all_occurrences(r'\verb+dic+', r'\verb+' + dic + '+')
    
    # indexes with no repetitions
    _2 = choice((d, str_a, int_a, a))
    _3_decision = choice(("int", "float", "str"))
    _4 = choice(ascii_letters)
    _5 = choice(("maior", "menor"))

    change_all_occurrences(r'\verb+2+', r'\verb+' + _2 + '+')
    change_all_occurrences(r'\verb+4+', r'\verb+' + _4 + '+')
    change_all_occurrences(r'\verb+4_t+', r'\verb+"' + _4 + '"+')
    _4_decision = choice((0, 1))
    if _4_decision == 0:
        change_all_occurrences(r'\verb+4_f+', r'\verb+"' + _4 + '"+')
    else:
        change_all_occurrences(r'\verb+4_f+', r'\verb+' + _4 + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + _5 + '+')
def make_transformations():
    ''
    global a
    global d
    global _1
    global _2
    global _3
    global _4
    global _5
    global _10
    global _20
    global _33
    global decision
    global _func5
    
    # question
    _135 = str(randint(1000000, 2000000))
    [a, b, d, l, k, i] = sample(string.ascii_lowercase, 6)
    _10 = randint(18000, 20000)
    _50 = randint(50, 150)
    _20 = _10 * randint(2, 4)
    _33 = randint(2, 5)
    
    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('b', b)
    change_token_all_occurrences('d', d)
    change_token_all_occurrences('l', l)
    change_token_all_occurrences('k', k)
    change_token_all_occurrences('i', i)
    change_all_occurrences('10', str(_10))
    change_all_occurrences('50', str(_50))
    change_all_occurrences('20', str(_20))
    change_all_occurrences('3', str(_33))

    func1 = choice(('[::-1].sort()', '[-1::].sort()', '[:-1:].sort()'))
    func2 = 'sort(reverse=True)'
    func3 = ['sort(key=len)', 'sort()',
             'sort(key=len, reverse=True)', 'sort(reverse=True)']
    ab = [b, a]
    decision = choice((0, 1, 2, 3))
    # answers
    change_all_occurrences(r'\verb+_33+', r'\verb+' + str(_33) + '+')
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')
    change_all_occurrences(r'\verb+b+', r'\verb+' + b + '+')
    change_all_occurrences(r'\verb+ab+', r'\verb+' + ab[decision % 2] + '+')
    change_all_occurrences(r'\verb+d+', r'\verb+' + d + '+')
    change_all_occurrences(r'\verb+func1+', r'\verb+' + func1 + '+')
    change_all_occurrences(r'\verb+func2+', r'\verb+' + func2 + '+')
    change_all_occurrences(r'\verb+func3+', r'\verb+' + func3[decision] + '+')
    # indexes with no repetitions
    _5 = choice((2, 3, 4, 5))
    _func5 = choice(('primeiros', 'ultimos'))

    [_3] = sample(range(_50), 1)
    change_all_occurrences(r'\verb+2+', r'\verb+' + _func5[decision] + '+')
    change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')
    change_all_occurrences(r'\verb+func5+', r'\verb+' + _func5 + '+')
示例#3
0
def make_transformations_on_results(program):
    ''
    global a
    global b
    global _1
    global _2_1
    global _2_2
    global _3_1
    global _3_2
    global _3_1_f
    global _3_2_f
    global _4
    global _5_1
    global _5_2
    global __var
    global var
    global P
    global p

    print('»»»»»»»»»')
    the_list = program.get_global(a)
    the_list_b = program.get_global(b)
    #correct index for question 5
    _5_1, _5_2 = choose_correct_idx_5(the_list)
    change_all_occurrences(
        r'\verb+5_1+', "<b><font color=green><i>" + r'\verb+' + str(_5_1) +
        '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+5_2+', "<b><font color=green><i>" + r'\verb+' + str(_5_2) +
        '+' + "</font></i></b>")

    answer_1_true = regular_search(_1, the_list_b)
    new_b = regular_subtitution(_2_1, _2_2, the_list_b)
    answer_2_true = round(
        regular_search(_2_2, new_b) / regular_search(_2_2, the_list_b), 2)
    answer_4_true = regular_match(_4, the_list_b)
    answer_5_true = power(the_list[_5_1].num, the_list[_5_2].num)

    # true answers
    change_all_occurrences(
        r'\verb+11+',
        "<b><font color=green><i>" + str(answer_1_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+22+',
        "<b><font color=green><i>" + str(answer_2_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+44+',
        "<b><font color=green><i>" + str(answer_4_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+55+',
        "<b><font color=green><i>" + str(answer_5_true) + "</font></i></b>")

    # wrong answers
    increment2 = choice([.1, -.1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = _1
    answer_2_false = round(answer_2_true + increment2, 2)
    answer_4_false = answer_4_true + increment4
    answer_5_false = answer_5_true + increment5

    change_all_occurrences(
        r'\verb+111+',
        "<b><font color=green><i>" + str(answer_1_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+222+',
        "<b><font color=green><i>" + str(answer_2_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+444+',
        "<b><font color=green><i>" + str(answer_4_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+555+',
        "<b><font color=green><i>" + str(answer_5_false) + "</font></i></b>")
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global f
    global _1
    global _2
    global _3
    global _4
    global _5

    print('»»»»»»»»»')
    print(a)
    the_list = program.get_global(a)
    the_3rdlist = program.get_global(f)
    #print(the_list)
    answer_1_true = the_list[_1]
    answer_2_true = the_3rdlist[_2]
    answer_3_true = the_list[_3]
    answer_4_true = the_3rdlist[_4]
    answer_5_true = the_list[_5]

    # true answers
    change_all_occurrences(r'\verb+11+',
                           "<b><i>" + str(answer_1_true) + "</b></i>")
    change_all_occurrences(r'\verb+22+',
                           "<b><i>" + str(answer_2_true) + "</b></i>")
    change_all_occurrences(r'\verb+33+',
                           "<b><i>" + str(answer_3_true) + "</b></i>")
    change_all_occurrences(r'\verb+44+',
                           "<b><i>" + str(answer_4_true) + "</b></i>")
    change_all_occurrences(r'\verb+55+',
                           "<b><i>" + str(answer_5_true) + "</b></i>")

    # wrong answers
    increment1 = choice([1, -1])
    increment2 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = the_list[_1] + increment1
    answer_2_false = the_3rdlist[_2 + increment2]
    answer_3_false = the_list[_3] + increment3
    answer_4_false = the_3rdlist[_4 + increment4]
    answer_5_false = the_list[_5] + increment5
    change_all_occurrences(r'\verb+111+',
                           "<b><i>" + str(answer_1_false) + "</b></i>")
    change_all_occurrences(r'\verb+222+',
                           "<b><i>" + str(answer_2_false) + "</b></i>")
    change_all_occurrences(r'\verb+333+',
                           "<b><i>" + str(answer_3_false) + "</b></i>")
    change_all_occurrences(r'\verb+444+',
                           "<b><i>" + str(answer_4_false) + "</b></i>")
    change_all_occurrences(r'\verb+555+',
                           "<b><i>" + str(answer_5_false) + "</b></i>")
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global b
    global c
    global _1
    global _2
    global _3
    global _4
    global _5
    global rgb_idx
    global limiar

    the_list = program.get_global(a)
    the_2nd_list = []
    the_3rd_list = []

    for pixel in the_list:
        the_2nd_list.append(round(rgb2gray(pixel),2))

    for pixel in the_2nd_list:
        the_3rd_list.append(treshold(pixel,limiar))

    answer_1_true = numOfIndexPixelsBiggerThanX(rgb_idx, the_list, _1)
    answer_2_true = the_2nd_list[_2]
    answer_3_true = numPixels(the_3rd_list, _3)
    answer_4_true = (np.array(the_list)).size / (np.array(the_3rd_list)).size
    answer_5_true = the_list[_5]

    # true answers
    change_all_occurrences(r'\verb+11+',"<b><font color=red><i>" +  str(answer_1_true)+ "</font></i></b>")
    change_all_occurrences(r'\verb+22+',"<b><font color=red><i>" +  str(answer_2_true)+ "</font></i></b>")
    change_all_occurrences(r'\verb+33+',"<b><font color=red><i>" +  str(answer_3_true)+ "</font></i></b>")
    change_all_occurrences(r'\verb+44+',"<b><font color=red><i>" +  str(answer_4_true)+ "</font></i></b>")
    change_all_occurrences(r'\verb+55+',"<b><font color=red><i>" +  str(answer_5_true)+ "</font></i></b>")

    # wrong answers
    increment1 = choice([1, -1])
    increment2 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = answer_1_true + increment1
    answer_2_false = answer_2_true + increment2
    answer_3_false = answer_3_true + increment3
    answer_4_false = answer_4_true + increment4
    answer_5_false = the_list[_5 + increment5]

    change_all_occurrences(r'\verb+111+',"<b><font color=red><i>" +  str(answer_1_false)+ "</font></i></b>")
    change_all_occurrences(r'\verb+222+',"<b><font color=red><i>" +  str(answer_2_false)+ "</font></i></b>")
    change_all_occurrences(r'\verb+333+',"<b><font color=red><i>" +  str(answer_3_false)+ "</font></i></b>")
    change_all_occurrences(r'\verb+444+',"<b><font color=red><i>" +  str(answer_4_false)+ "</font></i></b>")
    change_all_occurrences(r'\verb+555+',"<b><font color=red><i>" +  str(answer_5_false)+ "</font></i></b>")
示例#6
0
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global p
    global _1_1
    global _1_2
    global _1_3
    global _2
    global _3
    global _4
    global _5

    print('»»»»»»»»»')
    the_list = program.get_global(a)
    pt_a = "ã".encode('utf8').decode('iso-8859-1')
    pt_e = "é".encode('utf8').decode('iso-8859-1')
    answer_1_true = "" if _1_1 == "Com" else "n" + pt_a + "o"
    answer_2_true = "pode ser semelhante" if quest_2_type == "correct" else choice(
        (pt_e + " igual", pt_e + " diferente"))
    answer_3_true = p + "[index] = value" if _3 == "alterar o" else p + "[index]"
    answer_4_true = "uma string"
    answer_5_true = choice(
        ("o tamanho da lista menos um elemento", str(_13 - 1)))

    # true answers
    change_all_occurrences(r'\verb+11+', "<b><i>" + answer_1_true + "</b></i>")
    change_all_occurrences(r'\verb+22+', "<b><i>" + answer_2_true + "</b></i>")
    change_all_occurrences(r'\verb+33+', "<b><i>" + answer_3_true + "</b></i>")
    change_all_occurrences(r'\verb+44+', "<b><i>" + answer_4_true + "</b></i>")
    change_all_occurrences(r'\verb+55+', "<b><i>" + answer_5_true + "</b></i>")

    # wrong answers
    answer_1_false = "n" + pt_a + "o" if _1_1 == "Com" else ""
    answer_2_false = choice(
        (pt_e + " igual", pt_e +
         " diferente")) if quest_2_type == "correct" else "pode ser semelhante"
    answer_3_false = answer_3_true
    answer_4_false = choice(("lista", "lista de ints", "lista de strings"))
    answer_5_false = choice(
        ("o tamanho da lista", "o tamanho da lista que " + pt_e + str(_13),
         "o tamanho da lista que " + pt_e + str(_13 - 1), str(_13)))

    change_all_occurrences(r'\verb+111+',
                           "<b><i>" + answer_1_false + "</b></i>")
    change_all_occurrences(r'\verb+222+',
                           "<b><i>" + answer_2_false + "</b></i>")
    change_all_occurrences(r'\verb+333+',
                           "<b><i>" + answer_3_false + "</b></i>")
    change_all_occurrences(r'\verb+444+',
                           "<b><i>" + answer_4_false + "</b></i>")
    change_all_occurrences(r'\verb+555+',
                           "<b><i>" + answer_5_false + "</b></i>")
示例#7
0
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global _1
    global _2_1
    global _2_2
    global __var
    global var
    global P
    global p

    print('»»»»»»»»»')
    print(a)
    the_list = program.get_global(a)
    #correct index for question 5
    _5 = choose_correct_idx_5(the_list)
    change_all_occurrences(
        r'\verb+5+', "<b><font color=green><i>" + r'\verb+' + str(_5) + '+' +
        "</i></font></b>")

    answer_1_true = 1
    p1 = the_list[_2_1].num
    p2 = the_list[_2_2].num
    if p2 == 0 or ((p1 / p2) % 2 == 0):
        answer_2_true = 3
    else:
        answer_2_true = 4
    answer_3_true = p + '.\_' + P + '\_\_' + var
    answer_4_true = 0
    answer_5_true = factorial(the_list[_5].num)

    # true answers
    change_all_occurrences(
        r'\verb+11+',
        "<b><font color=green><i>" + str(answer_1_true) + "</i></font></b>")
    change_all_occurrences(
        r'\verb+22+',
        "<b><font color=green><i>" + str(answer_2_true) + "</i></font></b>")
    change_all_occurrences(
        r'\verb+33+',
        "<b><font color=green><i>" + answer_3_true + "</i></font></b>")
    change_all_occurrences(
        r'\verb+44+',
        "<b><font color=green><i>" + str(answer_4_true) + "</i></font></b>")
    change_all_occurrences(
        r'\verb+55+',
        "<b><font color=green><i>" + str(answer_5_true) + "</i></font></b>")

    # wrong answers
    increment2 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = _1
    if p2 == 0 or ((p1 / p2) % 2 == 0):
        answer_2_false = 4
    else:
        answer_2_false = 3
    wrong_answer_3 = choice(
        (p + '.' + '\_\_' + var, P + '.' + '\_\_' + var,
         p + '.\_' + P + '\_' + var, P + '.' + var, p + '.' + var))
    answer_3_false = wrong_answer_3
    wrong_answer_4 = choice(('Undifined', 'None', 'Null'))
    answer_4_false = wrong_answer_4
    answer_5_false = answer_5_true + increment5

    change_all_occurrences(
        r'\verb+111+',
        "<b><font color=green><i>" + str(answer_1_false) + "</i></font></b>")
    change_all_occurrences(
        r'\verb+222+',
        "<b><font color=green><i>" + str(answer_2_false) + "</i></font></b>")
    change_all_occurrences(
        r'\verb+333+',
        "<b><font color=green><i>" + answer_3_false + "</i></font></b>")
    change_all_occurrences(
        r'\verb+444+',
        "<b><font color=green><i>" + answer_4_false + "</i></font></b>")
    change_all_occurrences(
        r'\verb+555+',
        "<b><font color=green><i>" + str(answer_5_false) + "</i></font></b>")
def make_transformations():

    ''
    global a
    global _1
    global _3
    global _4
    global _5
    global idx_m1
    global idx_m2
    global answer_2_decision
    global answer_2_index
    global cl_1
    global cl_2
    global v1
    global v2

    # question
    _135 = str(randint(1000000, 2000000))
    a = choice(string.ascii_lowercase)  # ERROR: isto está mal!!!  a letra 'a'
    # não pode ser uma letra qualquer. porque se for igual a 'n' como
    # há no programa uma variável 'n' isto vai causar um erro
    # deexecuçaõ. Intermitente, o que ainda é pior
    # soluções possíveis:
    # 1. escolher uma letra qualquer execto o 'n'
    # 2. substituir também a variável 'n' escolhendo duas letras diferentes
    # vai ser usada a solução 2 porque assim as versões ainda ficam
    # mais diferentes. a variável 'n' passa também a ser diferente
    [a, n] = sample(string.ascii_lowercase, 2)
    _13 = randint(19000, 20000)
    _133 = randint(-50, 100)
    _255 = randint(101, 255)

    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('n', n)
    change_all_occurrences('13', str(_13))
    change_all_occurrences('133', str(_133))
    change_all_occurrences('255', str(_255))

    idx_m1, idx_m2 = idx_getter(_13)
    cl_1, v1, cl_2, v2 = cl_v_getter()
    answer_2_decision = choice(("coluna", "linha"))
    answer_2_index = choice(range(3))
    answer_2_index_str = "primeira" if answer_2_index == 0 else "segunda" if answer_2_index == 1 else "terceira"
    change_all_occurrences(r'\verb+cl_1+', r'\verb+' + cl_1 + '+')
    change_all_occurrences(r'\verb+cl_2+', r'\verb+' + cl_2 + '+')
    change_all_occurrences(r'\verb+v1+', r'\verb+' + str(v1) + '+')
    change_all_occurrences(r'\verb+v2+', r'\verb+' + str(v2) + '+')
    change_all_occurrences(r'\verb+idx_m1+', r'\verb+' + str(idx_m1) + '+')
    change_all_occurrences(r'\verb+idx_m2+', r'\verb+' + str(idx_m2) + '+')
    change_all_occurrences(r'\verb+answer_2_decision+',
                           r'\verb+' + str(answer_2_decision) + '+')
    change_all_occurrences(r'\verb+answer_2_index+',
                           r'\verb+' + answer_2_index_str + '+')
    # answers
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')

    # indexes with no repetitions
    [_1, _3, _4, _5] = sample(range(_13), 4)

    change_all_occurrences(r'\verb+1+', r'\verb+' + str(_1) + '+')
    change_all_occurrences(r'\verb+2+', r'\verb+' + str(idx_m1) + '+')
    change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+')
    change_all_occurrences(r'\verb+4+', r'\verb+' + str(_4) + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global _1
    global _2
    global _3
    global _4
    global _5
    global the_list

    the_list = program.get_global(a)

    letter = choice(the_list[_1])
    change_all_occurrences(
        r'\verb+1+', "<b><font color=red><i>" + r'\verb+' + letter + '+' +
        "</font></i></b>")
    word, equasion = choice_to_do()
    change_all_occurrences(
        r'\verb+2+',
        "<b><font color=red><i>" + r'\verb+' + word + '+' + "</font></i></b>")
    letter_2, max_occur = max_num_occurences(the_list)
    change_all_occurrences(
        r'\verb+4+', "<b><font color=red><i>" + r'\verb+' + letter_2 + '+' +
        "</font></i></b>")
    answer_1_true = letter_occurence(letter, the_list[_1])
    answer_2_true = equasion
    answer_3_true = the_list[_3]
    answer_4_true = max_occur
    answer_5_true = len(the_list[_5])

    # true answers
    change_all_occurrences(
        r'\verb+11+',
        "<b><font color=red><i>" + str(answer_1_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+22+',
        "<b><font color=red><i>" + str(answer_2_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+33+',
        "<b><font color=red><i>" + str(answer_3_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+44+',
        "<b><font color=red><i>" + str(answer_4_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+55+',
        "<b><font color=red><i>" + str(answer_5_true) + "</font></i></b>")

    # wrong answers
    increment1 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = answer_1_true + increment1 if answer_1_true > 1 else answer_1_true + 1
    answer_2_false = find_word_with_different_length(the_list, len(equasion),
                                                     word, answer_2_true)
    answer_3_false = the_list[_3 + increment3]
    answer_4_false = answer_4_true + increment4
    answer_5_false = answer_5_true + increment5

    change_all_occurrences(
        r'\verb+111+',
        "<b><font color=red><i>" + str(answer_1_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+222+',
        "<b><font color=red><i>" + str(answer_2_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+333+',
        "<b><font color=red><i>" + str(answer_3_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+444+',
        "<b><font color=red><i>" + str(answer_4_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+555+',
        "<b><font color=red><i>" + str(answer_5_false) + "</font></i></b>")
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global _1
    global _2
    global _3
    global _4
    global _5


    the_list = program.get_global(a)
    _2 = random_generator(the_list)
    change_all_occurrences(r'\verb+2+',"<b><i>" +  r'\verb+' + str(_2) + '+'+ "</b></i>")

    
    answer_1_true = the_list[_1]
    answer_2_true = sum(np.array(the_list) == _2)
    answer_3_true = the_list[_3]
    answer_4_true = the_list[_4]
    answer_5_true = sum(the_list)

    # true answers
    change_all_occurrences(r'\verb+11+',"<b><i>" +  str(answer_1_true)+ "</b></i>")
    change_all_occurrences(r'\verb+22+',"<b><i>" +  str(answer_2_true)+ "</b></i>")
    change_all_occurrences(r'\verb+33+',"<b><i>" +  str(answer_3_true)+ "</b></i>")
    change_all_occurrences(r'\verb+44+',"<b><i>" +  str(answer_4_true)+ "</b></i>")
    change_all_occurrences(r'\verb+55+',"<b><i>" +  str(answer_5_true)+ "</b></i>")

    # wrong answers
    increment1 = choice([1, -1])
    increment2 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = the_list[_1] + increment1
    answer_2_false = sum(np.array(the_list) == _2) + increment2
    answer_3_false = the_list[_3] + increment3
    answer_4_false = the_list[_4 + increment4]
    answer_5_false = sum(the_list) + increment5
    change_all_occurrences(r'\verb+111+',"<b><i>" +  str(answer_1_false)+ "</b></i>")
    change_all_occurrences(r'\verb+222+',"<b><i>" +  str(answer_2_false)+ "</b></i>")
    change_all_occurrences(r'\verb+333+',"<b><i>" +  str(answer_3_false)+ "</b></i>")
    change_all_occurrences(r'\verb+444+',"<b><i>" +  str(answer_4_false)+ "</b></i>")
    change_all_occurrences(r'\verb+555+',"<b><i>" +  str(answer_5_false)+ "</b></i>")
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global _1
    global _3
    global _4
    global _5
    global idx_m1
    global idx_m2
    global answer_2_decision
    global answer_2_index
    global cl_1
    global cl_2
    global v1
    global v2

    the_list = program.get_global(a)
    m1 = the_list[idx_m1]
    m2 = the_list[idx_m2]
    m3 = the_list[_3]
    m4 = the_list[_4]
    m5 = the_list[_5]

    answer_1_true = m1.row_times_column(cl_1, v1, m2, cl_2, v2)
    if answer_2_decision == "coluna":
        answer_2_true = m1.get_coluna(answer_2_index)
    if answer_2_decision == "linha":
        answer_2_true = m1.get_linha(answer_2_index)
    answer_3_true = m3.matrix_cross_product()
    answer_4_true = m4.mult_by_itself()
    answer_5_true = m5.std()

    # true answers
    change_all_occurrences(r'\verb+11+', str(answer_1_true))
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+33+', str(answer_3_true))
    change_all_occurrences(r'\verb+44+', str(answer_4_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    increment1 = choice([1, -1])
    increment3 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = answer_1_true + increment1
    if answer_2_decision == "coluna":
        answer_2_false = m1.get_linha(answer_2_index)
    if answer_2_decision == "linha":
        answer_2_false = m1.get_coluna(answer_2_index)
    if answer_2_false == answer_2_true:
        answer_2_false = get_answer_2_false(the_list, answer_2_decision,
                                            answer_2_true)
    answer_3_false = m1.matrix_cross_product(
    ) if answer_3_true != m1.matrix_cross_product(
    ) else m1.matrix_cross_product() + increment3
    answer_4_false = m2.mult_by_itself(
    ) if answer_4_true != m2.mult_by_itself() else get_answer_4_false(
        the_list, answer_4_true)
    answer_5_false = m1.std(
    ) if answer_5_true != m1.std() else m1.std() + increment5

    change_all_occurrences(r'\verb+111+', str(answer_1_false))
    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+333+', str(answer_3_false))
    change_all_occurrences(r'\verb+444+', str(answer_4_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
def make_transformations():

    ''
    global a
    global e
    global f
    global numpy_func
    global _1_t
    global _1_f
    global _2
    global _3
    global _4
    global _5_dimension
    global _5
    global _23

    # question
    _135 = str(randint(1000000, 2000000))
    [a, b, c, d, e, f, n] = sample(string.ascii_lowercase, 7)
    _13 = randint(19000, 20000)
    _3 = randint(0, 5)
    _23 = randint(6, 300)
    _33 = randint(6, 600)

    maneiras_corretas = [
        'np.zeros(0)', 'np.ones(0)', 'np.arange(0)', 'np.array([])',
        'np.empty(0)', 'np.eye(0)'
    ]
    maneiras_incorretas = ['[]', 'array()', 'np.array()', 'np.empty()']
    numpy_func = choice((maneiras_corretas))

    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('b', b)
    change_token_all_occurrences('c', c)
    change_token_all_occurrences('d', d)
    change_token_all_occurrences('e', e)
    change_token_all_occurrences('f', f)
    change_token_all_occurrences('n', n)
    change_all_occurrences('13', str(_13))
    change_all_occurrences('3', str(_3))
    change_all_occurrences('23', str(_23))
    change_all_occurrences('33', str(_33))
    change_all_occurrences('numpy_func', numpy_func)

    # answers
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')
    change_all_occurrences(r'\verb+e+', r'\verb+' + e + '+')

    # indexes with no repetitions
    [_5] = sample(range(_13), 1)

    _2 = randint(0, 1)
    if _2 == 0:
        change_all_occurrences(r'\verb+2+', r'\verb+' + pt_e + '+')
    if _2 == 1:
        change_all_occurrences(r'\verb+2+', r'\verb+' + pt_nao + '+')
    _3_funcs = [
        'np.vstack(' + b + ', ' + c + ')', 'np.hstack((' + b + ', ' + c + '))',
        'np.vstack(' + b + ', ' + d + ')', 'np.hstack((' + b + ', ' + d + '))',
        'np.vstack(' + c + ', ' + b + ')', 'np.hstack((' + c + ', ' + b + '))',
        'np.vstack(' + c + ', ' + d + ')', 'np.hstack((' + c + ', ' + d + '))',
        'np.vstack(' + d + ', ' + b + ')', 'np.hstack((' + d + ', ' + b + '))',
        'np.vstack(' + d + ', ' + c + ')', 'np.hstack((' + d + ', ' + c + '))',
        'np.vstack((' + b + ', ' + c + '))', 'np.vstack((' + c + ', ' + d +
        '))', 'np.vstack((' + b + ', ' + d + '))',
        'np.vstack((' + d + ', ' + c + '))', 'np.hstack(' + b + ', ' + c + ')',
        'np.vstack(([], []))', 'np.hstack(' + b + ', ' + d + ')',
        'np.vstack((' + d + ', ' + d + '))', 'np.hstack(' + c + ', ' + b + ')',
        'np.vstack((' + c + ', ' + c + '))', 'np.hstack(' + c + ', ' + d + ')',
        'np.vstack((' + b + ', ' + b + '))', 'np.hstack(' + d + ', ' + b + ')'
    ]

    [_3_idx] = sample(range(len(_3_funcs)), 1)
    change_all_occurrences(r'\verb+3+', r'\verb+' + _3_funcs[_3_idx] + '+')
    if _3_idx % 2 == 0:
        answer_3_true = pt_lancar + ' um erro'
        if _3_idx < 15:
            answer_3_false = 'originar um numpy array de 2 ' + pt_dimensoes
        else:
            answer_3_false = 'originar um numpy array de 1 ' + pt_dimensao
        change_all_occurrences(r'\verb+33+', answer_3_true)
        change_all_occurrences(r'\verb+333+', answer_3_false)

    if _3_idx % 2 != 0:
        if _3_idx < 12:
            answer_3_true = 'originar um numpy array de 1 ' + pt_dimensao
            answer_3_false = 'originar um numpy array de 2 ' + pt_dimensoes
        else:
            answer_3_true = 'originar um numpy array de 2 ' + pt_dimensoes
            option_answer_3_false = 'originar um numpy array de 1 ' + pt_dimensao
            answer_3_false = choice(
                (pt_lancar + ' um erro', option_answer_3_false))
        change_all_occurrences(r'\verb+33+', answer_3_true)
        change_all_occurrences(r'\verb+333+', answer_3_false)

    _5_dimension = choice((1, 2))
    if _5_dimension == 1:
        _5 = choice(('-2', '-1', '0', ':', '1'))
        _5 = _5 + ', :'
    if _5_dimension == 2:
        _5 = ':, ' + str(randint(-_23, _23))
    change_all_occurrences(r'\verb+5+', r'\verb+' + f + '[' + str(_5) + ']+')

    # true answer
    _1_t, answer_1_true = quest_1(maneiras_corretas, maneiras_incorretas, True)
    change_all_occurrences(r'\verb+1_t+', r'\verb+' + _1_t + '+')
    change_all_occurrences(r'\verb+11+', answer_1_true)
    # false answer
    _1_f, answer_1_false = quest_1(maneiras_corretas, maneiras_incorretas,
                                   False)
    change_all_occurrences(r'\verb+1_f+', r'\verb+' + _1_f + '+')
    change_all_occurrences(r'\verb+111+', answer_1_false)
def make_transformations_on_results(program):
    ''

    global a
    global e
    global f
    global _1_t
    global _1_f
    global _2
    global _3
    global _4
    global _5

    the_list = program.get_global(a)
    the_list_e = program.get_global(e)
    the_list_f = program.get_global(f)

    answer_2_true = possible_shape(len(the_list)) if _2 == 0 \
                    else possible_shape(len(the_list) + choice([1, -1]))
    answer_4_true = np.shape(the_list_e)
    answer_5_true = quest_5(the_list_f)

    # true answers
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+44+', str(answer_4_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    increment5 = choice([1, -1])


    answer_2_false = possible_shape(len(the_list)) if _2 == 1 \
                    else possible_shape(len(the_list) + choice([1, -1]))
    answer_4_false = wrong_shape(answer_4_true)
    answer_5_false = quest_5_wrong_answer(the_list_f, answer_5_true)

    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+444+', str(answer_4_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
示例#14
0
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global d
    global str_a
    global int_a
    global dic
    global _2
    global _3
    global _3_idx
    global _3_decision
    global _4
    global _4_decision
    global _5

    the_list = program.get_global(a)
    str_the_list = program.get_global(str_a)
    int_the_list = program.get_global(int_a)
    the_dic = program.get_global(dic)
    the_dict = program.get_global(d)
    _3_idx = choice(ascii_letters)
    
    _3 = the_dic[_3_idx][0] if _3_decision == 'int' else the_dic[_3_idx] * 1.0 \
         if _3_decision == 'float' else _3_idx
    # answer index
    change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+')

    # answer values
    dic_val = the_dic[_4][0]
    change_all_occurrences(r'\verb+dic_val+', r'\verb+' + str(dic_val) + '+')
    add_val = randint(7, 500)
    change_all_occurrences(r'\verb+add_val+', r'\verb+' + str(add_val) + '+')
    
    answer_1_1_true = "letras" if len(str_the_list) > len(int_the_list) else pt_numeros
    answer_1_2_true = pt_numeros if answer_1_1_true == "letras" else "letras"
    answer_2_true = "tamanho maior" if len(d) > len(_2) else "tamanho menor" \
                    if len(d) < len(_2) else "tamanho igual"
    answer_3_true = the_dic[_3][0]
    answer_4_true = 'o valor ' + str(add_val)
    answer_5_true = get_max_key(the_dict) if _5 == "maior" else get_min_key(the_dict)

    
    
    # true answers
    change_all_occurrences(r'\verb+11_1+', str(answer_1_1_true))
    change_all_occurrences(r'\verb+11_2+', str(answer_1_2_true))
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+33+', str(answer_3_true))
    change_all_occurrences(r'\verb+44+', str(answer_4_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_1_false = pt_numeros if answer_1_1_true == "letras" else "letras"
    answer_1_2_false = "letras" if answer_1_1_true == "letras" else pt_numeros
    answer_2_false = choice(("tamanho maior", "tamanho menor"))  \
                     if answer_2_true == "tamanho igual" else \
                     "tamanho maior" if answer_2_true == "tamanho menor" \
                     else "tamanho menor"
    answer_3_false = quest_3_false(answer_3_true)
    answer_4_false = 'os valores ' + str(add_val) + ' e ' + str(dic_val) \
                     if _4_decision == 0 else 'o valor ' + str(add_val)
    answer_5_false = get_min_key(the_dict) if _5 == "maior" else get_max_key(the_dict)


    change_all_occurrences(r'\verb+111_1+', str(answer_1_1_false))
    change_all_occurrences(r'\verb+111_2+', str(answer_1_2_false))
    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+333+', str(answer_3_false))
    change_all_occurrences(r'\verb+444+', str(answer_4_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global counter
    global d
    global _1
    global _2
    global _3
    global _4
    global _5

    the_list = program.get_global(d)
    answer_1_true = _1
    answer_2_true = the_list[:3] if _2 == 3 else the_list[-3:]
    answer_3_true = 0 if _3 == 1 else _5 - 1
    answer_5_true = program.get_global(counter)

    # true answers
    change_all_occurrences(r'\verb+11+', str(answer_1_true))
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+33+', str(answer_3_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    increment1 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = _7
    answer_2_false = the_list[-3:] if _2 == 3 else the_list[:3]
    answer_3_false = answer_3_true + 1
    answer_5_false = 0

    change_all_occurrences(r'\verb+111+', str(answer_1_false))
    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+333+', str(answer_3_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
def make_transformations():

    ''
    global a
    global _1
    global _2
    global _3
    global _4
    global _5

    # question
    _135 = str(randint(1000000, 2000000))
    [a, i, k, l, m] = sample(string.ascii_lowercase, 5)
    _10 = randint(19000, 20000)
    _15 = randint(10, 20)

    change_all_occurrences('135',
                           "<b><font color=red><i>" + _135 + "</font></i></b>")
    change_token_all_occurrences(
        'a', "<b><font color=red><i>" + a + "</font></i></b>")
    change_token_all_occurrences(
        'i', "<b><font color=red><i>" + i + "</font></i></b>")
    change_token_all_occurrences(
        'k', "<b><font color=red><i>" + k + "</font></i></b>")
    change_token_all_occurrences(
        'l', "<b><font color=red><i>" + l + "</font></i></b>")
    change_token_all_occurrences(
        'm', "<b><font color=red><i>" + m + "</font></i></b>")
    change_all_occurrences(
        '10', "<b><font color=red><i>" + str(_10) + "</font></i></b>")
    change_all_occurrences(
        '15', "<b><font color=red><i>" + str(_15) + "</font></i></b>")

    # answers
    change_all_occurrences(
        r'\verb+a+',
        "<b><font color=red><i>" + r'\verb+' + a + '+' + "</font></i></b>")

    # indexes with no repetitions
    [_1, _3, _4, _5] = sample(range(_10), 4)

    change_all_occurrences(
        r'\verb+b+', "<b><font color=red><i>" + r'\verb+' + str(_1) + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+3+', "<b><font color=red><i>" + r'\verb+' + str(_3) + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+5+', "<b><font color=red><i>" + r'\verb+' + str(_5) + '+' +
        "</font></i></b>")
def make_transformations():
    ''
    global counter
    global d
    global _1
    global _2
    global _3
    global _4
    global _5
    global _7

    _135 = str(randint(1000000, 2000000))

    [a, counter, c, d] = sample(string.ascii_lowercase, 4)
    _1 = randint(10, 80)
    _5 = randint(50, 100)
    _7 = randint(19000, 20000)
    _15 = randint(200, 500)

    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('counter', counter)
    change_token_all_occurrences('c', c)
    change_token_all_occurrences('d', d)
    change_token_all_occurrences('3', str(_1))
    change_all_occurrences('5', str(_5))
    change_all_occurrences('7', str(_7))
    change_all_occurrences('15', str(_15))

    change_all_occurrences(r'\verb+1_idx+', r'\verb+' + str(_1) + '+')

    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')
    change_all_occurrences(r'\verb+c+', r'\verb+' + c + '+')
    change_all_occurrences(r'\verb+d+', r'\verb+' + d + '+')

    _2, decision1 = decision_function()
    _3, decision2 = decision_function_2()
    change_all_occurrences(r'\verb+2+', r'\verb+' + decision1 + '+')
    change_all_occurrences(r'\verb+3+', r'\verb+' + decision2 + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + counter + '+')
示例#18
0
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global _1
    global _2
    global _3
    global _4
    global _5
    global list_distance
    global wtc

    the_list = program.get_global(a)
    mst_freq = program.get_global("mst_freq")
    lst_freq = program.get_global("lst_freq")
    nums = the_list[_5: _5 + list_distance]

    answer_1_true = the_list[_1]
    answer_2_true = mst_freq
    answer_3_true = lst_freq
    answer_4_true = int_to_roman(the_list[_4])
    answer_5_true = nums[wtc:] + nums[:wtc]

    # true answers
    change_all_occurrences(r'\verb+11+', str(answer_1_true))
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+33+', str(answer_3_true))
    change_all_occurrences(r'\verb+44+', str(answer_4_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    increment1 = choice([1, -1])
    increment2 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = answer_1_true + increment1
    answer_2_false = answer_2_true + increment2
    answer_3_false = answer_3_true + increment3
    answer_4_false = int_to_roman(the_list[_4 + increment2])
    answer_5_false = change_random_num(list_distance, nums[wtc:] + nums[:wtc])

    change_all_occurrences(r'\verb+111+', str(answer_1_false))
    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+333+', str(answer_3_false))
    change_all_occurrences(r'\verb+444+', str(answer_4_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
示例#19
0
def make_transformations():

    ''
    global a
    global p
    global P
    global _1_1
    global _1_2
    global _1_3
    global _2_1
    global _2_2
    global _3
    global _13

    # question
    _135 = str(randint(1000000, 2000000))
    [a, i, n, p, P] = sample(string.ascii_lowercase, 5)
    _13 = randint(19000, 20000)
    _3 = randint(0, 5)
    _33 = randint(50, 255)
    P = P.upper()

    change_all_occurrences('135', "<b><i>" + _135 + "</b></i>")
    change_token_all_occurrences('a', "<b><i>" + a + "</b></i>")
    change_token_all_occurrences('i', "<b><i>" + i + "</b></i>")
    change_token_all_occurrences('n', "<b><i>" + n + "</b></i>")
    change_token_all_occurrences('p', "<b><i>" + p + "</b></i>")
    change_token_all_occurrences('P', "<b><i>" + P + "</b></i>")
    change_all_occurrences('13', "<b><i>" + str(_13) + "</b></i>")
    change_all_occurrences('3', "<b><i>" + str(_3) + "</b></i>")
    change_all_occurrences('33', "<b><i>" + str(_33) + "</b></i>")

    _1_1, _1_2, _1_3 = _1_quest()
    _2_1, _2_2 = _2_quest()
    _3 = choice(("alterar o", "aceder ao"))
    # answers
    change_all_occurrences(r'\verb+a+',
                           "<b><i>" + r'\verb+' + a + '+' + "</b></i>")
    change_all_occurrences(r'\verb+classP+',
                           "<b><i>" + r'\verb+' + P + '+' + "</b></i>")
    change_all_occurrences(r'\verb+classp+',
                           "<b><i>" + r'\verb+' + p + '+' + "</b></i>")

    # indexes with no repetitions
    [_1, _2] = sample(range(_13), 2)

    change_all_occurrences(r'\verb+1_1+',
                           "<b><i>" + r'\verb+' + str(_1_1) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+1_2+',
                           "<b><i>" + r'\verb+' + str(_1_2) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+1_3+',
                           "<b><i>" + r'\verb+' + str(_1_3) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+2_1+',
                           "<b><i>" + r'\verb+' + str(_2_1) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+2_2+',
                           "<b><i>" + r'\verb+' + str(_2_2) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+3+',
                           "<b><i>" + r'\verb+' + str(_3) + '+' + "</b></i>")
示例#20
0
def make_transformations():

    ''
    global a
    global _1
    global _2
    global _3
    global _4
    global _5
    global list_distance
    global wtc
    
    # question
    _135 = str(randint(1000000, 2000000))
    [a, n, k] = sample(string.ascii_lowercase, 3)
    _13 = randint(19000, 20000)
    _33  = randint(1, 500)
    _66  = randint(500, 1000)
    
    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('n', n)
    change_token_all_occurrences('k', k)

    change_all_occurrences('13', str(_13))
    change_all_occurrences('33', str(_33))
    change_all_occurrences('66', str(_66))

    list_distance = choice((3, 4, 5, 6, 7))
    _5 = choice(range(_13 - list_distance))
    wtc = choice(range(list_distance))
    if wtc == 0:
        wtc += choice((1,2))
    if wtc == list_distance:
        wtc -= choice((1,2))
    
    # answers
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')
    
    # indexes with no repetitions
    [_1, _4, _5] = sample(range(_13), 3)
    
    change_all_occurrences(r'\verb+1+', r'\verb+' + str(_1) + '+')
    change_all_occurrences(r'\verb+4+', r'\verb+' + str(_4) + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')

    #alinea 5
    change_all_occurrences(r'\verb+k+', r'\verb+' + k + '+')
    change_all_occurrences(r'\verb+dist+', r'\verb+' + str(list_distance) + '+')
    change_all_occurrences(r'\verb+k_val+', r'\verb+' + str(wtc) + '+')
示例#21
0
def make_transformations():

    ''
    global a
    global _1
    global _2_1
    global _2_2
    global __var
    global var
    global P
    global p

    # question
    _135 = str(randint(1000000, 2000000))
    [a, n, p, P, var, i] = sample(string.ascii_lowercase, 6)
    _13 = randint(19000, 20000)
    _3 = randint(-50, 5)
    _33 = randint(5, 1500)
    __var = '__' + var
    P = P.upper()

    change_all_occurrences(
        '135', "<b><font color=green><i>" + _135 + "</i></font></b>")
    change_token_all_occurrences(
        'a', "<b><font color=green><i>" + a + "</i></font></b>")
    change_token_all_occurrences(
        'P', "<b><font color=green><i>" + P + "</i></font></b>")
    change_token_all_occurrences(
        '__var', "<b><font color=green><i>" + __var + "</i></font></b>")
    change_token_all_occurrences(
        'p', "<b><font color=green><i>" + p + "</i></font></b>")
    change_token_all_occurrences(
        'i', "<b><font color=green><i>" + i + "</i></font></b>")
    change_token_all_occurrences(
        'n', "<b><font color=green><i>" + n + "</i></font></b>")
    change_all_occurrences(
        '13', "<b><font color=green><i>" + str(_13) + "</i></font></b>")
    change_all_occurrences(
        '3', "<b><font color=green><i>" + str(_3) + "</i></font></b>")
    change_all_occurrences(
        '33', "<b><font color=green><i>" + str(_33) + "</i></font></b>")

    # answers
    change_all_occurrences(
        r'\verb+a+',
        "<b><font color=green><i>" + r'\verb+' + a + '+' + "</i></font></b>")
    change_all_occurrences(
        r'\verb+classp+',
        "<b><font color=green><i>" + r'\verb+' + p + '+' + "</i></font></b>")
    change_all_occurrences(
        r'\verb+classP+',
        "<b><font color=green><i>" + r'\verb+' + P + '+' + "</i></font></b>")

    # indexes with no repetitions
    [_1, _2_1, _2_2] = sample(range(_13), 3)

    change_all_occurrences(
        r'\verb+1+', "<b><font color=green><i>" + r'\verb+' + str(_1) + '+' +
        "</i></font></b>")
    change_all_occurrences(
        r'\verb+2_1+', "<b><font color=green><i>" + r'\verb+' + str(_2_1) +
        '+' + "</i></font></b>")
    change_all_occurrences(
        r'\verb+2_2+', "<b><font color=green><i>" + r'\verb+' + str(_2_2) +
        '+' + "</i></font></b>")
    change_all_occurrences(
        r'\verb+3+', "<b><font color=green><i>" + r'\verb+' + __var + '+' +
        "</i></font></b>")
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global b
    global c
    global _1
    global _2
    global _5
    global _13

    the_list_a = program.get_global(a)
    the_list_b = program.get_global(b)
    the_list_c = program.get_global(c)
    r = Reverser()
    ##    print(the_list)
    answer_1_true = the_list_a[_1]
    answer_2_true = the_list_b[_2]
    answer_3_true = sum(np.array(the_list_a) != np.array(the_list_c) * 1.0)
    answer_4_true = sum(np.array(the_list_c) == 0 * 1.0)
    answer_5_true = r.reverse(
        binary_sum(to_bits(the_list_a[_5]), to_bits(the_list_b[_5])))

    # true answers
    change_all_occurrences(
        r'\verb+11+',
        "<b><font color=red><i>" + str(answer_1_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+22+',
        "<b><font color=red><i>" + str(answer_2_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+33+',
        "<b><font color=red><i>" + str(answer_3_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+44+',
        "<b><font color=red><i>" + str(answer_4_true) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+55+',
        "<b><font color=red><i>" + str(answer_5_true) + "</font></i></b>")

    # wrong answers
    increment1 = choice([1, -1])
    increment2 = choice([1, -1])
    increment3 = choice([1, -1]) if answer_3_true > 0 else 1
    increment4 = choice([1, -1]) if answer_4_true > 0 else 1
    increment5 = choice([1, -1])

    answer_1_false = answer_1_true + increment1
    answer_2_false = answer_2_true + increment2
    answer_3_false = answer_3_true + increment3
    answer_4_false = answer_4_true + increment4
    if answer_5_true == 0:
        answer_5_false = r.false_reverse(
            binary_sum(to_bits(the_list_a[_5]), to_bits(the_list_b[_5])))
    else:
        idx = 0
        while True:
            if idx != _5:
                reverse = r.reverse(
                    binary_sum(to_bits(the_list_a[idx]),
                               to_bits(the_list_b[idx])))
                if reverse != answer_5_true:
                    answer_5_false = reverse
                    break
            idx += 1

    change_all_occurrences(
        r'\verb+111+',
        "<b><font color=red><i>" + str(answer_1_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+222+',
        "<b><font color=red><i>" + str(answer_2_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+333+',
        "<b><font color=red><i>" + str(answer_3_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+444+',
        "<b><font color=red><i>" + str(answer_4_false) + "</font></i></b>")
    change_all_occurrences(
        r'\verb+555+',
        "<b><font color=red><i>" + str(answer_5_false) + "</font></i></b>")
def make_transformations():
    ''
    global a
    global f
    global _1
    global _2
    global _3
    global _4
    global _5

    # question
    _135 = str(randint(1000000, 2000000))
    a = choice(string.ascii_lowercase)  # ERROR: isto está mal!!!  a letra 'a'

    # não pode ser uma letra qualquer. porque se for igual a 'n' como
    # há no programa uma variável 'n' isto vai causar um erro
    # deexecuçaõ. Intermitente, o que ainda é pior
    # soluções possíveis:
    # 1. escolher uma letra qualquer execto o 'n'
    # 2. substituir também a variável 'n' escolhendo duas letras diferentes
    # vai ser usada a solução 2 porque assim as versões ainda ficam
    # mais diferentes. a variável 'n' passa também a ser diferente
    [a, b, c, d, e, f] = sample(string.ascii_lowercase, 6)
    _30 = randint(19000, 20000)

    change_all_occurrences('135', "<b><i>" + _135 + "</b></i>")
    change_token_all_occurrences('a', "<b><i>" + a + "</b></i>")
    change_token_all_occurrences('b', "<b><i>" + b + "</b></i>")
    change_token_all_occurrences('c', "<b><i>" + c + "</b></i>")
    change_token_all_occurrences('d', "<b><i>" + d + "</b></i>")
    change_token_all_occurrences('e', "<b><i>" + e + "</b></i>")
    change_token_all_occurrences('f', "<b><i>" + f + "</b></i>")
    change_all_occurrences('30', "<b><i>" + str(_30) + "</b></i>")

    # answers
    change_all_occurrences(r'\verb+a+',
                           "<b><i>" + r'\verb+' + a + '+' + "</b></i>")
    change_all_occurrences(r'\verb+f+',
                           "<b><i>" + r'\verb+' + f + '+' + "</b></i>")

    # indexes with no repetitions
    [_1, _2, _3, _4, _5] = sample(range(_30), 5)

    change_all_occurrences(r'\verb+1+',
                           "<b><i>" + r'\verb+' + str(_1) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+2+',
                           "<b><i>" + r'\verb+' + str(_2) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+3+',
                           "<b><i>" + r'\verb+' + str(_3) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+4+',
                           "<b><i>" + r'\verb+' + str(_4) + '+' + "</b></i>")
    change_all_occurrences(r'\verb+5+',
                           "<b><i>" + r'\verb+' + str(_5) + '+' + "</b></i>")
def make_transformations():

    ''
    global a
    global b
    global c
    global _1
    global _2
    global _5
    global _13

    # question
    _135 = str(randint(1000000, 2000000))
    [a, b, c, r, i] = sample(string.ascii_lowercase, 5)
    _13 = randint(19000, 20000)

    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('b', b)
    change_token_all_occurrences('c', c)
    change_token_all_occurrences('r', r)
    change_token_all_occurrences('i', i)
    change_all_occurrences('13', str(_13))

    # answers
    change_all_occurrences(
        r'\verb+a+',
        "<b><font color=red><i>" + r'\verb+' + a + '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+b+',
        "<b><font color=red><i>" + r'\verb+' + b + '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+c+',
        "<b><font color=red><i>" + r'\verb+' + c + '+' + "</font></i></b>")

    # indexes with no repetitions
    [_1, _2, _5] = sample(range(_13), 3)

    change_all_occurrences(
        r'\verb+1+', "<b><font color=red><i>" + r'\verb+' + str(_1) + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+2+', "<b><font color=red><i>" + r'\verb+' + str(_2) + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+5+', "<b><font color=red><i>" + r'\verb+' + str(_5) + '+' +
        "</font></i></b>")
def make_transformations():

    ''
    global a
    global b
    global c
    global _1
    global _2
    global _3
    global _4
    global _5
    global rgb_idx
    global limiar
    # question
    _135 = str(randint(1000000, 2000000))
    a = choice(string.ascii_lowercase) # ERROR: isto está mal!!!  a letra 'a'
    # não pode ser uma letra qualquer. porque se for igual a 'n' como
    # há no programa uma variável 'n' isto vai causar um erro
    # deexecuçaõ. Intermitente, o que ainda é pior
    # soluções possíveis:
    # 1. escolher uma letra qualquer execto o 'n'
    # 2. substituir também a variável 'n' escolhendo duas letras diferentes
    # vai ser usada a solução 2 porque assim as versões ainda ficam
    # mais diferentes. a variável 'n' passa também a ser diferente
    [a, b, c, i] = sample(string.ascii_lowercase, 4)
    _10 = randint(19000, 20000)

    
    change_all_occurrences('135', _135)
    change_token_all_occurrences('la', a)
    change_token_all_occurrences('lb', b)
    change_token_all_occurrences('lc', c)
    change_token_all_occurrences('i', i)
    change_all_occurrences('10', str(_10))


    # answers
    change_all_occurrences(r'\verb+la+',"<b><font color=red><i>" +  r'\verb+' + a + '+'+ "</font></i></b>")
    change_all_occurrences(r'\verb+lb+',"<b><font color=red><i>" +  r'\verb+' + b + '+'+ "</font></i></b>")
    change_all_occurrences(r'\verb+lc+',"<b><font color=red><i>" +  r'\verb+' + c + '+'+ "</font></i></b>")
    # indexes with no repetitions
    [_2, _4, _5] = sample(range(_10), 3)
    _1 = randint(0, 255)
    _3 = choice((0, 255))
    black_or_white = 'brancos' if _3 == 255 else 'pretos'
    change_all_occurrences(r'\verb+1+',"<b><font color=red><i>" +  r'\verb+' + str(_1) + '+'+ "</font></i></b>")
    change_all_occurrences(r'\verb+2+',"<b><font color=red><i>" +  r'\verb+' + str(_2) + '+'+ "</font></i></b>")
    change_all_occurrences(r'\verb+3+',"<b><font color=red><i>" +  r'\verb+' + black_or_white + '+'+ "</font></i></b>")
    change_all_occurrences(r'\verb+4+',"<b><font color=red><i>" +  r'\verb+' + str(_4) + '+'+ "</font></i></b>")
    change_all_occurrences(r'\verb+5+',"<b><font color=red><i>" +  r'\verb+' + str(_5) + '+'+ "</font></i></b>")
    rgb_idx = rgb_decision()
    RGBpix = rgb_str(rgb_idx)
    change_all_occurrences(r'\verb+RGBpix+',"<b><font color=red><i>" +  RGBpix+ "</font></i></b>")
    limiar = randint(80, 140)
    change_all_occurrences(r'\verb+limTreshold+',"<b><font color=red><i>" +  str(limiar)+ "</font></i></b>")
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global _1
    global _2
    global _3
    global _4
    global _5

    isNum = "um numero"
    isString = "uma string"

    the_list = program.get_global(a)
    #print(the_list)
    answer_1_true = the_list[_1]
    answer_2_true = the_list[_2]
    answer_3_true = ""
    if the_list[_3].isdigit():
        answer_3_true = isString
    if not the_list[_3].isdigit():
        answer_3_true = isNum
    answer_4_true = the_list[_4]
    answer_5_true = ""
    if the_list[_5].isdigit():
        answer_5_true = isString
    if not the_list[_5].isdigit():
        answer_5_true = isNum

    # true answers
    change_all_occurrences(r'\verb+11+', str(answer_1_true))
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+33+', str(answer_3_true))
    change_all_occurrences(r'\verb+44+', str(answer_4_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    increment1 = choice([1, -1])
    increment2 = choice([1, -1])
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer_1_false = the_list[_1 + increment1]
    answer_2_false = the_list[_2 + increment2]
    answer_3_false = ""
    if the_list[_3 + increment3].isdigit():
        answer_3_false = isString
    if not the_list[_3 + increment3].isdigit():
        answer_3_false = isNum
    answer_4_false = the_list[_4 + increment4]
    answer_5_false = ""
    if the_list[_5 + increment5].isdigit():
        answer_5_false = isString
    if not the_list[_5 + increment5].isdigit():
        answer_5_false = isNum
    change_all_occurrences(r'\verb+111+', str(answer_1_false))
    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+333+', str(answer_3_false))
    change_all_occurrences(r'\verb+444+', str(answer_4_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
def make_transformations_on_results(program):
    ''
    # os global aqui não são precisos porque não se faz nesta função
    # atribuição a estas variáveis. Só está para para tornar explícito
    # que são variáveis globais partilhadas
    global a
    global d
    global _1
    global _2
    global _3
    global _4
    global _5
    global decision
    global _10
    global _20
    global _33
    global _func5

    
    form = ['crescente', 'decrescente']
    base = ['com base no tamanho da string', 'com base no numero']
    answer = form[0] if decision < 3 else form[1]
    answer += ' '
    answer += base[decision%2]
    the_list = program.get_global(d)
    #print(the_list)
    
    answer_2_true = answer
    times = _33
    for i in range(1, int(_20 / _10)):
        times *= _33
    answer_3_true = the_list[_3]
    answer_4_true = times
    answer_5_true = a + '[:' + str(_5) + ':]'  if _func5 == 'primeiros' else a + '[-' + str(_5) +'::]'

    # true answers
  
    change_all_occurrences(r'\verb+22+', str(answer_2_true))
    change_all_occurrences(r'\verb+33+', str(answer_3_true))
    change_all_occurrences(r'\verb+44+', str(answer_4_true))
    change_all_occurrences(r'\verb+55+', str(answer_5_true))

    # wrong answers
    
    increment3 = choice([1, -1])
    increment4 = choice([1, -1])
    increment5 = choice([1, -1])

    answer = form[1] if decision < 3 else form[0]
    answer += ' '
    answer += base[decision%2]

    
    answer_2_false = answer
    answer_3_false = the_list[_3] + increment3
    answer_4_false = answer_4_true + increment4
    answer_5_false = a + wrong_5_awnser(_func5, _5)
    
    change_all_occurrences(r'\verb+222+', str(answer_2_false))
    change_all_occurrences(r'\verb+333+', str(answer_3_false))
    change_all_occurrences(r'\verb+444+', str(answer_4_false))
    change_all_occurrences(r'\verb+555+', str(answer_5_false))
def make_transformations():
    ''
    global a
    global _1
    global _2
    global _3
    global _4
    global _5

    # question
    _135 = str(randint(1000000, 2000000))
    a = choice(string.ascii_lowercase)  # ERROR: isto está mal!!!  a letra 'a'

    # não pode ser uma letra qualquer. porque se for igual a 'n' como
    # há no programa uma variável 'n' isto vai causar um erro
    # deexecuçaõ. Intermitente, o que ainda é pior
    # soluções possíveis:
    # 1. escolher uma letra qualquer execto o 'n'
    # 2. substituir também a variável 'n' escolhendo duas letras diferentes
    # vai ser usada a solução 2 porque assim as versões ainda ficam
    # mais diferentes. a variável 'n' passa também a ser diferente
    [a, k, c, g, l, n, g1] = sample(string.ascii_lowercase, 7)
    _20 = randint(18000, 20000)

    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('k', k)
    change_token_all_occurrences('c', c)
    change_token_all_occurrences('g', g)
    change_token_all_occurrences('l', l)
    change_token_all_occurrences('n', n)
    change_token_all_occurrences('g1', g1)
    change_all_occurrences('20', str(_20))

    # answers
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')

    # indexes with no repetitions
    [_1, _2, _3, _4, _5] = sample(range(_20), 5)

    change_all_occurrences(r'\verb+1+', r'\verb+' + str(_1) + '+')
    change_all_occurrences(r'\verb+2+', r'\verb+' + str(_2) + '+')
    change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+')
    change_all_occurrences(r'\verb+4+', r'\verb+' + str(_4) + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')
示例#29
0
def make_transformations():

    ''
    global a
    global b
    global _1
    global _2_1
    global _2_2
    global _3
    global _3_1
    global _3_2
    global _3_1_f
    global _3_2_f
    global _4
    global __var
    global var
    global P
    global p

    # question
    _135 = str(randint(1000000, 2000000))
    [a, b, n, p, P, var, i] = sample(string.ascii_lowercase, 7)
    _13 = randint(19000, 20000)
    _3 = randint(0, 3)
    _33 = randint(50, 1500)
    __var = '__' + var
    P = P.upper()

    wrong_3 = choice((p + '.' + '__' + var, P + '.' + '__' + var,
                      p + '._' + P + '_' + var, P + '.' + var, p + '.' + var))
    correct_answers_list = [
        p + '._' + P + '__' + var, p + ".get_var()", P + "().get_var()"
    ]

    _3_1, _3_2 = sample(correct_answers_list, 2)

    decision = choice((0, 1))
    correct_3 = choice((_3_1, _3_2))

    _3_1_f = correct_3 if decision == 0 else wrong_3
    _3_2_f = wrong_3 if decision == 0 else _3_1

    change_all_occurrences(
        '135', "<b><font color=green><i>" + _135 + "</font></i></b>")
    change_token_all_occurrences(
        'a', "<b><font color=green><i>" + a + "</font></i></b>")
    change_token_all_occurrences(
        'b', "<b><font color=green><i>" + b + "</font></i></b>")
    change_token_all_occurrences(
        'P', "<b><font color=green><i>" + P + "</font></i></b>")
    change_token_all_occurrences(
        '__var', "<b><font color=green><i>" + __var + "</font></i></b>")
    change_token_all_occurrences(
        'p', "<b><font color=green><i>" + p + "</font></i></b>")
    change_token_all_occurrences(
        'i', "<b><font color=green><i>" + i + "</font></i></b>")
    change_token_all_occurrences(
        'n', "<b><font color=green><i>" + n + "</font></i></b>")
    change_all_occurrences(
        '13', "<b><font color=green><i>" + str(_13) + "</font></i></b>")
    change_all_occurrences(
        '3', "<b><font color=green><i>" + str(_3) + "</font></i></b>")
    change_all_occurrences(
        '33', "<b><font color=green><i>" + str(_33) + "</font></i></b>")

    # answers
    change_all_occurrences(
        r'\verb+a+',
        "<b><font color=green><i>" + r'\verb+' + a + '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+b+',
        "<b><font color=green><i>" + r'\verb+' + b + '+' + "</font></i></b>")

    # indexes with no repetitions
    [_1] = sample(range(10), 1)
    _1 = str(_1)

    #regex parameters decision
    [_2_1, _2_2] = sample(range(10), 2)
    _2_1 = str(_2_1)
    _2_2 = str(_2_2)

    decision = choice(("single", "list"))
    if decision == "single":
        [_4] = sample(range(10), 1)
        _4 = str(_4) + choice(('?', '*', '+'))
    if decision == "list":
        [_4] = sample(range(10), 1)
        [max_4] = sample(range(len(str(_13))), 1)
        max_4 = max_4 if max_4 > 0 else max_4 + 1
        [min_4] = sample(range(max_4), 1)
        _4 = str(_4) + '{' + str(min_4) + '-' + str(max_4) + '}'

    change_all_occurrences(
        r'\verb+1+',
        "<b><font color=green><i>" + r'\verb+' + _1 + '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+2_1+', "<b><font color=green><i>" + r'\verb+' + _2_1 + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+2_2+', "<b><font color=green><i>" + r'\verb+' + _2_2 + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+3_1+', "<b><font color=green><i>" + r'\verb+' + _3_1 + '+' +
        "</font></i></b>")
    change_all_occurrences(
        r'\verb+3_2+', "<b><font color=green><i>" + r'\verb+' + _3_2 + '+' +
        "</font></i></b>")
    ##    change_all_occurrences(r'\verb+3_1+',"<b><font color=green><i>" +  _3_1+ "</font></i></b>")
    ##    change_all_occurrences(r'\verb+3_2+',"<b><font color=green><i>" +  _3_2 + "</font></i></b>")
    change_all_occurrences(
        r'\verb+3_1_f+', "<b><font color=green><i>" + r'\verb+' + _3_1_f +
        '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+3_2_f+', "<b><font color=green><i>" + r'\verb+' + _3_2_f +
        '+' + "</font></i></b>")
    change_all_occurrences(
        r'\verb+4+',
        "<b><font color=green><i>" + r'\verb+' + _4 + '+' + "</font></i></b>")
示例#30
0
def make_transformations():

    ''
    global a
    global _1
    global _2
    global _5
    global _35
    global _36

    # question
    _135 = str(randint(1000000, 2000000))
    [a, n, e, M, m, x] = sample(string.ascii_lowercase, 6)
    _13 = randint(19000, 20000)
    _33 = randint(1, 5000)
    _66 = randint(5000, 10000)
    _35 = randint(1, 17984)
    _36 = _35 + 1

    change_all_occurrences('135', _135)
    change_token_all_occurrences('a', a)
    change_token_all_occurrences('n', n)
    change_token_all_occurrences('e', e)
    change_token_all_occurrences('m', m)
    change_token_all_occurrences('M', M)
    change_token_all_occurrences('x', x)
    change_all_occurrences('13', str(_13))
    change_all_occurrences('33', str(_33))
    change_all_occurrences('66', str(_66))

    # answers
    change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+')
    change_all_occurrences(r'\verb+class+', r'\verb+' + M + '+')
    functions = {
        'print_v1()': 'NameError',
        'print_v1(' + str(e) + ')': 'NameError',
        'print_v2()': 'NameError',
        'print_v2(' + str(e) + ')': 'NameError',
        'print_v3()': 'TypeError',
        str(M) + '.print_v1()': 'TypeError',
        str(M) + '.print_v2(' + str(e) + ')': 'TypeError',
        str(M) + '.print_v3(' + str(e) + ')': 'AttributeError',
        str(m) + '.print_v1(' + str(e) + ')': 'TypeError',
        str(m) + '.print_v2(' + str(e) + ')': 'TypeError',
        str(m) + '.print_v3(' + str(e) + ')': 'AttributeError',
        str(M) + '.print_v1(' + str(e) + ')': str(_36),
        str(m) + '.print_v1()': "function print_v1",
        str(M) + '.print_v2()': 'function print_v2',
        'print_v3(' + str(e) + ')': str(_36)
    }

    # indexes with no repetitions
    [_5] = sample(range(_13), 1)

    idx = choice(range(len(functions)))
    _1 = list(functions.values())[idx]
    _2 = choice(('pares', 'impares'))
    change_all_occurrences(r'\verb+1+',
                           r'\verb+' + list(functions.keys())[idx] + '+')
    change_all_occurrences(r'\verb+2+', r'\verb+' + str(_2) + '+')
    change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')