|
275 | 275 | "#### 17. What is the result of the following expression? (★☆☆)" |
276 | 276 | ] |
277 | 277 | }, |
| 278 | + { |
| 279 | + "cell_type": "markdown", |
| 280 | + "metadata": {}, |
| 281 | + "source": [ |
| 282 | + "```python\n", |
| 283 | + "0 * np.nan\n", |
| 284 | + "np.nan == np.nan\n", |
| 285 | + "np.inf > np.nan\n", |
| 286 | + "np.nan - np.nan\n", |
| 287 | + "0.3 == 3 * 0.1\n", |
| 288 | + "```" |
| 289 | + ] |
| 290 | + }, |
278 | 291 | { |
279 | 292 | "cell_type": "code", |
280 | 293 | "execution_count": null, |
|
419 | 432 | "#### 26. What is the output of the following script? (★☆☆)" |
420 | 433 | ] |
421 | 434 | }, |
| 435 | + { |
| 436 | + "cell_type": "markdown", |
| 437 | + "metadata": {}, |
| 438 | + "source": [ |
| 439 | + "```python\n", |
| 440 | + "# Author: Jake VanderPlas\n", |
| 441 | + "\n", |
| 442 | + "print(sum(range(5),-1))\n", |
| 443 | + "from numpy import *\n", |
| 444 | + "print(sum(range(5),-1))\n", |
| 445 | + "```" |
| 446 | + ] |
| 447 | + }, |
422 | 448 | { |
423 | 449 | "cell_type": "code", |
424 | 450 | "execution_count": null, |
|
435 | 461 | "#### 27. Consider an integer vector Z, which of these expressions are legal? (★☆☆)" |
436 | 462 | ] |
437 | 463 | }, |
| 464 | + { |
| 465 | + "cell_type": "markdown", |
| 466 | + "metadata": {}, |
| 467 | + "source": [ |
| 468 | + "```python\n", |
| 469 | + "Z**Z\n", |
| 470 | + "2 << Z >> 2\n", |
| 471 | + "Z <- Z\n", |
| 472 | + "1j*Z\n", |
| 473 | + "Z/1/1\n", |
| 474 | + "Z<Z>Z\n", |
| 475 | + "```" |
| 476 | + ] |
| 477 | + }, |
438 | 478 | { |
439 | 479 | "cell_type": "code", |
440 | 480 | "execution_count": null, |
|
451 | 491 | "#### 28. What are the result of the following expressions?" |
452 | 492 | ] |
453 | 493 | }, |
| 494 | + { |
| 495 | + "cell_type": "markdown", |
| 496 | + "metadata": {}, |
| 497 | + "source": [ |
| 498 | + "```python\n", |
| 499 | + "np.array(0) / np.array(0)\n", |
| 500 | + "np.array(0) // np.array(0)\n", |
| 501 | + "np.array([np.nan]).astype(int).astype(float)\n", |
| 502 | + "```" |
| 503 | + ] |
| 504 | + }, |
454 | 505 | { |
455 | 506 | "cell_type": "code", |
456 | 507 | "execution_count": null, |
|
515 | 566 | "#### 32. Is the following expressions true? (★☆☆)" |
516 | 567 | ] |
517 | 568 | }, |
| 569 | + { |
| 570 | + "cell_type": "markdown", |
| 571 | + "metadata": {}, |
| 572 | + "source": [ |
| 573 | + "```python\n", |
| 574 | + "np.sqrt(-1) == np.emath.sqrt(-1)\n", |
| 575 | + "```" |
| 576 | + ] |
| 577 | + }, |
518 | 578 | { |
519 | 579 | "cell_type": "code", |
520 | 580 | "execution_count": null, |
|
867 | 927 | "#### 54. How to read the following file? (★★☆)" |
868 | 928 | ] |
869 | 929 | }, |
| 930 | + { |
| 931 | + "cell_type": "markdown", |
| 932 | + "metadata": {}, |
| 933 | + "source": [ |
| 934 | + "```\n", |
| 935 | + "1, 2, 3, 4, 5\n", |
| 936 | + "6, , , 7, 8\n", |
| 937 | + " , , 9,10,11\n", |
| 938 | + "```" |
| 939 | + ] |
| 940 | + }, |
870 | 941 | { |
871 | 942 | "cell_type": "code", |
872 | 943 | "execution_count": null, |
|
0 commit comments