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', _135) change_token_all_occurrences('a', a) change_token_all_occurrences('i', i) change_token_all_occurrences('k', k) change_token_all_occurrences('l', l) change_token_all_occurrences('m', m) change_all_occurrences('10', str(_10)) change_all_occurrences('15', str(_15)) # answers change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+') # indexes with no repetitions [_1,_3, _4, _5] = sample(range(_10), 4) change_all_occurrences(r'\verb+b+', r'\verb+' + str(_1) + '+') change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+') change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')
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+', r'\verb+' + a + '+') change_all_occurrences(r'\verb+b+', r'\verb+' + b + '+') change_all_occurrences(r'\verb+c+', r'\verb+' + c + '+') # indexes with no repetitions [_1, _2, _5] = sample(range(_13), 3) 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+5+', r'\verb+' + str(_5) + '+')
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>")
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', "<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( 'b', "<b><font color=red><i>" + b + "</font></i></b>") change_token_all_occurrences( 'c', "<b><font color=red><i>" + c + "</font></i></b>") change_token_all_occurrences( 'r', "<b><font color=red><i>" + r + "</font></i></b>") change_token_all_occurrences( 'i', "<b><font color=red><i>" + i + "</font></i></b>") change_all_occurrences( '13', "<b><font color=red><i>" + str(_13) + "</font></i></b>") # 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 _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 a global _1 global _2 global _3 global _4 global _5 # question _123456 = 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) _1000 = randint(19000, 20000) _100 = randint(500, 1000) _200 = _100 + 1000 change_all_occurrences('123456', "<b><i>" + _123456 + "</b></i>") change_token_all_occurrences('a', "<b><i>" + a + "</b></i>") change_token_all_occurrences('n', "<b><i>" + n + "</b></i>") change_all_occurrences('1000', "<b><i>" + str(_1000) + "</b></i>") change_all_occurrences('100', "<b><i>" + str(_100) + "</b></i>") change_all_occurrences('200', "<b><i>" + str(_200) + "</b></i>") # answers change_all_occurrences(r'\verb+a+', "<b><i>" + r'\verb+' + a + '+' + "</b></i>") # indexes with no repetitions [_1, _2, _3, _4, _5] = sample(range(_1000), 5) print(_1, _2, _3, _4, _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 _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(): '' global counter global d global _1 global _2 global _3 global _4 global _5 _135 = str(randint(1000000, 2000000)) [a, counter, c, d] = sample(string.ascii_lowercase, 4) _1 = randint(10, 80) _5 = randint(50, 100) _6 = randint(19000, 20000) _15 = randint(200, 500) change_all_occurrences('135', "<b><i>" + _135 + "</b></i>") change_token_all_occurrences('a', "<b><i>" + a + "</b></i>") change_token_all_occurrences('counter', "<b><i>" + counter + "</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('3', "<b><i>" + str(_1) + "</b></i>") change_all_occurrences('5', "<b><i>" + str(_5) + "</b></i>") change_all_occurrences('6', "<b><i>" + str(_6) + "</b></i>") change_all_occurrences('15', "<b><i>" + str(_15) + "</b></i>") change_all_occurrences(r'\verb+a+', "<b><i>" + r'\verb+' + a + '+' + "</b></i>") change_all_occurrences(r'\verb+c+', "<b><i>" + r'\verb+' + c + '+' + "</b></i>") change_all_occurrences(r'\verb+d+', "<b><i>" + r'\verb+' + d + '+' + "</b></i>") _2, decision1 = decision_function() _3, decision2 = decision_function_2() change_all_occurrences(r'\verb+2+', "<b><i>" + r'\verb+' + decision1 + '+' + "</b></i>") change_all_occurrences(r'\verb+3+', "<b><i>" + r'\verb+' + decision2 + '+' + "</b></i>") change_all_occurrences(r'\verb+5+', "<b><i>" + r'\verb+' + counter + '+' + "</b></i>")
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 + '+')
def make_transformations(): '' global c global _1 global _2 global _3 global _4 global _5 # question _135 = str(randint(1000000, 2000000)) c = 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 [c, d, o] = sample(string.ascii_lowercase, 3) _55 = randint(19000, 20000) _11 = randint(500, 1000) _333 = randint(0, 10000) change_all_occurrences('135', _135) change_token_all_occurrences('c', c) change_token_all_occurrences('d', d) change_token_all_occurrences('o', o) change_all_occurrences('55', str(_55)) change_all_occurrences('11', str(_11)) change_all_occurrences('333', str(_333)) # answers change_all_occurrences( r'\verb+a+', "<b><font color=red><i>" + r'\verb+' + c + '+' + "</font></i></b>") # indexes with no repetitions [_1, _2, _3, _4, _5] = sample(range(_55), 5) print(_1, _2, _3, _4, _5) 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+' + str(_3) + '+' + "</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>")
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) + '+')
def make_transformations(): '' global a global _1 global _2 global _3 global _4 global _5 # question _135 = str(randint(1000000, 2000000)) [a, n, c] = sample(string.ascii_lowercase, 3) _13 = randint(19000, 20000) _3 = randint(0, 5) _33 = randint(_3, 500) change_all_occurrences('135', _135) change_token_all_occurrences('a', a) change_token_all_occurrences('n', n) change_token_all_occurrences('c', c) 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 + '+') _1 = question_1() _2 = question_2() _3 = randint(_3, _33) _4 = choice((pt_impar, 'pares')) _5 = 'par' if _4 == pt_impar else pt_impar change_all_occurrences(r'\verb+1+', r'\verb+' + str(_1[0]) + '+') change_all_occurrences(r'\verb+2+', r'\verb+' + str(_2[0]) + '+') change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+') change_all_occurrences(r'\verb+4+', r'\verb+' + _4 + '+') change_all_occurrences(r'\verb+5+', r'\verb+' + _5 + '+')
def make_transformations(): '' global a global b global c global d global e # 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, i] = sample(string.ascii_lowercase, 6) _150 = randint(2000, 3000) _70 = _150 - 1500 _450 = _150 + 5000 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('i', i) change_all_occurrences('150', str(_150)) change_all_occurrences('70', str(_70)) change_all_occurrences('450', str(_450)) # answers change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+') change_all_occurrences(r'\verb+b+', r'\verb+' + b + '+') change_all_occurrences(r'\verb+c+', r'\verb+' + c + '+') change_all_occurrences(r'\verb+d+', r'\verb+' + d + '+') change_all_occurrences(r'\verb+e+', r'\verb+' + e + '+')
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) + '+')
def make_transformations(): '' global a global f global _1 global _2 global _3 global _4 global _5 # question _135 = str(randint(1000000, 2000000)) [a, b, c, d, e, f] = sample(string.ascii_lowercase, 6) _30 = 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('d', d) change_token_all_occurrences('e', e) change_token_all_occurrences('f', f) change_all_occurrences('30', str(_30)) # answers change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+') change_all_occurrences(r'\verb+b+', r'\verb+' + b + '+') change_all_occurrences(r'\verb+f+', r'\verb+' + f + '+') change_all_occurrences(r'\verb+_30+', r'\verb+' + str(_30) + '+') # indexes with no repetitions [_1, _2, _3, _4, _5] = sample(range(_30), 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) + '+')
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(): '' 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(): '' 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 + '+')
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(): '' 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, b, c, d, e, f] = sample(string.ascii_lowercase, 6) _300 = randint(19000, 20000) _125 = randint(0, 1500) 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_all_occurrences('300', str(_300)) change_all_occurrences('125', str(_125)) # answers change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+') # indexes with no repetitions [_1, _3, _4, _5] = sample(range(_300), 4) ## print(_300 , _1, _2, _3, _4, _5) change_all_occurrences(r'\verb+1+', r'\verb+' + str(_1) + '+') change_all_occurrences(r'\verb+3+', r'\verb+' + str(_3) + '+') change_all_occurrences(r'\verb+4+', r'\verb+' + str(_4) + '+')
def make_transformations(): '' global a global _1 global _2 global _3 global _4 global _5 # question _135 = str(randint(1000000, 2000000)) [a, i, k, s, m, l] = sample(string.ascii_lowercase, 6) _13 = randint(19000, 20000) change_all_occurrences('135', _135) change_token_all_occurrences('a', a) change_token_all_occurrences('i', i) change_token_all_occurrences('k', k) change_token_all_occurrences('s', s) change_token_all_occurrences('m', m) change_token_all_occurrences('l', l) change_all_occurrences('13', str(_13)) # answers change_all_occurrences(r'\verb+a+', r'\verb+' + a + '+') # indexes with no repetitions [_1, _2, _3, _4, _5] = sample(range(_13), 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) + '+')
def make_transformations(): '' global a global b global c global d global e global _5 # question _135 = str(randint(1000000, 2000000)) [a, b, c, d, e, i] = sample(string.ascii_lowercase, 6) _13 = randint(19000, 20000) _3 = randint(1, 500) _9 = randint(500, 1000) _18 = _9 * 2 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('i', i) change_all_occurrences('13', str(_13)) change_all_occurrences('3', str(_3)) change_all_occurrences('9', str(_9)) change_all_occurrences('18', str(_18)) # answers 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 + '+') # indexes with no repetitions [_5] = sample(range(_13), 1) change_all_occurrences(r'\verb+5+', r'\verb+' + str(_5) + '+')
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) + '+')
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 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>")
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', _135) change_token_all_occurrences('a', a) change_token_all_occurrences('P', P) change_token_all_occurrences('__var', __var) change_token_all_occurrences('p', p) change_token_all_occurrences('i', i) change_token_all_occurrences('n', n) 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+classp+', r'\verb+' + p + '+') change_all_occurrences(r'\verb+classP+', r'\verb+' + P + '+') # indexes with no repetitions [_1, _2_1, _2_2] = sample(range(_13), 3) change_all_occurrences(r'\verb+1+', r'\verb+' + str(_1) + '+') change_all_occurrences(r'\verb+2_1+', r'\verb+' + str(_2_1) + '+') change_all_occurrences(r'\verb+2_2+', r'\verb+' + str(_2_2) + '+') change_all_occurrences(r'\verb+3+', r'\verb+' + __var + '+')