quinta-feira, 28 de maio de 2015

PY CODES #01



 Olá para todos aqui que escreve é o Sansigolo, hoje venho disponibilizar os códigos, em python, desenvolvidos por mim, para a resolução do EP1.


EXERCÍCIO 1

1:  x = 0  
2:  Contador_Prep = 0  
3:  Contador_Verb = 0  
4:  Contador_Verb_1P = 0  
5:  while x < len(txtB):  
6:    if str(txtB[x][0]) in "ftc":  
7:     if str(txtB[x][-1]) not in "ftc":  
8:      Contador_Prep = Contador_Prep + 1  
9:    x+=1  
10:  print ('Existem %d preposições no Texto B' %Contador_Prep)  

EXERCÍCIO 2

1:  x=0  
2:  while x < len(txtB):  
3:   if len(str(txtB[x])) == 5:  
4:    if str(txtB[x][-1]) not in "ftc":  
5:     Contador_Verb +=1  
6:     if str(txtB[x][0]) not in "ftc":  
7:      Contador_Verb_1P +=1  
8:   x+=1  
9:  print ('Existem %d verbos no texto B' %Contador_Verb)  

EXERCÍCIO 3

1:  x=0  
2:  while x < len(txtB):  
3:   if len(str(txtB[x])) == 5:  
4:    if str(txtB[x][-1]) not in "ftc":  
5:     Contador_Verb +=1  
6:     if str(txtB[x][0]) not in "ftc":  
7:      Contador_Verb_1P +=1  
8:   x+=1  
9:  print ('Existem %d estão em primeira pessoa B' %Contador_Verb_1P)  

EXERCÍCIO 4

1:  x = 0  
2:  Py_Alfabeto = "ftczmbshjpnwlrxkqvdg"  
3:  txtB.sort(key=lambda elemento: [Py_Alfabeto.index(v) for v in elemento[0]]+ [Py_Alfabeto.index(v) for v in elemento[1]]+ [Py_Alfabeto.index(v) for v in elemento[2]])  
4:  print(txtB)  

EXERCÍCIO 5

1:  x = 0  
2:  y = 0  
3:  Py_Alfabeto = ["f","t","c","z","m","b","s","h","j","p","n","w","l","r","x","k","q","v","d","g"]  
4:  Lista_Magicos = []  
5:  Lista_Magicos_F = []  
6:  Lista_Letra = []  
7:  soma = 0  
8:  while x < len(txtB):  
9:    while y < len(str(txtB[x])):  
10:      palavra = str(txtB[x])  
11:      num = Py_Alfabeto.index(txtB[x][y])  
12:      soma = soma + num*(20**y)  
13:      y = y + 1  
14:    resto = soma%42  
15:    if (resto==0):  
16:      if len(palavra) == len(set(palavra)):  
17:        Lista_Magicos.append(palavra)  
18:    soma = 0  
19:    y = 0  
20:    x = x + 1  
21:  print ('Existem %d numeros magicos na lista A' %(len(Lista_Magicos)))  
22:    

Espero que você leitor possa contribuir com sugestões, criticas(construtivas) e com pesquisas relacionadas sobre. Qualquer duvida entre em contato meu email é gabrielsansigolo@gmail.com

Forte Abraço, Sansigolo.

Um comentário: