Skip to content

Commit d37cb5c

Browse files
committed
Day 4'
1 parent 4d881d5 commit d37cb5c

File tree

6 files changed

+1407
-0
lines changed

6 files changed

+1407
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/plain": [
11+
"Counter({0: 2, 1: 1, 2: 1})"
12+
]
13+
},
14+
"execution_count": 2,
15+
"metadata": {},
16+
"output_type": "execute_result"
17+
}
18+
],
19+
"source": [
20+
"from collections import Counter\n",
21+
"c = Counter([0,1,2,0])\n",
22+
"c"
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"execution_count": 3,
28+
"metadata": {},
29+
"outputs": [
30+
{
31+
"data": {
32+
"text/plain": [
33+
"['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog.']"
34+
]
35+
},
36+
"execution_count": 3,
37+
"metadata": {},
38+
"output_type": "execute_result"
39+
}
40+
],
41+
"source": [
42+
"str = 'the quick brown fox jumps over the lazy dog.'\n",
43+
"words = str.split()\n",
44+
"words"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": 5,
50+
"metadata": {},
51+
"outputs": [
52+
{
53+
"data": {
54+
"text/plain": [
55+
"Counter({'brown': 1,\n",
56+
" 'dog.': 1,\n",
57+
" 'fox': 1,\n",
58+
" 'jumps': 1,\n",
59+
" 'lazy': 1,\n",
60+
" 'over': 1,\n",
61+
" 'quick': 1,\n",
62+
" 'the': 2})"
63+
]
64+
},
65+
"execution_count": 5,
66+
"metadata": {},
67+
"output_type": "execute_result"
68+
}
69+
],
70+
"source": [
71+
"word_count = Counter(words)\n",
72+
"word_count"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": 6,
78+
"metadata": {},
79+
"outputs": [
80+
{
81+
"name": "stdout",
82+
"output_type": "stream",
83+
"text": [
84+
"the 2\n",
85+
"dog. 1\n",
86+
"brown 1\n"
87+
]
88+
}
89+
],
90+
"source": [
91+
"for word,count in word_count.most_common(3):\n",
92+
" print word,count"
93+
]
94+
}
95+
],
96+
"metadata": {
97+
"kernelspec": {
98+
"display_name": "Python 2",
99+
"language": "python",
100+
"name": "python2"
101+
},
102+
"language_info": {
103+
"codemirror_mode": {
104+
"name": "ipython",
105+
"version": 2
106+
},
107+
"file_extension": ".py",
108+
"mimetype": "text/x-python",
109+
"name": "python",
110+
"nbconvert_exporter": "python",
111+
"pygments_lexer": "ipython2",
112+
"version": "2.7.18"
113+
}
114+
},
115+
"nbformat": 4,
116+
"nbformat_minor": 2
117+
}

0 commit comments

Comments
 (0)