From 01ad6112afd92db4e21236f5b448c4cc1d3dd66b Mon Sep 17 00:00:00 2001 From: javierdastas <43615461+javierdastas@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:19:19 -0400 Subject: [PATCH 1/2] Deliver lab-list-comprehension-en Deliver lab-list-comprehension-en Week 1, Day 1, Lab 2 --- your-code/main.ipynb | 118 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 95 insertions(+), 23 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index d584552..c4a143d 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -27,11 +27,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n" + ] + } + ], "source": [ - "#your code here" + "consecutive_integers = [num for num in range(1, 51)] # Generate the list of consecutive integers from 1 to 50\n", + "\n", + "print(consecutive_integers)" ] }, { @@ -43,11 +53,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[2, 20, 22, 24, 26, 28]\n" + ] + } + ], "source": [ - "#your code here" + "even_numbers = [num for num in range(1, 51) if num % 2 == 0 if str(num).startswith('2')] # Generate the list of consecutive integers from 1 to 50\n", + "\n", + "print(even_numbers)" ] }, { @@ -59,7 +79,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -77,11 +97,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.84062117, 0.48006452, 0.7876326, 0.77109654, 0.44409793, 0.09014516, 0.81835917, 0.87645456, 0.7066597, 0.09610873, 0.41247947, 0.57433389, 0.29960807, 0.42315023, 0.34452557, 0.4751035, 0.17003563, 0.46843998, 0.92796258, 0.69814654, 0.41290051, 0.19561071, 0.16284783, 0.97016248, 0.71725408, 0.87702738, 0.31244595, 0.76615487, 0.20754036, 0.57871812, 0.07214068, 0.40356048, 0.12149553, 0.53222417, 0.9976855, 0.12536346, 0.80930099, 0.50962849, 0.94555126, 0.33364763]\n" + ] + } + ], "source": [ - "#your code here" + "new_list = [c for b in a for c in b]\n", + "\n", + "print(new_list)" ] }, { @@ -93,11 +123,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.84062117, 0.7876326, 0.77109654, 0.81835917, 0.87645456, 0.7066597, 0.57433389, 0.92796258, 0.69814654, 0.97016248, 0.71725408, 0.87702738, 0.76615487, 0.57871812, 0.53222417, 0.9976855, 0.80930099, 0.50962849, 0.94555126]\n", + "\n", + "19\n" + ] + } + ], "source": [ - "#your code here" + "new_list = [c for b in a for c in b if c >= 0.5]\n", + "\n", + "print(new_list)\n", + "print()\n", + "print(len(new_list))" ] }, { @@ -109,7 +153,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -131,11 +175,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.55867166, 0.06210792, 0.08147297, 0.82579068, 0.91512478, 0.06833034, 0.05440634, 0.65857693, 0.30296619, 0.06769833, 0.96031863, 0.51293743, 0.09143215, 0.71893382, 0.45850679, 0.58256464, 0.59005654, 0.56266457, 0.71600294, 0.87392666, 0.11434044, 0.8694668, 0.65669313, 0.10708681, 0.07529684, 0.46470767, 0.47984544, 0.65368638, 0.14901286, 0.23760688]\n", + "\n", + "30\n" + ] + } + ], "source": [ - "#your code here" + "new_list = [e for c in b for d in c for e in d]\n", + "\n", + "print(new_list)\n", + "print()\n", + "print(len(new_list))" ] }, { @@ -147,11 +205,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.08147297, 0.06833034, 0.30296619, 0.51293743, 0.45850679, 0.56266457, 0.11434044, 0.10708681, 0.47984544, 0.23760688]\n", + "\n", + "10\n" + ] + } + ], "source": [ - "#your code here" + "new_list = [e for c in b for d in c for e in d if e == d[-1]]\n", + "\n", + "print(new_list)\n", + "print()\n", + "print(len(new_list))" ] }, { @@ -205,7 +277,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.7" }, "vscode": { "interpreter": { @@ -214,5 +286,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } From 312dfbcb31bccbb3a1f0d2688ca92550fc9a64ce Mon Sep 17 00:00:00 2001 From: javierdastas <43615461+javierdastas@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:53:26 -0400 Subject: [PATCH 2/2] Update the challenge 2 --- your-code/main.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index c4a143d..2bfb6f0 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -15,7 +15,7 @@ "metadata": {}, "outputs": [], "source": [ - "import os" + "import os # import os library" ] }, {