From cd05cf78f33aaa8ecd0391808421562825935caf Mon Sep 17 00:00:00 2001 From: Diana Date: Sat, 18 Oct 2025 13:19:10 -0400 Subject: [PATCH] completing assignment 1 --- 01_materials/slides/01_data_types.ipynb | 29 +++++- 02_activities/assignments/assignment_1.ipynb | 98 +++++++++++++++++--- 2 files changed, 112 insertions(+), 15 deletions(-) diff --git a/01_materials/slides/01_data_types.ipynb b/01_materials/slides/01_data_types.ipynb index 481169455..26e15c606 100644 --- a/01_materials/slides/01_data_types.ipynb +++ b/01_materials/slides/01_data_types.ipynb @@ -304,10 +304,33 @@ "outputs": [], "source": [ "degrees_celsius = 0\n", - "degrees_celsius += 10\n", + "degrees_celsius += 10 #same as degrees_celsius = degrees_celsius + 10\n", "degrees_celsius" ] }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2024" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "year = 2025\n", + "year -=1\n", + "year\n", + "#the output should be 2024" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -318,7 +341,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "python-env", "language": "python", "name": "python3" }, @@ -332,7 +355,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.11.13" } }, "nbformat": 4, diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index bee48d5a0..cf8abc6d4 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,12 +56,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# For testing purposes, we will write our code in the function\n", "def anagram_checker(word_a, word_b):\n", + " '''converts characters of both strings into lower case, then sorts them alphabetically, finally compares if they are the same. If same = TRUE, if different = FALSE'''\n", + " lowa = word_a.lower()\n", + " lowb = word_b.lower()\n", + " sorteda = sorted(lowa)\n", + " sortedb = sorted(lowb)\n", + "\n", + " return sorteda == sortedb\n", " # Your code here\n", "\n", "# Run your code to check using the words below:\n", @@ -70,18 +88,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -97,12 +137,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " # Modify your existing code here\n", + " '''if is_case_sensitive = False (default),converts characters of both strings into lower case, then sorts them alphabetically, finally compares if they are the same. If same = TRUE, if different = FALSE.\n", + " if is_case_sensitive = True, do not convert into lower case, proceed as above'''\n", + " if is_case_sensitive == False:\n", + " lowa = word_a.lower()\n", + " lowb = word_b.lower()\n", + " sorteda = sorted(lowa)\n", + " sortedb = sorted(lowb)\n", + " return sorteda == sortedb\n", + " else: \n", + " sorteda = sorted(word_a)\n", + " sortedb = sorted(word_b)\n", + " return sorteda == sortedb\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -110,9 +173,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -130,7 +204,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "python-env", "language": "python", "name": "python3" }, @@ -144,7 +218,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.11.13" } }, "nbformat": 4,