diff --git a/your-code/Untitled.ipynb b/your-code/Untitled.ipynb new file mode 100644 index 0000000..35eac67 --- /dev/null +++ b/your-code/Untitled.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/your-code/challenge-1.ipynb b/your-code/challenge-1.ipynb index 48f6b46..7544ec9 100755 --- a/your-code/challenge-1.ipynb +++ b/your-code/challenge-1.ipynb @@ -15,11 +15,28 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "# Your code here" + "tup=(\"I\",)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I',)\n" + ] + } + ], + "source": [ + "print(tup)" ] }, { @@ -33,11 +50,23 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "tuple" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here" + "type(tup)\n", + "\n" ] }, { @@ -55,20 +84,30 @@ }, { "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], + "execution_count": 14, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('r', 'o', 'n', 'h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n", + "tup = (\"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n", "\n", - "# Your explanation here\n" + "print(tup)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### How about re-assign a new value to an existing tuple?\n", + "\n", "\n", "Re-assign the following elements to `tup`. Are you able to do it? Explain.\n", "\n", @@ -79,13 +118,21 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n", + "tup = (\"I\", \"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n", "\n", - "# Your explanation here\n" + "print (tup)" ] }, { @@ -103,11 +150,23 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n')\n", + "('h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n" + "tup1=(\"I\", \"r\", \"o\", \"n\")\n", + "tup2=(\"h\", \"a\", \"c\", \"k\")\n", + "print(tup1)\n", + "print(tup2)" ] }, { @@ -121,11 +180,21 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n" + "tup3 = tup1 + tup2 \n", + "\n", + "print(tup3)\n" ] }, { @@ -137,11 +206,23 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "8" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "len((tup1)+(tup2))\n", + "len(tup3)" ] }, { @@ -153,11 +234,22 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'h'" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here" + "tup3[4]" ] }, { @@ -177,11 +269,32 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a - True\n", + "b - False\n", + "c - True\n", + "d - False\n", + "e - False\n" + ] + } + ], "source": [ - "# Your code here\n" + "letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n", + "\n", + "\n", + "for i in letters:\n", + " if i in tup3:\n", + " print(i,\"-\", True)\n", + " else:\n", + " print(i,\"-\",False)\n", + " \n", + "\n" ] }, { @@ -195,11 +308,27 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 21, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "0\n", + "1\n", + "0\n", + "0\n" + ] + } + ], "source": [ - "# Your code here\n" + "numbers_letters = []\n", + "\n", + "for letter in letters:\n", + " print(tup3.count(letter))\n", + " " ] }, { @@ -211,12 +340,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "range(10,20)\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -235,7 +380,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/your-code/challenge-2.ipynb b/your-code/challenge-2.ipynb index ef7bde3..8fcea09 100755 --- a/your-code/challenge-2.ipynb +++ b/your-code/challenge-2.ipynb @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -38,11 +38,35 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[9, 80, 12, 33, 31, 97, 20, 41, 1, 64, 44, 10, 46, 60, 24, 71, 68, 4, 73, 83, 21, 11, 37, 35, 49, 25, 16, 28, 96, 79, 61, 6, 76, 56, 5, 30, 14, 51, 8, 17, 58, 0, 3, 82, 36, 26, 77, 74, 19, 75, 90, 52, 72, 18, 86, 81, 95, 40, 87, 84, 92, 13, 7, 89, 50, 53, 99, 42, 94, 38, 39, 47, 57, 63, 69, 54, 43, 66, 70, 62]\n" + ] + }, + { + "data": { + "text/plain": [ + "80" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Your code here\n", + "sample_list_1 = random.sample(range(100),(80))\n", + "\n", + "print(sample_list_1)\n", + "\n", + "\n", + "len(sample_list_1)" ] }, { @@ -54,11 +78,33 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 24, 25, 26, 28, 30, 31, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 60, 61, 62, 63, 64, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 86, 87, 89, 90, 92, 94, 95, 96, 97, 99}\n" + ] + }, + { + "data": { + "text/plain": [ + "80" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Your code here\n", + "set1=set(sample_list_1)\n", + "print(set1)\n", + "\n", + "len(set1)" ] }, { @@ -77,11 +123,39 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[78, 19, 21, 17, 16, 31, 71, 87, 45, 24, 1, 65, 39, 50, 58, 5, 45, 62, 58, 51, 51, 82, 43, 4, 85, 72, 77, 26, 22, 98, 61, 29, 7, 21, 1, 3, 58, 35, 75, 88, 25, 58, 85, 36, 36, 35, 44, 23, 13, 97, 65, 57, 13, 73, 3, 98, 12, 24, 72, 15, 46, 50, 43, 67, 76, 47, 60, 6, 12, 68, 37, 89, 51, 84, 6, 22, 58, 98, 45, 41]\n" + ] + }, + { + "data": { + "text/plain": [ + "80" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Your code here\n", + "\n", + "sample_list_2= []\n", + "\n", + "for i in range(80):\n", + " i = random.randrange(101)\n", + " sample_list_2.append(i)\n", + "\n", + "print(sample_list_2)\n", + "\n", + "len(sample_list_2)" ] }, { @@ -93,11 +167,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1, 3, 4, 5, 6, 7, 12, 13, 15, 16, 17, 19, 21, 22, 23, 24, 25, 26, 29, 31, 35, 36, 37, 39, 41, 43, 44, 45, 46, 47, 50, 51, 57, 58, 60, 61, 62, 65, 67, 68, 71, 72, 73, 75, 76, 77, 78, 82, 84, 85, 87, 88, 89, 97, 98}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "\n", + "set2=set(sample_list_2)\n", + "\n", + "print(set2)\n", + "\n" ] }, { @@ -109,11 +196,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{0, 8, 9, 10, 11, 14, 18, 20, 28, 30, 33, 38, 40, 42, 49, 52, 53, 54, 56, 63, 64, 66, 69, 70, 74, 79, 80, 81, 83, 86, 90, 92, 94, 95, 96, 99}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "\n", + "set3 = set1-set2\n", + "\n", + "print(set3)\n", + "\n" ] }, { @@ -125,11 +225,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{65, 98, 67, 45, 78, 15, 85, 22, 23, 88, 29}\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "set4 = set2-set1\n", + "print(set4)" ] }, { @@ -141,11 +251,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1, 3, 4, 5, 6, 7, 12, 13, 16, 17, 19, 21, 24, 25, 26, 31, 35, 36, 37, 39, 41, 43, 44, 46, 47, 50, 51, 57, 58, 60, 61, 62, 68, 71, 72, 73, 75, 76, 77, 82, 84, 87, 89, 97}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "set5 = set1 & set2\n", + "print(set5)\n", + "\n", + "\n" ] }, { @@ -165,11 +287,103 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "80" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Your code here\n", + "len(set1)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "55" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(set2)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "36" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "len(set3)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "11" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(set4)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "44" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(set5)" ] }, { @@ -181,11 +395,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "set6=[]\n", + "\n", + "set6=set(set6)\n", + "\n", + "\n" ] }, { @@ -197,11 +416,25 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{0, 8, 9, 10, 11, 14, 18, 20, 28, 30, 33, 38, 40, 42, 49, 52, 53, 54, 56, 63, 64, 66, 69, 70, 74, 79, 80, 81, 83, 86, 90, 92, 94, 95, 96, 99}\n", + "{1, 3, 4, 5, 6, 7, 12, 13, 16, 17, 19, 21, 24, 25, 26, 31, 35, 36, 37, 39, 41, 43, 44, 46, 47, 50, 51, 57, 58, 60, 61, 62, 68, 71, 72, 73, 75, 76, 77, 82, 84, 87, 89, 97}\n", + "{0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 24, 25, 26, 28, 30, 31, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 60, 61, 62, 63, 64, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 86, 87, 89, 90, 92, 94, 95, 96, 97, 99}\n" + ] + } + ], + "source": [ + "print(set3)\n", + "print(set5)\n", + "\n", + "set6.update(set3,set5)\n", + "print(set6)\n" ] }, { @@ -213,11 +446,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "if set1 == set6: \n", + " print (\"True\") \n", + "else : \n", + " print (\"False\") " ] }, { @@ -229,11 +474,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "print(set1.issubset(set2))" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], + "source": [ + "print(set1.issubset(set3))" ] }, { @@ -247,11 +518,30 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 94, 95, 96, 97, 98, 99}\n", + "{0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 94, 95, 96, 97, 98, 99}\n", + "True\n" + ] + } + ], + "source": [ + "# Your code here\n", + "set_list1 = set3.union(set4,set5)\n", + "print(set_list1)\n", + "set_list2 = set1.union(set2)\n", + "print(set_list2)\n", + "\n", + "if set_list1 == set_list2: \n", + " print (\"True\") \n", + "else : \n", + " print (\"False\") " ] }, { @@ -263,11 +553,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 24, 25, 26, 28, 30, 31, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 60, 61, 62, 63, 64, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 86, 87, 89, 90, 92, 94, 95, 96, 97, 99}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "\n", + "set1.pop()\n", + "\n", + "print(set1)" ] }, { @@ -281,14 +583,45 @@ "```" ] }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{5, 6, 7, 8, 10, 12, 13, 14, 16, 17, 18, 20, 24, 25, 26, 28, 30, 33, 35, 36, 37, 38, 40, 42, 43, 44, 46, 47, 50, 52, 53, 54, 56, 57, 58, 60, 62, 63, 64, 66, 68, 70, 72, 73, 74, 75, 76, 77, 80, 82, 83, 84, 86, 87, 90, 92, 94, 95, 96, 97}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "list_to_remove = [1, 9, 11, 19, 21, 29, 31, 39, 41, 49, 51, 59, 61, 69, 71, 79, 81, 89, 91, 99]\n", + "\n", + "#new_list=[i for i in set1 if i not in list_to_remove]\n", + "\n", + "new_list=set1.copy()\n", + "\n", + "for i in set1:\n", + " if i in list_to_remove:\n", + " new_list.remove(i)\n", + " \n", + "\n", + "print(new_list)\n", + "\n", + " \n", + " \n", + "\n" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "# Your code here\n" - ] + "source": [] } ], "metadata": { @@ -307,7 +640,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/your-code/challenge-3.ipynb b/your-code/challenge-3.ipynb index 74d65e0..5967566 100755 --- a/your-code/challenge-3.ipynb +++ b/your-code/challenge-3.ipynb @@ -21,11 +21,12 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "dict1={\"Penelope\":\"178\",\"Arnau\":\"172\",\"Marta\":175}" ] }, { @@ -37,11 +38,103 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Penelope\n", + "Arnau\n", + "Marta\n" + ] + } + ], + "source": [ + "# Your code here\n", + "for x in dict1:\n", + " print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "178\n", + "172\n", + "175\n" + ] + } + ], + "source": [ + "for x in dict1:\n", + " print(dict1[x])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Penelope\n", + "Arnau\n", + "Marta\n" + ] + } + ], + "source": [ + "for x in dict1.keys():\n", + " print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "178\n", + "172\n", + "175\n" + ] + } + ], + "source": [ + "for x in dict1.values():\n", + " print(x)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('Penelope', '178')\n", + "('Arnau', '172')\n", + "('Marta', 175)\n" + ] + } + ], "source": [ - "# Your code here\n" + "for x in dict1.items():\n", + " print(x)" ] }, { @@ -53,11 +146,25 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Penelope': '178', 'Arnau': '172', 'Marta': 175, 'Anna': '160'}\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "dict1={\"Penelope\":\"178\",\"Arnau\":\"172\",\"Marta\":175}\n", + "\n", + "dict1[\"Anna\"]='160'\n", + "\n", + "print(dict1)\n" ] }, { @@ -69,11 +176,22 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Penelope': '178', 'Arnau': '172', 'Marta': 175}\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "del dict1[\"Anna\"]\n", + "\n", + "print(dict1)\n" ] }, { @@ -87,11 +205,21 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'love': 25, 'conversation': 1, 'every': 6, \"we're\": 1, 'plate': 1, 'sour': 1, 'jukebox': 1, 'now': 11, 'taxi': 1, 'fast': 1, 'bag': 1, 'man': 1, 'push': 3, 'baby': 14, 'going': 1, 'you': 16, \"don't\": 2, 'one': 1, 'mind': 2, 'backseat': 1, 'friends': 1, 'then': 3, 'know': 2, 'take': 1, 'play': 1, 'okay': 1, 'so': 2, 'begin': 1, 'start': 2, 'over': 1, 'body': 17, 'boy': 2, 'just': 1, 'we': 7, 'are': 1, 'girl': 2, 'tell': 1, 'singing': 2, 'drinking': 1, 'put': 3, 'our': 1, 'where': 1, \"i'll\": 1, 'all': 1, \"isn't\": 1, 'make': 1, 'lover': 1, 'get': 1, 'radio': 1, 'give': 1, \"i'm\": 23, 'like': 10, 'can': 1, 'doing': 2, 'with': 22, 'club': 1, 'come': 37, 'it': 1, 'somebody': 2, 'handmade': 2, 'out': 1, 'new': 6, 'room': 3, 'chance': 1, 'follow': 6, 'in': 27, 'may': 2, 'brand': 6, 'that': 2, 'magnet': 3, 'up': 3, 'first': 1, 'and': 23, 'pull': 3, 'of': 6, 'table': 1, 'much': 2, 'last': 3, 'i': 6, 'thrifty': 1, 'grab': 2, 'was': 2, 'driver': 1, 'slow': 1, 'dance': 1, 'the': 18, 'say': 2, 'trust': 1, 'family': 1, 'week': 1, 'date': 1, 'me': 10, 'do': 3, 'waist': 2, 'smell': 3, 'day': 6, 'although': 3, 'your': 21, 'leave': 1, 'want': 2, \"let's\": 2, 'lead': 6, 'at': 1, 'hand': 1, 'how': 1, 'talk': 4, 'not': 2, 'eat': 1, 'falling': 3, 'about': 1, 'story': 1, 'sweet': 1, 'best': 1, 'crazy': 2, 'let': 1, 'too': 5, 'van': 1, 'shots': 1, 'go': 2, 'to': 2, 'a': 8, 'my': 33, 'is': 5, 'place': 1, 'find': 1, 'shape': 6, 'on': 40, 'kiss': 1, 'were': 3, 'night': 3, 'heart': 3, 'for': 3, 'discovering': 6, 'something': 6, 'be': 16, 'bedsheets': 3, 'fill': 2, 'hours': 2, 'stop': 1, 'bar': 1}\n" + ] + } + ], "source": [ - "word_freq = {'love': 25, 'conversation': 1, 'every': 6, \"we're\": 1, 'plate': 1, 'sour': 1, 'jukebox': 1, 'now': 11, 'taxi': 1, 'fast': 1, 'bag': 1, 'man': 1, 'push': 3, 'baby': 14, 'going': 1, 'you': 16, \"don't\": 2, 'one': 1, 'mind': 2, 'backseat': 1, 'friends': 1, 'then': 3, 'know': 2, 'take': 1, 'play': 1, 'okay': 1, 'so': 2, 'begin': 1, 'start': 2, 'over': 1, 'body': 17, 'boy': 2, 'just': 1, 'we': 7, 'are': 1, 'girl': 2, 'tell': 1, 'singing': 2, 'drinking': 1, 'put': 3, 'our': 1, 'where': 1, \"i'll\": 1, 'all': 1, \"isn't\": 1, 'make': 1, 'lover': 1, 'get': 1, 'radio': 1, 'give': 1, \"i'm\": 23, 'like': 10, 'can': 1, 'doing': 2, 'with': 22, 'club': 1, 'come': 37, 'it': 1, 'somebody': 2, 'handmade': 2, 'out': 1, 'new': 6, 'room': 3, 'chance': 1, 'follow': 6, 'in': 27, 'may': 2, 'brand': 6, 'that': 2, 'magnet': 3, 'up': 3, 'first': 1, 'and': 23, 'pull': 3, 'of': 6, 'table': 1, 'much': 2, 'last': 3, 'i': 6, 'thrifty': 1, 'grab': 2, 'was': 2, 'driver': 1, 'slow': 1, 'dance': 1, 'the': 18, 'say': 2, 'trust': 1, 'family': 1, 'week': 1, 'date': 1, 'me': 10, 'do': 3, 'waist': 2, 'smell': 3, 'day': 6, 'although': 3, 'your': 21, 'leave': 1, 'want': 2, \"let's\": 2, 'lead': 6, 'at': 1, 'hand': 1, 'how': 1, 'talk': 4, 'not': 2, 'eat': 1, 'falling': 3, 'about': 1, 'story': 1, 'sweet': 1, 'best': 1, 'crazy': 2, 'let': 1, 'too': 5, 'van': 1, 'shots': 1, 'go': 2, 'to': 2, 'a': 8, 'my': 33, 'is': 5, 'place': 1, 'find': 1, 'shape': 6, 'on': 40, 'kiss': 1, 'were': 3, 'night': 3, 'heart': 3, 'for': 3, 'discovering': 6, 'something': 6, 'be': 16, 'bedsheets': 3, 'fill': 2, 'hours': 2, 'stop': 1, 'bar': 1}" + "word_freq = {'love': 25, 'conversation': 1, 'every': 6, \"we're\": 1, 'plate': 1, 'sour': 1, 'jukebox': 1, 'now': 11, 'taxi': 1, 'fast': 1, 'bag': 1, 'man': 1, 'push': 3, 'baby': 14, 'going': 1, 'you': 16, \"don't\": 2, 'one': 1, 'mind': 2, 'backseat': 1, 'friends': 1, 'then': 3, 'know': 2, 'take': 1, 'play': 1, 'okay': 1, 'so': 2, 'begin': 1, 'start': 2, 'over': 1, 'body': 17, 'boy': 2, 'just': 1, 'we': 7, 'are': 1, 'girl': 2, 'tell': 1, 'singing': 2, 'drinking': 1, 'put': 3, 'our': 1, 'where': 1, \"i'll\": 1, 'all': 1, \"isn't\": 1, 'make': 1, 'lover': 1, 'get': 1, 'radio': 1, 'give': 1, \"i'm\": 23, 'like': 10, 'can': 1, 'doing': 2, 'with': 22, 'club': 1, 'come': 37, 'it': 1, 'somebody': 2, 'handmade': 2, 'out': 1, 'new': 6, 'room': 3, 'chance': 1, 'follow': 6, 'in': 27, 'may': 2, 'brand': 6, 'that': 2, 'magnet': 3, 'up': 3, 'first': 1, 'and': 23, 'pull': 3, 'of': 6, 'table': 1, 'much': 2, 'last': 3, 'i': 6, 'thrifty': 1, 'grab': 2, 'was': 2, 'driver': 1, 'slow': 1, 'dance': 1, 'the': 18, 'say': 2, 'trust': 1, 'family': 1, 'week': 1, 'date': 1, 'me': 10, 'do': 3, 'waist': 2, 'smell': 3, 'day': 6, 'although': 3, 'your': 21, 'leave': 1, 'want': 2, \"let's\": 2, 'lead': 6, 'at': 1, 'hand': 1, 'how': 1, 'talk': 4, 'not': 2, 'eat': 1, 'falling': 3, 'about': 1, 'story': 1, 'sweet': 1, 'best': 1, 'crazy': 2, 'let': 1, 'too': 5, 'van': 1, 'shots': 1, 'go': 2, 'to': 2, 'a': 8, 'my': 33, 'is': 5, 'place': 1, 'find': 1, 'shape': 6, 'on': 40, 'kiss': 1, 'were': 3, 'night': 3, 'heart': 3, 'for': 3, 'discovering': 6, 'something': 6, 'be': 16, 'bedsheets': 3, 'fill': 2, 'hours': 2, 'stop': 1, 'bar': 1}\n", + "\n", + "print(word_freq)" ] }, { @@ -121,11 +249,89 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['love', 'conversation', 'every', \"we're\", 'plate', 'sour', 'jukebox', 'now', 'taxi', 'fast', 'bag', 'man', 'push', 'baby', 'going', 'you', \"don't\", 'one', 'mind', 'backseat', 'friends', 'then', 'know', 'take', 'play', 'okay', 'so', 'begin', 'start', 'over', 'body', 'boy', 'just', 'we', 'are', 'girl', 'tell', 'singing', 'drinking', 'put', 'our', 'where', \"i'll\", 'all', \"isn't\", 'make', 'lover', 'get', 'radio', 'give', \"i'm\", 'like', 'can', 'doing', 'with', 'club', 'come', 'it', 'somebody', 'handmade', 'out', 'new', 'room', 'chance', 'follow', 'in', 'may', 'brand', 'that', 'magnet', 'up', 'first', 'and', 'pull', 'of', 'table', 'much', 'last', 'i', 'thrifty', 'grab', 'was', 'driver', 'slow', 'dance', 'the', 'say', 'trust', 'family', 'week', 'date', 'me', 'do', 'waist', 'smell', 'day', 'although', 'your', 'leave', 'want', \"let's\", 'lead', 'at', 'hand', 'how', 'talk', 'not', 'eat', 'falling', 'about', 'story', 'sweet', 'best', 'crazy', 'let', 'too', 'van', 'shots', 'go', 'to', 'a', 'my', 'is', 'place', 'find', 'shape', 'on', 'kiss', 'were', 'night', 'heart', 'for', 'discovering', 'something', 'be', 'bedsheets', 'fill', 'hours', 'stop', 'bar']\n" + ] + } + ], + "source": [ + "# Your code here\n", + "\n", + "key=[]\n", + "\n", + "for x in word_freq.keys():\n", + " key.append(x)\n", + " \n", + "print(key)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['a', 'about', 'all', 'although', 'and', 'are', 'at', 'baby', 'backseat', 'bag', 'bar', 'be', 'bedsheets', 'begin', 'best', 'body', 'boy', 'brand', 'can', 'chance', 'club', 'come', 'conversation', 'crazy', 'dance', 'date', 'day', 'discovering', 'do', 'doing', \"don't\", 'drinking', 'driver', 'eat', 'every', 'falling', 'family', 'fast', 'fill', 'find', 'first', 'follow', 'for', 'friends', 'get', 'girl', 'give', 'go', 'going', 'grab', 'hand', 'handmade', 'heart', 'hours', 'how', 'i', \"i'll\", \"i'm\", 'in', 'is', \"isn't\", 'it', 'jukebox', 'just', 'kiss', 'know', 'last', 'lead', 'leave', 'let', \"let's\", 'like', 'love', 'lover', 'magnet', 'make', 'man', 'may', 'me', 'mind', 'much', 'my', 'new', 'night', 'not', 'now', 'of', 'okay', 'on', 'one', 'our', 'out', 'over', 'place', 'plate', 'play', 'pull', 'push', 'put', 'radio', 'room', 'say', 'shape', 'shots', 'singing', 'slow', 'smell', 'so', 'somebody', 'something', 'sour', 'start', 'stop', 'story', 'sweet', 'table', 'take', 'talk', 'taxi', 'tell', 'that', 'the', 'then', 'thrifty', 'to', 'too', 'trust', 'up', 'van', 'waist', 'want', 'was', 'we', \"we're\", 'week', 'were', 'where', 'with', 'you', 'your']\n" + ] + } + ], + "source": [ + "key.sort()\n", + "\n", + "print(key) " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[25, 1, 6, 1, 1, 1, 1, 11, 1, 1, 1, 1, 3, 14, 1, 16, 2, 1, 2, 1, 1, 3, 2, 1, 1, 1, 2, 1, 2, 1, 17, 2, 1, 7, 1, 2, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 10, 1, 2, 22, 1, 37, 1, 2, 2, 1, 6, 3, 1, 6, 27, 2, 6, 2, 3, 3, 1, 23, 3, 6, 1, 2, 3, 6, 1, 2, 2, 1, 1, 1, 18, 2, 1, 1, 1, 1, 10, 3, 2, 3, 6, 3, 21, 1, 2, 2, 6, 1, 1, 1, 4, 2, 1, 3, 1, 1, 1, 1, 2, 1, 5, 1, 1, 2, 2, 8, 33, 5, 1, 1, 6, 40, 1, 3, 3, 3, 3, 6, 6, 16, 3, 2, 2, 1, 1]\n" + ] + } + ], + "source": [ + "\n", + "value=[]\n", + "for i in word_freq.values():\n", + " value.append(i)\n", + "print(value)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[(1, 'about'), (1, 'all'), (1, 'are'), (1, 'at'), (1, 'backseat'), (1, 'bag'), (1, 'bar'), (1, 'begin'), (1, 'best'), (1, 'can'), (1, 'chance'), (1, 'club'), (1, 'conversation'), (1, 'dance'), (1, 'date'), (1, 'drinking'), (1, 'driver'), (1, 'eat'), (1, 'family'), (1, 'fast'), (1, 'find'), (1, 'first'), (1, 'friends'), (1, 'get'), (1, 'give'), (1, 'going'), (1, 'hand'), (1, 'how'), (1, \"i'll\"), (1, \"isn't\"), (1, 'it'), (1, 'jukebox'), (1, 'just'), (1, 'kiss'), (1, 'leave'), (1, 'let'), (1, 'lover'), (1, 'make'), (1, 'man'), (1, 'okay'), (1, 'one'), (1, 'our'), (1, 'out'), (1, 'over'), (1, 'place'), (1, 'plate'), (1, 'play'), (1, 'radio'), (1, 'shots'), (1, 'slow'), (1, 'sour'), (1, 'stop'), (1, 'story'), (1, 'sweet'), (1, 'table'), (1, 'take'), (1, 'taxi'), (1, 'tell'), (1, 'thrifty'), (1, 'trust'), (1, 'van'), (1, \"we're\"), (1, 'week'), (1, 'where'), (2, 'boy'), (2, 'crazy'), (2, 'doing'), (2, \"don't\"), (2, 'fill'), (2, 'girl'), (2, 'go'), (2, 'grab'), (2, 'handmade'), (2, 'hours'), (2, 'know'), (2, \"let's\"), (2, 'may'), (2, 'mind'), (2, 'much'), (2, 'not'), (2, 'say'), (2, 'singing'), (2, 'so'), (2, 'somebody'), (2, 'start'), (2, 'that'), (2, 'to'), (2, 'waist'), (2, 'want'), (2, 'was'), (3, 'although'), (3, 'bedsheets'), (3, 'do'), (3, 'falling'), (3, 'for'), (3, 'heart'), (3, 'last'), (3, 'magnet'), (3, 'night'), (3, 'pull'), (3, 'push'), (3, 'put'), (3, 'room'), (3, 'smell'), (3, 'then'), (3, 'up'), (3, 'were'), (4, 'talk'), (5, 'is'), (5, 'too'), (6, 'brand'), (6, 'day'), (6, 'discovering'), (6, 'every'), (6, 'follow'), (6, 'i'), (6, 'lead'), (6, 'new'), (6, 'of'), (6, 'shape'), (6, 'something'), (7, 'we'), (8, 'a'), (10, 'like'), (10, 'me'), (11, 'now'), (14, 'baby'), (16, 'be'), (16, 'you'), (17, 'body'), (18, 'the'), (21, 'your'), (22, 'with'), (23, 'and'), (23, \"i'm\"), (25, 'love'), (27, 'in'), (33, 'my'), (37, 'come'), (40, 'on')]\n" + ] + } + ], "source": [ - "# Your code here\n" + "word_freq2={}\n", + "\n", + "\n", + "word_freq2= sorted((key, value) for (value,key) in word_freq.items())\n", + "\n", + "print(word_freq2)" ] }, { @@ -162,12 +368,53 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 14, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[('conversation', 1), (\"we're\", 1), ('plate', 1), ('sour', 1), ('jukebox', 1), ('taxi', 1), ('fast', 1), ('bag', 1), ('man', 1), ('going', 1), ('one', 1), ('backseat', 1), ('friends', 1), ('take', 1), ('play', 1), ('okay', 1), ('begin', 1), ('over', 1), ('just', 1), ('are', 1), ('tell', 1), ('drinking', 1), ('our', 1), ('where', 1), (\"i'll\", 1), ('all', 1), (\"isn't\", 1), ('make', 1), ('lover', 1), ('get', 1), ('radio', 1), ('give', 1), ('can', 1), ('club', 1), ('it', 1), ('out', 1), ('chance', 1), ('first', 1), ('table', 1), ('thrifty', 1), ('driver', 1), ('slow', 1), ('dance', 1), ('trust', 1), ('family', 1), ('week', 1), ('date', 1), ('leave', 1), ('at', 1), ('hand', 1), ('how', 1), ('eat', 1), ('about', 1), ('story', 1), ('sweet', 1), ('best', 1), ('let', 1), ('van', 1), ('shots', 1), ('place', 1), ('find', 1), ('kiss', 1), ('stop', 1), ('bar', 1), (\"don't\", 2), ('mind', 2), ('know', 2), ('so', 2), ('start', 2), ('boy', 2), ('girl', 2), ('singing', 2), ('doing', 2), ('somebody', 2), ('handmade', 2), ('may', 2), ('that', 2), ('much', 2), ('grab', 2), ('was', 2), ('say', 2), ('waist', 2), ('want', 2), (\"let's\", 2), ('not', 2), ('crazy', 2), ('go', 2), ('to', 2), ('fill', 2), ('hours', 2), ('push', 3), ('then', 3), ('put', 3), ('room', 3), ('magnet', 3), ('up', 3), ('pull', 3), ('last', 3), ('do', 3), ('smell', 3), ('although', 3), ('falling', 3), ('were', 3), ('night', 3), ('heart', 3), ('for', 3), ('bedsheets', 3), ('talk', 4), ('too', 5), ('is', 5), ('every', 6), ('new', 6), ('follow', 6), ('brand', 6), ('of', 6), ('i', 6), ('day', 6), ('lead', 6), ('shape', 6), ('discovering', 6), ('something', 6), ('we', 7), ('a', 8), ('like', 10), ('me', 10), ('now', 11), ('baby', 14), ('you', 16), ('be', 16), ('body', 17), ('the', 18), ('your', 21), ('with', 22), (\"i'm\", 23), ('and', 23), ('love', 25), ('in', 27), ('my', 33), ('come', 37), ('on', 40)]\n" + ] + } + ], + "source": [ + "# Your code here\n", + "\n", + "import operator\n", + "sorted_tups = sorted(word_freq.items(), key=operator.itemgetter(1))\n", + "print(sorted_tups)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'conversation': 1, \"we're\": 1, 'plate': 1, 'sour': 1, 'jukebox': 1, 'taxi': 1, 'fast': 1, 'bag': 1, 'man': 1, 'going': 1, 'one': 1, 'backseat': 1, 'friends': 1, 'take': 1, 'play': 1, 'okay': 1, 'begin': 1, 'over': 1, 'just': 1, 'are': 1, 'tell': 1, 'drinking': 1, 'our': 1, 'where': 1, \"i'll\": 1, 'all': 1, \"isn't\": 1, 'make': 1, 'lover': 1, 'get': 1, 'radio': 1, 'give': 1, 'can': 1, 'club': 1, 'it': 1, 'out': 1, 'chance': 1, 'first': 1, 'table': 1, 'thrifty': 1, 'driver': 1, 'slow': 1, 'dance': 1, 'trust': 1, 'family': 1, 'week': 1, 'date': 1, 'leave': 1, 'at': 1, 'hand': 1, 'how': 1, 'eat': 1, 'about': 1, 'story': 1, 'sweet': 1, 'best': 1, 'let': 1, 'van': 1, 'shots': 1, 'place': 1, 'find': 1, 'kiss': 1, 'stop': 1, 'bar': 1, \"don't\": 2, 'mind': 2, 'know': 2, 'so': 2, 'start': 2, 'boy': 2, 'girl': 2, 'singing': 2, 'doing': 2, 'somebody': 2, 'handmade': 2, 'may': 2, 'that': 2, 'much': 2, 'grab': 2, 'was': 2, 'say': 2, 'waist': 2, 'want': 2, \"let's\": 2, 'not': 2, 'crazy': 2, 'go': 2, 'to': 2, 'fill': 2, 'hours': 2, 'push': 3, 'then': 3, 'put': 3, 'room': 3, 'magnet': 3, 'up': 3, 'pull': 3, 'last': 3, 'do': 3, 'smell': 3, 'although': 3, 'falling': 3, 'were': 3, 'night': 3, 'heart': 3, 'for': 3, 'bedsheets': 3, 'talk': 4, 'too': 5, 'is': 5, 'every': 6, 'new': 6, 'follow': 6, 'brand': 6, 'of': 6, 'i': 6, 'day': 6, 'lead': 6, 'shape': 6, 'discovering': 6, 'something': 6, 'we': 7, 'a': 8, 'like': 10, 'me': 10, 'now': 11, 'baby': 14, 'you': 16, 'be': 16, 'body': 17, 'the': 18, 'your': 21, 'with': 22, \"i'm\": 23, 'and': 23, 'love': 25, 'in': 27, 'my': 33, 'come': 37, 'on': 40}\n" + ] + } + ], "source": [ - "# Your code here\n" + "word_freq2={}\n", + "\n", + "for i in sorted_tups:\n", + " word_freq2[i[0]] = i[1]\n", + "\n", + "print(word_freq2)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -186,7 +433,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.7.6" } }, "nbformat": 4,