|
83 | 83 | },
|
84 | 84 | {
|
85 | 85 | "cell_type": "code",
|
86 |
| - "execution_count": 1, |
| 86 | + "execution_count": 43, |
87 | 87 | "metadata": {
|
88 | 88 | "collapsed": false,
|
89 | 89 | "slideshow": {
|
|
109 | 109 | },
|
110 | 110 | {
|
111 | 111 | "cell_type": "code",
|
112 |
| - "execution_count": 2, |
| 112 | + "execution_count": 44, |
113 | 113 | "metadata": {
|
114 | 114 | "collapsed": false,
|
115 | 115 | "slideshow": {
|
|
141 | 141 | },
|
142 | 142 | {
|
143 | 143 | "cell_type": "code",
|
144 |
| - "execution_count": 3, |
| 144 | + "execution_count": 45, |
145 | 145 | "metadata": {
|
146 | 146 | "collapsed": false,
|
147 | 147 | "slideshow": {
|
|
169 | 169 | },
|
170 | 170 | {
|
171 | 171 | "cell_type": "code",
|
172 |
| - "execution_count": 4, |
| 172 | + "execution_count": 46, |
173 | 173 | "metadata": {
|
174 | 174 | "collapsed": false,
|
175 | 175 | "slideshow": {
|
|
193 | 193 | },
|
194 | 194 | {
|
195 | 195 | "cell_type": "code",
|
196 |
| - "execution_count": 5, |
| 196 | + "execution_count": 47, |
197 | 197 | "metadata": {
|
198 | 198 | "collapsed": false,
|
199 | 199 | "slideshow": {
|
|
205 | 205 | "name": "stdout",
|
206 | 206 | "output_type": "stream",
|
207 | 207 | "text": [
|
208 |
| - "A dictionary: {'C': 'Cytosine', 'T': 'Thymine', 'G': 'Guanine', 'A': 'Adenine'}\n", |
| 208 | + "A dictionary: {'G': 'Guanine', 'T': 'Thymine', 'A': 'Adenine', 'C': 'Cytosine'}\n", |
209 | 209 | "Value associated to key C: Cytosine\n"
|
210 | 210 | ]
|
211 | 211 | }
|
|
233 | 233 | },
|
234 | 234 | {
|
235 | 235 | "cell_type": "code",
|
236 |
| - "execution_count": 6, |
| 236 | + "execution_count": 48, |
237 | 237 | "metadata": {
|
238 | 238 | "collapsed": false
|
239 | 239 | },
|
|
272 | 272 | },
|
273 | 273 | {
|
274 | 274 | "cell_type": "code",
|
275 |
| - "execution_count": 7, |
| 275 | + "execution_count": 49, |
276 | 276 | "metadata": {
|
277 | 277 | "collapsed": false,
|
278 | 278 | "slideshow": {
|
|
302 | 302 | },
|
303 | 303 | {
|
304 | 304 | "cell_type": "code",
|
305 |
| - "execution_count": 8, |
| 305 | + "execution_count": 50, |
306 | 306 | "metadata": {
|
307 | 307 | "collapsed": false,
|
308 | 308 | "slideshow": {
|
|
332 | 332 | },
|
333 | 333 | {
|
334 | 334 | "cell_type": "code",
|
335 |
| - "execution_count": 9, |
| 335 | + "execution_count": 51, |
336 | 336 | "metadata": {
|
337 | 337 | "collapsed": false,
|
338 | 338 | "slideshow": {
|
|
379 | 379 | },
|
380 | 380 | {
|
381 | 381 | "cell_type": "code",
|
382 |
| - "execution_count": 10, |
| 382 | + "execution_count": 52, |
383 | 383 | "metadata": {
|
384 | 384 | "collapsed": false
|
385 | 385 | },
|
|
399 | 399 | "print(\"ATG TCA CCG GGC\".split())"
|
400 | 400 | ]
|
401 | 401 | },
|
| 402 | + { |
| 403 | + "cell_type": "markdown", |
| 404 | + "metadata": { |
| 405 | + "slideshow": { |
| 406 | + "slide_type": "slide" |
| 407 | + } |
| 408 | + }, |
| 409 | + "source": [ |
| 410 | + "## Exercise 2.0.1\n", |
| 411 | + "\n", |
| 412 | + "- Create a string variable with the lyrics of Imagine by John Lennon, 1971. Split into words. Print the total number of words, and the number of unique words. Calculate the frequency of each word and store the result into a dictionary. Print each unique word along with its frequency. Find the most frequent word in the song, print it with its frequency.\n", |
| 413 | + "\n", |
| 414 | + "<center><img src=\"https://upload.wikimedia.org/wikipedia/en/1/1d/John_Lennon_-_Imagine_John_Lennon.jpg\"/></center>" |
| 415 | + ] |
| 416 | + }, |
| 417 | + { |
| 418 | + "cell_type": "code", |
| 419 | + "execution_count": 53, |
| 420 | + "metadata": { |
| 421 | + "collapsed": false, |
| 422 | + "slideshow": { |
| 423 | + "slide_type": "subslide" |
| 424 | + } |
| 425 | + }, |
| 426 | + "outputs": [], |
| 427 | + "source": [ |
| 428 | + "lyrics = \"\"\"\n", |
| 429 | + "Imagine there's no Heaven\n", |
| 430 | + "It's easy if you try\n", |
| 431 | + "No Hell below us\n", |
| 432 | + "Above us only sky\n", |
| 433 | + "\n", |
| 434 | + "Imagine all the people\n", |
| 435 | + "Living for today\n", |
| 436 | + "Aaa haa\n", |
| 437 | + "\n", |
| 438 | + "Imagine there's no countries\n", |
| 439 | + "It isn't hard to do\n", |
| 440 | + "Nothing to kill or die for\n", |
| 441 | + "And no religion too\n", |
| 442 | + "\n", |
| 443 | + "Imagine all the people\n", |
| 444 | + "Living life in peace\n", |
| 445 | + "Yoo hoo\n", |
| 446 | + "\n", |
| 447 | + "You may say I'm a dreamer\n", |
| 448 | + "But I'm not the only one\n", |
| 449 | + "I hope someday you'll join us\n", |
| 450 | + "And the world will be as one\n", |
| 451 | + "\n", |
| 452 | + "Imagine no possessions\n", |
| 453 | + "I wonder if you can\n", |
| 454 | + "No need for greed or hunger\n", |
| 455 | + "A brotherhood of man\n", |
| 456 | + "\n", |
| 457 | + "Imagine all the people\n", |
| 458 | + "Sharing all the world\n", |
| 459 | + "Yoo hoo\n", |
| 460 | + "\n", |
| 461 | + "You may say I'm a dreamer\n", |
| 462 | + "But I'm not the only one\n", |
| 463 | + "I hope someday you'll join us\n", |
| 464 | + "And the world will live as one\n", |
| 465 | + "\"\"\"" |
| 466 | + ] |
| 467 | + }, |
402 | 468 | {
|
403 | 469 | "cell_type": "markdown",
|
404 | 470 | "metadata": {
|
|
0 commit comments