|
6 | 6 | "source": [ |
7 | 7 | "# Python the basics: datatypes\n", |
8 | 8 | "\n", |
9 | | - "> *DS Data manipulation, analysis and visualisation in Python* \n", |
10 | | - "> *December, 2017*\n", |
11 | | - "\n", |
12 | | - "> *© 2016, Joris Van den Bossche and Stijn Van Hoey (<mailto:jorisvandenbossche@gmail.com>, <mailto:stijnvanhoey@gmail.com>). Licensed under [CC BY 4.0 Creative Commons](http://creativecommons.org/licenses/by/4.0/)*\n", |
13 | | - "\n", |
| 9 | + "> *DS Data manipulation, analysis and visualization in Python* \n", |
| 10 | + "> *May/June, 2021*\n", |
| 11 | + ">\n", |
| 12 | + "> *© 2021, Joris Van den Bossche and Stijn Van Hoey (<mailto:jorisvandenbossche@gmail.com>, <mailto:stijnvanhoey@gmail.com>). Licensed under [CC BY 4.0 Creative Commons](http://creativecommons.org/licenses/by/4.0/)*\n", |
14 | 13 | "\n", |
15 | 14 | "---\n", |
16 | 15 | "\n", |
|
404 | 403 | "run_control": { |
405 | 404 | "frozen": false, |
406 | 405 | "read_only": false |
407 | | - } |
| 406 | + }, |
| 407 | + "tags": [] |
408 | 408 | }, |
409 | 409 | "outputs": [], |
410 | 410 | "source": [ |
|
418 | 418 | "run_control": { |
419 | 419 | "frozen": false, |
420 | 420 | "read_only": false |
421 | | - } |
| 421 | + }, |
| 422 | + "tags": [] |
422 | 423 | }, |
423 | 424 | "outputs": [], |
424 | 425 | "source": [ |
|
545 | 546 | "run_control": { |
546 | 547 | "frozen": false, |
547 | 548 | "read_only": false |
548 | | - } |
| 549 | + }, |
| 550 | + "tags": [] |
549 | 551 | }, |
550 | 552 | "outputs": [], |
551 | 553 | "source": [ |
552 | | - "# %load _solutions/01-basic24.py" |
| 554 | + "a_third_list.count?" |
553 | 555 | ] |
554 | 556 | }, |
555 | 557 | { |
|
560 | 562 | "run_control": { |
561 | 563 | "frozen": false, |
562 | 564 | "read_only": false |
563 | | - } |
| 565 | + }, |
| 566 | + "tags": [] |
564 | 567 | }, |
565 | 568 | "outputs": [], |
566 | 569 | "source": [ |
567 | | - "# %load _solutions/01-basic25.py" |
| 570 | + "a_third_list.index??" |
568 | 571 | ] |
569 | 572 | }, |
570 | 573 | { |
|
581 | 584 | "run_control": { |
582 | 585 | "frozen": false, |
583 | 586 | "read_only": false |
584 | | - } |
| 587 | + }, |
| 588 | + "tags": [] |
585 | 589 | }, |
586 | 590 | "outputs": [], |
587 | 591 | "source": [ |
|
625 | 629 | }, |
626 | 630 | "outputs": [], |
627 | 631 | "source": [ |
628 | | - "# %load _solutions/01-basic28.py" |
| 632 | + "a_third_list[::-1]" |
629 | 633 | ] |
630 | 634 | }, |
631 | 635 | { |
|
674 | 678 | "run_control": { |
675 | 679 | "frozen": false, |
676 | 680 | "read_only": false |
677 | | - } |
| 681 | + }, |
| 682 | + "tags": [] |
678 | 683 | }, |
679 | 684 | "outputs": [], |
680 | 685 | "source": [ |
|
834 | 839 | "run_control": { |
835 | 840 | "frozen": false, |
836 | 841 | "read_only": false |
837 | | - } |
| 842 | + }, |
| 843 | + "tags": [] |
838 | 844 | }, |
839 | 845 | "outputs": [], |
840 | 846 | "source": [ |
841 | | - "## pay attention when using apostrophes! - test out the nxt two lines one at a time\n", |
| 847 | + "## pay attention when using apostrophes! - test out the next two lines one at a time\n", |
842 | 848 | "#print('Hi, what's up?')\n", |
843 | 849 | "#print(\"Hi, what's up?\")" |
844 | 850 | ] |
|
925 | 931 | "run_control": { |
926 | 932 | "frozen": false, |
927 | 933 | "read_only": false |
928 | | - } |
| 934 | + }, |
| 935 | + "tags": [] |
929 | 936 | }, |
930 | 937 | "outputs": [], |
931 | 938 | "source": [ |
|
946 | 953 | "run_control": { |
947 | 954 | "frozen": false, |
948 | 955 | "read_only": false |
949 | | - } |
| 956 | + }, |
| 957 | + "tags": [] |
950 | 958 | }, |
951 | 959 | "outputs": [], |
952 | 960 | "source": [ |
|
1047 | 1055 | }, |
1048 | 1056 | "outputs": [], |
1049 | 1057 | "source": [ |
1050 | | - "# %load _solutions/01-basic47.py" |
| 1058 | + "[el for el in dir(list) if not el[0]=='_']" |
1051 | 1059 | ] |
1052 | 1060 | }, |
1053 | 1061 | { |
|
1066 | 1074 | "run_control": { |
1067 | 1075 | "frozen": false, |
1068 | 1076 | "read_only": false |
1069 | | - } |
| 1077 | + }, |
| 1078 | + "tags": [] |
1070 | 1079 | }, |
1071 | 1080 | "outputs": [], |
1072 | 1081 | "source": [ |
|
1085 | 1094 | }, |
1086 | 1095 | "outputs": [], |
1087 | 1096 | "source": [ |
1088 | | - "# %load _solutions/01-basic49.py" |
| 1097 | + "#split in words and get word lengths\n", |
| 1098 | + "[len(word) for word in sentence.split()]" |
1089 | 1099 | ] |
1090 | 1100 | }, |
1091 | 1101 | { |
|
1233 | 1243 | "metadata": {}, |
1234 | 1244 | "source": [ |
1235 | 1245 | "<div class=\"alert alert alert-success\">\n", |
1236 | | - " <b>Exercise</b> Put all keys of the hourly_wage dictionary in a list as strings. If their not yet a string, convert them:\n", |
| 1246 | + " <b>Exercise</b> Put all keys of the `hourly_wage` dictionary in a list as strings. If they are not yet a string, convert them:\n", |
1237 | 1247 | "</div>" |
1238 | 1248 | ] |
1239 | 1249 | }, |
1240 | 1250 | { |
1241 | 1251 | "cell_type": "code", |
1242 | 1252 | "execution_count": null, |
1243 | | - "metadata": {}, |
| 1253 | + "metadata": { |
| 1254 | + "tags": [] |
| 1255 | + }, |
1244 | 1256 | "outputs": [], |
1245 | 1257 | "source": [ |
1246 | 1258 | "hourly_wage = {'Jos':10, 'Frida': 9, 'Gaspard': '13', 23 : 3}" |
|
1258 | 1270 | }, |
1259 | 1271 | "outputs": [], |
1260 | 1272 | "source": [ |
1261 | | - "# %load _solutions/01-basic58.py" |
| 1273 | + "str_key = []\n", |
| 1274 | + "for key in hourly_wage.keys():\n", |
| 1275 | + " str_key.append(str(key))\n", |
| 1276 | + "str_key" |
1262 | 1277 | ] |
1263 | 1278 | }, |
1264 | 1279 | { |
|
1339 | 1354 | "name": "python", |
1340 | 1355 | "nbconvert_exporter": "python", |
1341 | 1356 | "pygments_lexer": "ipython3", |
1342 | | - "version": "3.7.3" |
| 1357 | + "version": "3.8.10" |
1343 | 1358 | }, |
1344 | 1359 | "nav_menu": {}, |
1345 | 1360 | "toc": { |
|
1353 | 1368 | } |
1354 | 1369 | }, |
1355 | 1370 | "nbformat": 4, |
1356 | | - "nbformat_minor": 1 |
| 1371 | + "nbformat_minor": 4 |
1357 | 1372 | } |
0 commit comments