|
354 | 354 | "outputs": [],
|
355 | 355 | "source": [
|
356 | 356 | "x = 5\n",
|
357 |
| - "type(x) == int" |
| 357 | + "isinstance(x, int)" |
358 | 358 | ]
|
359 | 359 | },
|
360 | 360 | {
|
|
367 | 367 | "# if statements allow our scripts to encode more complex instructions\n",
|
368 | 368 | "\n",
|
369 | 369 | "x = 5\n",
|
370 |
| - "if type(x) == int:\n", |
| 370 | + "if isinstance(x, int):\n", |
371 | 371 | " print(x, 'is an integer')\n"
|
372 | 372 | ]
|
373 | 373 | },
|
|
379 | 379 | "source": [
|
380 | 380 | "# if-else\n",
|
381 | 381 | "\n",
|
382 |
| - "if type(x) == str:\n", |
| 382 | + "if isinstance(x, str):\n", |
383 | 383 | " print(x, 'is a string')\n",
|
384 | 384 | "else:\n",
|
385 | 385 | " print(x, 'is not a string')"
|
|
394 | 394 | "# if-elif-else\n",
|
395 | 395 | "# useful if we have multiple conditions to test\n",
|
396 | 396 | "\n",
|
397 |
| - "if type(x) == str:\n", |
| 397 | + "if isinstance(x, str):\n", |
398 | 398 | " print(x, 'is a string')\n",
|
399 |
| - "elif type(x) == int:\n", |
| 399 | + "elif isinstance(x, int):\n", |
400 | 400 | " print(x, 'is an integer')\n",
|
401 | 401 | "else:\n",
|
402 | 402 | " print(x, 'is neither a string nor an integer')"
|
|
651 | 651 | "metadata": {},
|
652 | 652 | "outputs": [],
|
653 | 653 | "source": [
|
654 |
| - "sns.relplot(x = 'petal_length', y = 'petal_width', data = iris)" |
| 654 | + "sns.relplot(x='petal_length', y='petal_width', data=iris)" |
655 | 655 | ]
|
656 | 656 | },
|
657 | 657 | {
|
|
660 | 660 | "metadata": {},
|
661 | 661 | "outputs": [],
|
662 | 662 | "source": [
|
663 |
| - "sns.relplot(x = 'petal_length', y = 'petal_width', hue = 'species', data = iris)" |
| 663 | + "sns.relplot(x='petal_length', y='petal_width', hue='species', data=iris)" |
664 | 664 | ]
|
665 | 665 | }
|
666 | 666 | ],
|
|
0 commit comments