From 89ec25ad39eb32f2deb5bdcc3e947e740696af0f Mon Sep 17 00:00:00 2001 From: Ranveer Date: Tue, 26 Nov 2024 19:59:41 -0500 Subject: [PATCH 1/9] Data Type Homework --- 02_activities/homework/01_data_types.ipynb | 241 ++++++++++++++++- Data Type Nov 26.ipynb | 291 +++++++++++++++++++++ 2 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 Data Type Nov 26.ipynb diff --git a/02_activities/homework/01_data_types.ipynb b/02_activities/homework/01_data_types.ipynb index f60123d4b..09bf9a129 100644 --- a/02_activities/homework/01_data_types.ipynb +++ b/02_activities/homework/01_data_types.ipynb @@ -1 +1,240 @@ -{"cells":[{"cell_type":"markdown","metadata":{"id":"jNAI57ELh-I8"},"source":["# Getting Started: Python Fundamentals\n","## Practice Problems"]},{"cell_type":"markdown","metadata":{"id":"5xeRB_0jiT5n"},"source":["### 1. What types are involved in the following expressions? What data type will each expression evaluate to?\n","\n","`8 * 2.5`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":158,"status":"ok","timestamp":1667929890889,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"C6c48sSBOUeE","outputId":"3628ffce-faf6-4d23-daff-5e09edf76541"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"4eICUfHi_Z-K"},"source":["`9 / 2`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":43,"status":"ok","timestamp":1667929891449,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"QVdbNoA2OiQ_","outputId":"ab9f4fac-b1cc-4afc-cc54-10592b92abb1"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"DhrJoWbj_cNe"},"source":["`9 // -2`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":39,"status":"ok","timestamp":1667929891450,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"cSsGq3r0Opx6","outputId":"13df11ef-d136-4a42-884e-be1e369aae52"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"lW4UnVfw_eYy"},"source":["`1.5 * 2 >= 7 - 3`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":34,"status":"ok","timestamp":1667929891452,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"54N6gcNPOylS","outputId":"938208fc-c4c3-4e58-dd18-b50d3acc84d8"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"5T-ytiTw-KvJ"},"source":["### 2. In which order will the expressions be evaluated.\n","\n","`6 * 3 + 7 * 4`\n","\n","\n","
\n"," Answer\n","\n"," `*` > `*` > `+` \n","
\n","\n","\n","`5 - 2 * 3 ** 4`\n","\n","
\n"," Answer\n","\n"," `**` > `*` > `-`\n","
\n","\n","`(5 - 2) * 3 ** 4`\n","\n","
\n"," Answer\n","\n"," `(-)` > `**` > `*` \n","
\n","\n","`5 + 2 >= 3 * 4`\n","\n","
\n"," Answer\n","\n"," `*` > `+` > `>=`\n","
"]}],"metadata":{"colab":{"authorship_tag":"ABX9TyMhUBNX+UP2C+YDtVSxQKBK","collapsed_sections":[],"provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0} +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "jNAI57ELh-I8" + }, + "source": [ + "# Getting Started: Python Fundamentals\n", + "## Practice Problems" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5xeRB_0jiT5n" + }, + "source": [ + "### 1. What types are involved in the following expressions? What data type will each expression evaluate to?\n", + "\n", + "`8 * 2.5`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 158, + "status": "ok", + "timestamp": 1667929890889, + "user": { + "displayName": "Kaylie Lau", + "userId": "01284785813595846851" + }, + "user_tz": 300 + }, + "id": "C6c48sSBOUeE", + "outputId": "3628ffce-faf6-4d23-daff-5e09edf76541" + }, + "outputs": [], + "source": [ + "# 8 is an integer\n", + "# 2.5 is float\n", + "# float\n", + "# 20.0" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4eICUfHi_Z-K" + }, + "source": [ + "`9 / 2`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 43, + "status": "ok", + "timestamp": 1667929891449, + "user": { + "displayName": "Kaylie Lau", + "userId": "01284785813595846851" + }, + "user_tz": 300 + }, + "id": "QVdbNoA2OiQ_", + "outputId": "ab9f4fac-b1cc-4afc-cc54-10592b92abb1" + }, + "outputs": [], + "source": [ + "# 9 is an integer\n", + "# 2 is an integer\n", + "# / is the division and gives results as float data type\n", + "# 4.5" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "DhrJoWbj_cNe" + }, + "source": [ + "`9 // -2`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 39, + "status": "ok", + "timestamp": 1667929891450, + "user": { + "displayName": "Kaylie Lau", + "userId": "01284785813595846851" + }, + "user_tz": 300 + }, + "id": "cSsGq3r0Opx6", + "outputId": "13df11ef-d136-4a42-884e-be1e369aae52" + }, + "outputs": [], + "source": [ + "# 9 is an integer\n", + "# // is the floor division\n", + "# -2 is an integer\n", + "# the result will be an integer rounded down\n", + "# -5" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "lW4UnVfw_eYy" + }, + "source": [ + "`1.5 * 2 >= 7 - 3`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 34, + "status": "ok", + "timestamp": 1667929891452, + "user": { + "displayName": "Kaylie Lau", + "userId": "01284785813595846851" + }, + "user_tz": 300 + }, + "id": "54N6gcNPOylS", + "outputId": "938208fc-c4c3-4e58-dd18-b50d3acc84d8" + }, + "outputs": [], + "source": [ + "# 1.5 is float\n", + "# * is multiplication\n", + "# 2, 7, 3 are integers\n", + "# >= is greater than equal to\n", + "# - substraction\n", + "# result will be Boolean (FALSE)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5T-ytiTw-KvJ" + }, + "source": [ + "### 2. In which order will the expressions be evaluated.\n", + "\n", + "`6 * 3 + 7 * 4`\n", + "\n", + "\n", + "
\n", + " Answer\n", + "\n", + " `*` > `*` > `+` \n", + "
\n", + "\n", + "\n", + "`5 - 2 * 3 ** 4`\n", + "\n", + "
\n", + " Answer\n", + "\n", + " `**` > `*` > `-`\n", + "
\n", + "\n", + "`(5 - 2) * 3 ** 4`\n", + "\n", + "
\n", + " Answer\n", + "\n", + " `(-)` > `**` > `*` \n", + "
\n", + "\n", + "`5 + 2 >= 3 * 4`\n", + "\n", + "
\n", + " Answer\n", + "\n", + " `*` > `+` > `>=`\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 6 * 3, 7 * 4, 18 + 28 \n", + "# = 46\n", + "# 3 ** 4 (81), 2 * 81 (162), 5 - 162 \n", + "# = -157\n", + "# (5-2), 3 ** 4, 3 * 81 \n", + "# = 243\n", + "# 3 * 4, 5 + 2 \n", + "# FALSE" + ] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyMhUBNX+UP2C+YDtVSxQKBK", + "collapsed_sections": [], + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Data Type Nov 26.ipynb b/Data Type Nov 26.ipynb new file mode 100644 index 000000000..3863f85b5 --- /dev/null +++ b/Data Type Nov 26.ipynb @@ -0,0 +1,291 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# November 26th, 2024" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hello world\n" + ] + } + ], + "source": [ + "print(\"hello world\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "4+2" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-5" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "9 // -2" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1.5 * 2 >= 7 - 3" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "46" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "6 * 3 + 7 * 4" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-157" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "5 - 2 * 3 ** 4" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "243" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(5-2)* 3 ** 4" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "9//5\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1.8" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "9/5" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "def c_to_f(degrees_c):\n", + " degrees_f = (9/5) * degrees_c + 32\n", + " return degrees_f" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "50.0" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c_to_f(10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dsi_participant", + "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.9.15" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 75188fce415a2491ccc658e8b371354ae16268ed Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 16:43:04 -0500 Subject: [PATCH 2/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 108 ++++++++++++++++--- 1 file changed, 95 insertions(+), 13 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index cbfd8c709..8d4e0753a 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -58,30 +58,73 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# This is a function, which we will learn more about next week. For testing purposes, we will write our code in the function\n", "def anagram_checker(word_a, word_b):\n", - " # Your code here\n", + "\n", + " # using list function to create a list of each letter in the word_a & word_b\n", + " # using string.lower() method to change the string to lowercase.\n", + " # sort function will sort the alphabets in ascending order which is default\n", + " alphabet_list_a = list(word_a.lower())\n", + " alphabet_list_a.sort()\n", + " alphabet_list_b = list(word_b.lower())\n", + " alphabet_list_b.sort()\n", + "\n", + " # == is for comparing two lists. It compares two lists elementwise. \n", + " return(alphabet_list_a == alphabet_list_b)\n", "\n", "# Run your code to check using the words below:\n", - "anagram_checker(\"Silent\", \"listen\")" + "anagram_checker(\"Silent\", \"listen\")\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -99,10 +142,38 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", - " # Modify your existing code here\n", + "\n", + "# I'll use if else to set the conditions about the case sensitivity\n", + " if is_case_sensitive == False:\n", + "\n", + " alphabet_list_a = list(word_a.lower())\n", + " alphabet_list_a.sort()\n", + " alphabet_list_b = list(word_b.lower())\n", + " alphabet_list_b.sort()\n", + "\n", + " return(alphabet_list_a == alphabet_list_b)\n", + "\n", + " else:\n", + " alphabet_list_a = list(word_a)\n", + " alphabet_list_a.sort()\n", + " alphabet_list_b = list(word_b)\n", + " alphabet_list_b.sort()\n", + "\n", + " return(alphabet_list_a == alphabet_list_b)\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -110,9 +181,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -130,7 +212,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "dsi_participant", "language": "python", "name": "python3" }, @@ -144,7 +226,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.9.15" } }, "nbformat": 4, From 32c2b6bf1f0c1a54f0bb2a986e0f25d772a8fd0a Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 17:04:33 -0500 Subject: [PATCH 3/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 8d4e0753a..52cdc5395 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -65,7 +65,7 @@ "True" ] }, - "execution_count": 17, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -76,7 +76,7 @@ "\n", " # using list function to create a list of each letter in the word_a & word_b\n", " # using string.lower() method to change the string to lowercase.\n", - " # sort function will sort the alphabets in ascending order which is default\n", + " # sort function will sort the alphabets in ascending order which is default. It modifies the elements in a list and doesn't return the sorted list.\n", " alphabet_list_a = list(word_a.lower())\n", " alphabet_list_a.sort()\n", " alphabet_list_b = list(word_b.lower())\n", @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -100,7 +100,7 @@ "False" ] }, - "execution_count": 18, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -111,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -120,7 +120,7 @@ "True" ] }, - "execution_count": 19, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -140,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -149,7 +149,7 @@ "True" ] }, - "execution_count": 24, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -157,9 +157,9 @@ "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", "\n", - "# I'll use if else to set the conditions about the case sensitivity\n", + "# Using if else to set the conditions about the case sensitivity\n", " if is_case_sensitive == False:\n", - "\n", + " \n", " alphabet_list_a = list(word_a.lower())\n", " alphabet_list_a.sort()\n", " alphabet_list_b = list(word_b.lower())\n", @@ -181,7 +181,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -190,7 +190,7 @@ "False" ] }, - "execution_count": 25, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } From 330944cbaeec649d938ee697f38a16f75eb3cccd Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 17:29:20 -0500 Subject: [PATCH 4/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 119 +++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 52cdc5395..62d2b9529 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -129,6 +129,50 @@ "anagram_checker(\"night\", \"Thing\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Solution# 2\n", + "Using for loop" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def anagram_checker(word_a, word_b):\n", + " \n", + " alphabet_list_a = []\n", + " word_a = word_a.lower()\n", + " for i in range(0, len(word_a)):\n", + " alphabet_list_a.append(word_a[i])\n", + "\n", + " alphabet_list_b = []\n", + " word_a = word_a.lower()\n", + " for i in range(0, len(word_b)):\n", + " alphabet_list_b.append(word_b[i])\n", + "\n", + " # == is for comparing two lists. It compares two lists elementwise. \n", + " return(sorted(alphabet_list_a) == sorted(alphabet_list_b))\n", + "\n", + "# Run your code to check using the words below:\n", + "anagram_checker(\"Silent\", \"listen\")" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -199,6 +243,81 @@ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Modifying Solution# 2" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def anagram_checker(word_a, word_b, is_case_sensitive):\n", + "\n", + " if is_case_sensitive == False:\n", + "\n", + " alphabet_list_a = []\n", + " word_a = word_a.lower()\n", + " for i in range(0, len(word_a)):\n", + " alphabet_list_a.append(word_a[i])\n", + "\n", + " alphabet_list_b = []\n", + " word_a = word_a.lower()\n", + " for i in range(0, len(word_b)):\n", + " alphabet_list_b.append(word_b[i])\n", + "\n", + " return(sorted(alphabet_list_a) == sorted(alphabet_list_b))\n", + "\n", + " else:\n", + " alphabet_list_a = []\n", + " for i in range(0, len(word_a)):\n", + " alphabet_list_a.append(word_a[i])\n", + "\n", + " alphabet_list_b = []\n", + " for i in range(0, len(word_b)):\n", + " alphabet_list_b.append(word_b[i])\n", + "\n", + " return(sorted(alphabet_list_a) == sorted(alphabet_list_b))\n", + "\n", + "# Run your code to check using the words below:\n", + "anagram_checker(\"Silent\", \"listen\", False) # True" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Listen\", True) # False" + ] + }, { "cell_type": "markdown", "metadata": {}, From 1fc164df623ad2cb1da0eb099589cfa4cbb27b0a Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 17:31:59 -0500 Subject: [PATCH 5/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 62d2b9529..a7bee0a82 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -158,11 +158,13 @@ " \n", " alphabet_list_a = []\n", " word_a = word_a.lower()\n", + "\n", " for i in range(0, len(word_a)):\n", " alphabet_list_a.append(word_a[i])\n", "\n", " alphabet_list_b = []\n", " word_a = word_a.lower()\n", + " \n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", "\n", @@ -184,7 +186,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -212,6 +214,7 @@ " return(alphabet_list_a == alphabet_list_b)\n", "\n", " else:\n", + " \n", " alphabet_list_a = list(word_a)\n", " alphabet_list_a.sort()\n", " alphabet_list_b = list(word_b)\n", @@ -252,7 +255,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -273,11 +276,13 @@ "\n", " alphabet_list_a = []\n", " word_a = word_a.lower()\n", + "\n", " for i in range(0, len(word_a)):\n", " alphabet_list_a.append(word_a[i])\n", "\n", " alphabet_list_b = []\n", " word_a = word_a.lower()\n", + "\n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", "\n", @@ -285,10 +290,12 @@ "\n", " else:\n", " alphabet_list_a = []\n", + "\n", " for i in range(0, len(word_a)):\n", " alphabet_list_a.append(word_a[i])\n", "\n", " alphabet_list_b = []\n", + " \n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", "\n", From bbb3461f5caf90331e017cab44c8be9ad0168908 Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 17:42:05 -0500 Subject: [PATCH 6/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index a7bee0a82..804559dfa 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -156,9 +156,11 @@ "source": [ "def anagram_checker(word_a, word_b):\n", " \n", + " # Creatinig an empty list and changing word_a to lowercase\n", " alphabet_list_a = []\n", " word_a = word_a.lower()\n", "\n", + "# for loop runs from 0 to 5 and adds each letter for the respective index to the updated list in the previous iteration. \n", " for i in range(0, len(word_a)):\n", " alphabet_list_a.append(word_a[i])\n", "\n", @@ -282,20 +284,19 @@ "\n", " alphabet_list_b = []\n", " word_a = word_a.lower()\n", - "\n", + " \n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", "\n", " return(sorted(alphabet_list_a) == sorted(alphabet_list_b))\n", "\n", " else:\n", - " alphabet_list_a = []\n", "\n", + " alphabet_list_a = []\n", " for i in range(0, len(word_a)):\n", " alphabet_list_a.append(word_a[i])\n", "\n", " alphabet_list_b = []\n", - " \n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", "\n", From 8e17c59962722690f5d7e6e472a0563df358f2ba Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 17:50:00 -0500 Subject: [PATCH 7/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 804559dfa..c48fd76a3 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -160,7 +160,9 @@ " alphabet_list_a = []\n", " word_a = word_a.lower()\n", "\n", - "# for loop runs from 0 to 5 and adds each letter for the respective index to the updated list in the previous iteration. \n", + "# for loop goes through each index of the string (from 0 to (length - 1)) \n", + "# 1. It retrieves the letter at the current index\n", + "# 2. Adds the letter to the list. For each iteration, it keeps adding the letters to the updated list from the previous iteration. \n", " for i in range(0, len(word_a)):\n", " alphabet_list_a.append(word_a[i])\n", "\n", From b06598739f4ff99cb027ed90a2935d5f0004b940 Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 17:55:22 -0500 Subject: [PATCH 8/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index c48fd76a3..1c6e6105c 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -65,7 +65,7 @@ "True" ] }, - "execution_count": 26, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -148,7 +148,7 @@ "True" ] }, - "execution_count": 31, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } From b58150e1d8be1cc281692b34379df3f2cb8434d9 Mon Sep 17 00:00:00 2001 From: Ranveer Date: Thu, 28 Nov 2024 18:00:10 -0500 Subject: [PATCH 9/9] Assignment_1 Submission --- 02_activities/assignments/assignment_1.ipynb | 76 +++++++++++++++----- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 1c6e6105c..977dbe1c5 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 56, "metadata": {}, "outputs": [ { @@ -65,7 +65,7 @@ "True" ] }, - "execution_count": 35, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 57, "metadata": {}, "outputs": [ { @@ -100,7 +100,7 @@ "False" ] }, - "execution_count": 27, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -111,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 58, "metadata": {}, "outputs": [ { @@ -120,7 +120,7 @@ "True" ] }, - "execution_count": 28, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 62, "metadata": {}, "outputs": [ { @@ -148,7 +148,7 @@ "True" ] }, - "execution_count": 42, + "execution_count": 62, "metadata": {}, "output_type": "execute_result" } @@ -167,7 +167,7 @@ " alphabet_list_a.append(word_a[i])\n", "\n", " alphabet_list_b = []\n", - " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", " \n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", @@ -179,6 +179,46 @@ "anagram_checker(\"Silent\", \"listen\")" ] }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Night\")" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"night\", \"Thing\")" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -190,7 +230,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 65, "metadata": {}, "outputs": [ { @@ -199,7 +239,7 @@ "True" ] }, - "execution_count": 29, + "execution_count": 65, "metadata": {}, "output_type": "execute_result" } @@ -232,7 +272,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 66, "metadata": {}, "outputs": [ { @@ -241,7 +281,7 @@ "False" ] }, - "execution_count": 30, + "execution_count": 66, "metadata": {}, "output_type": "execute_result" } @@ -259,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 67, "metadata": {}, "outputs": [ { @@ -268,7 +308,7 @@ "True" ] }, - "execution_count": 33, + "execution_count": 67, "metadata": {}, "output_type": "execute_result" } @@ -285,7 +325,7 @@ " alphabet_list_a.append(word_a[i])\n", "\n", " alphabet_list_b = []\n", - " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", " \n", " for i in range(0, len(word_b)):\n", " alphabet_list_b.append(word_b[i])\n", @@ -310,7 +350,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 68, "metadata": {}, "outputs": [ { @@ -319,7 +359,7 @@ "False" ] }, - "execution_count": 34, + "execution_count": 68, "metadata": {}, "output_type": "execute_result" }