1+ {
2+ "nbformat" : 4 ,
3+ "nbformat_minor" : 0 ,
4+ "metadata" : {
5+ "colab" : {
6+ "name" : " Desafio 8 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38" ,
7+ "provenance" : [],
8+ "authorship_tag" : " ABX9TyMSSSI36flsE0MkU2NVRDau" ,
9+ "include_colab_link" : true
10+ },
11+ "kernelspec" : {
12+ "name" : " python3" ,
13+ "display_name" : " Python 3"
14+ },
15+ "language_info" : {
16+ "name" : " python"
17+ }
18+ },
19+ "cells" : [
20+ {
21+ "cell_type" : " markdown" ,
22+ "metadata" : {
23+ "id" : " view-in-github" ,
24+ "colab_type" : " text"
25+ },
26+ "source" : [
27+ " <a href=\" https://colab.research.google.com/github/marcilioduarte/br-python-challenges/blob/master/Desafio_8_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb\" target=\" _parent\" ><img src=\" https://colab.research.google.com/assets/colab-badge.svg\" alt=\" Open In Colab\" /></a>"
28+ ]
29+ },
30+ {
31+ "cell_type" : " markdown" ,
32+ "source" : [
33+ " \n "
34+ ],
35+ "metadata" : {
36+ "id" : " MacXeo6FTB7r"
37+ }
38+ },
39+ {
40+ "cell_type" : " markdown" ,
41+ "source" : [
42+ " ### Desafio 8\n " ,
43+ " \n " ,
44+ " Escreva um script Python para encontrar as 10 palavras mais longas em um arquivo de texto.\n " ,
45+ " O arquivo .txt está localizado na mesma pasta do projeto (**texto.txt**)."
46+ ],
47+ "metadata" : {
48+ "id" : " mqI_oC0ATGbk"
49+ }
50+ },
51+ {
52+ "cell_type" : " code" ,
53+ "source" : [
54+ " #colei porque não consegui fazer sozinho\n " ,
55+ " \n " ,
56+ " from operator import itemgetter\n " ,
57+ " with open('texto.txt','r') as t_base:\n " ,
58+ " dic={}\n " ,
59+ " conteudo=t_base.read().replace('.',' ').replace('-', \" \" ).replace(',',' ').replace(')', ' ')\n " ,
60+ " for palavra in conteudo.split():\n " ,
61+ " dic[f'{palavra}']=len(palavra)\n " ,
62+ " ordem=sorted(dic.items(),key=itemgetter(1),reverse=True)\n " ,
63+ " for k, v in enumerate(ordem):\n " ,
64+ " if k < 10:\n " ,
65+ " print(v[0],v[1])"
66+ ],
67+ "metadata" : {
68+ "id" : " IX-Z5n1ATKGR" ,
69+ "colab" : {
70+ "base_uri" : " https://localhost:8080/"
71+ },
72+ "outputId" : " 8bdc06bf-6559-4606-ed36-1c6ea0dc65c4"
73+ },
74+ "execution_count" : null ,
75+ "outputs" : [
76+ {
77+ "output_type" : " stream" ,
78+ "name" : " stdout" ,
79+ "text" : [
80+ " comprehensive 13\n " ,
81+ " intermediate 12\n " ,
82+ " interpreted 11\n " ,
83+ " programming 11\n " ,
84+ " readability 11\n " ,
85+ " programmers 11\n " ,
86+ " philosophy 10\n " ,
87+ " emphasizes 10\n " ,
88+ " imperative 10\n " ,
89+ " functional 10\n "
90+ ]
91+ }
92+ ]
93+ },
94+ {
95+ "cell_type" : " code" ,
96+ "source" : [
97+ " "
98+ ],
99+ "metadata" : {
100+ "id" : " ouy8i6u24W3U"
101+ },
102+ "execution_count" : null ,
103+ "outputs" : []
104+ }
105+ ]
106+ }
0 commit comments