#Q2 def lista_de_algarismos_ordem_reversa(n): """nome auto-explicativo entrada: int positivo saída: lista de ints""" lista_resposta = [] while n != 0: ultimo_algarismo = n%10 list.append(lista_resposta,ultimo_algarismo) n //= 10 return lista_resposta def int2roman(n): """converte n para romanos. entrada: int n entre 1 e 999 (inclusive) saída: string""" UNIDADES = { 0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX' } DEZENAS = { 0: '', 1: 'X', 2: 'XX', 3: 'XXX', 4: 'XL', 5: 'L', 6: 'LX', 7: 'LXX', 8: 'LXXX', 9: 'XC' } CENTENAS = { 0: '', 1: 'C', 2: 'CC', 3: 'CCC', 4: 'CD', 5: 'D', 6: 'DC', 7: 'DCC', 8:'DCCC', 9:'CM' } algarismos = lista_de_algarismos_ordem_reversa(n) if len(algarismos) == 0: return '' romano_unidades = UNIDADES[algarismos[0]] if len(algarismos) == 1: return romano_unidades romano_dezenas = DEZENAS[algarismos[1]] if len(algarismos) == 2: return romano_dezenas + romano_unidades romano_centenas = CENTENAS[algarismos[2]] return romano_centenas + romano_dezenas + romano_unidades #Q4 def rna_trad(molecula_RNA): """...""" tabela = {'UUU': 'Phe', 'CUU': 'Leu', 'UUA': 'Leu', 'AAG': 'Lisina', 'UCU': 'Ser', 'UAU': 'Tyr', 'CAA': 'Gln'} resultado = '' for n in range(len(molecula_RNA)//3): trinca_atual = molecula_RNA[3*n : 3*n +3] resultado += tabela[trinca_atual] + '-' return resultado[:-1] #Q6 def tinder(afinidades): """...""" lista_matches = [] for gostador in afinidades: gostado = afinidades[gostador] gostado_pelo_gostado = afinidades[gostado] if gostador == gostado_pelo_gostado: #MATCH if (gostado,gostador) not in lista_matches: #MATCH NOVO! list.append(lista_matches,(gostador,gostado)) return lista_matches