diff --git a/your-code/main.ipynb b/your-code/main.ipynb index de27676..694b85d 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -25,11 +25,52 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['PLAY', 'FILLING', 'BAR', 'THEATRE', 'EASYGOING', 'DATE', 'LEAD', 'THAT', 'STORY', 'ISLAND']\n" + ] + } + ], + "source": [ + "new_words=[]\n", + "for i in range(len(words)):\n", + " item=words[i].upper()\n", + " new_words.append(item)\n", + "print(new_words)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "PLAY\n", + "FILLING\n", + "BAR\n", + "THEATRE\n", + "EASYGOING\n", + "DATE\n", + "LEAD\n", + "THAT\n", + "STORY\n", + "ISLAND\n" + ] + } + ], "source": [ - "# your code here" + "for i in range(len(words)):\n", + " item=words[i].upper()\n", + " print(item)" ] }, { @@ -41,11 +82,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['filling', 'theatre', 'easygoing', 'story', 'island']\n" + ] + } + ], "source": [ - "# your code here" + "new_list=[]\n", + "\n", + "for i in words:\n", + " if len(i) > 4:\n", + " new_list.append(i)\n", + "\n", + "print(new_list)" ] }, { @@ -57,11 +112,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['theatre']\n" + ] + } + ], "source": [ - "# your code here" + "new_list2=[]\n", + "\n", + "for i in words:\n", + " if i.startswith(\"t\"):\n", + " new_list2.append(i)\n", + " break\n", + "print(new_list2)" ] }, { @@ -80,11 +149,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n" + ] + } + ], "source": [ - "# your code here" + "num=[]\n", + "\n", + "for i in range(1,11):\n", + " num.append(i**2)\n", + "print(num)" ] }, { @@ -96,11 +177,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 9, 25, 49, 81]\n" + ] + } + ], "source": [ - "# your code here" + "odd_num=[]\n", + "for i in range(1, 11):\n", + " if i%2==1:\n", + " odd_num.append(i**2)\n", + "\n", + "print(odd_num)" ] }, { @@ -112,11 +206,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 81, 289, 625, 1089, 1681, 2401, 3249, 4225, 5329, 6561, 7921, 9409, 11025, 12769, 14641, 16641, 18769, 21025, 23409, 25921, 28561, 31329, 34225, 37249, 40401, 43681, 47089, 50625, 54289, 58081, 62001, 66049, 70225, 74529, 78961, 83521, 88209, 93025, 97969, 103041, 108241, 113569, 119025, 124609, 130321, 136161, 142129, 148225, 154449, 160801, 167281, 173889, 180625, 187489, 194481, 201601, 208849, 216225, 223729, 231361, 239121, 247009, 255025, 263169, 271441, 279841, 288369, 297025, 305809, 314721, 323761, 332929, 342225, 351649, 361201, 370881, 380689, 390625, 400689, 410881, 421201, 431649, 442225, 452929, 463761, 474721, 485809, 497025, 508369, 519841, 531441, 543169, 555025, 567009, 579121, 591361, 603729, 616225, 628849, 641601, 654481, 667489, 680625, 693889, 707281, 720801, 734449, 748225, 762129, 776161, 790321, 804609, 819025, 833569, 848241, 863041, 877969, 893025, 908209, 923521, 938961, 954529, 970225, 986049]\n" + ] + } + ], "source": [ - "# your code here" + "multiple_num=[]\n", + "\n", + "for i in range(1, 1001, 8):\n", + " multiple_num.append(i**2)\n", + "\n", + "print(multiple_num)" ] }, { @@ -128,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -170,11 +277,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "len(people)" ] }, { @@ -186,11 +304,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], "source": [ - "# your code here" + "count=0\n", + "for i in people:\n", + " if i[\"n_kids\"] > 0:\n", + " count += 1\n", + "print(count)\n", + "\n" ] }, { @@ -202,11 +333,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], "source": [ - "# your code here" + "count=0\n", + "for i in people:\n", + " if i[\"n_kids\"] > 0:\n", + " count += i[\"n_kids\"]\n", + "print(count)" ] }, { @@ -218,17 +361,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[{'name': 'Juan', 'age': 34, 'n_kids': 2}, {'name': 'Pepe', 'age': 27, 'n_kids': 0}, {'name': 'Sonia', 'age': 41, 'n_kids': 2}, {'name': 'LucĂ­a', 'age': 22, 'n_kids': 3}, {'name': 'Leo', 'age': 55, 'n_kids': 5}]\n" + ] + } + ], "source": [ - "# your code here" + "people_nextyear=[]\n", + "\n", + "for i in people:\n", + " new_person=i.copy()\n", + " if new_person['name'].endswith(\"a\"):\n", + " new_person['n_kids'] += 1\n", + " people_nextyear.append(new_person)\n", + "\n", + "print(people_nextyear)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -242,7 +401,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" }, "toc": { "base_numbering": 1, @@ -285,11 +444,6 @@ "_Feature" ], "window_display": false - }, - "vscode": { - "interpreter": { - "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" - } } }, "nbformat": 4,