diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 2dca19d0b..eac80bf8f 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -54,36 +54,128 @@ "```" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Explaining my reasoning\n", + "\n", + "Anagrams are word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once.\n", + "\n", + "To identify whether two words are anagrams, I *first* make sure all letters within words are lowercase and I remove any spaces. *Second*, I sort the letters in alphabetical order. If two words are anagrams, when sorted they should be identical." + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 28, + "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", - " # Your code here\n", + " \"\"\"\n", + " The anagram_checker will check whether two words specified by the user are anagrams. \\nThe words dont need to be case sensitive.\\nThe function will return true if the words are anagrams.\n", + " \"\"\"\n", + " \n", + " word_a_edited = word_a.lower().replace(\" \", \"\")\n", + " word_b_edited = word_b.lower().replace(\" \", \"\")\n", + " \n", + " return sorted(word_a_edited) == sorted(word_b_edited)\n", + " \n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Testing the logic of my function\n", + "\n", + "Here I use the same logic as in the function above to test whether it works using two makde up words. I can confirm the function is correct based on this check" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Help on function anagram_checker in module __main__:\n", + "\n", + "anagram_checker(word_a, word_b)\n", + " The anagram_checker will check whether two words specified by the user are anagrams. \n", + " The words dont need to be case sensitive.\n", + " The function will return true if the words are anagrams.\n", + "\n" + ] + } + ], "source": [ - "anagram_checker(\"Silent\", \"Night\")" + "word_a_test=\"Ocean\"\n", + "word_b_test=\"Water\"\n", + "\n", + "word_a_edited_test = word_a_test.lower().replace(\" \", \"\")\n", + "word_b_edited_test = word_b_test.lower().replace(\" \", \"\")\n", + "\n", + "sorted(word_a_edited_test) == sorted(word_b_edited_test)\n", + "\n", + "help(anagram_checker) # Testing the documentation of the function\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "anagram_checker(\"night\", \"Thing\")" + "anagram_checker(\"Silent\", \"Night\") # Confimed correct" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"night\", \"Thing\") # Confimed correct" ] }, { @@ -97,12 +189,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 35, + "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==True: return sorted(word_a) == sorted(word_b)\n", + "\n", + " else : word_a_edited = word_a.lower().replace(\" \", \"\")\n", + " word_b_edited = word_b.lower().replace(\" \", \"\")\n", + " return sorted(word_a_edited) == sorted(word_b_edited)\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -112,16 +219,40 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "anagram_checker(\"Silent\", \"listen\", True) # False" + "anagram_checker(\"Silent\", \"listen\", True) # False\n", + "\n", + "# I am confused as to why the parameter is True. Clearly \"Silent\" and \"listen\" are not case sensitive." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -139,7 +270,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "python-env", "language": "python", "name": "python3" }, @@ -153,7 +284,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.11.15" } }, "nbformat": 4, diff --git a/04.14.2026 class session.ipynb b/04.14.2026 class session.ipynb new file mode 100644 index 000000000..cb9888ebf --- /dev/null +++ b/04.14.2026 class session.ipynb @@ -0,0 +1,261 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "1bcdd6bd", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "markdown", + "id": "dc556d60", + "metadata": {}, + "source": [ + "This code adds **one plus one**" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "2e431aa5", + "metadata": {}, + "outputs": [], + "source": [ + "name=\"Luissa\"\n", + "age=31\n", + "favourite_number=0" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "b474945f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Luissa'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "name" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a5f7edcd", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "31" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "age\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "40c6185d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "favourite_number" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "dab6e561", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('Luissa', 31, 0)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "name, age, favourite_number\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "96c9d5ed", + "metadata": {}, + "outputs": [], + "source": [ + "age += 10\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "61135c07", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "41" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "age\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c2011e67", + "metadata": {}, + "outputs": [], + "source": [ + "def f_to_c(f_deg):\n", + " return(f_deg-32)*5/9 #Conversion formula\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "138bcc6e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.0" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f_to_c(32)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "1b1eac2e", + "metadata": {}, + "outputs": [], + "source": [ + "def luissa_function(proportion):\n", + " \"\"\"\n", + " This function converts proportions into percents\n", + " User needs the proportion parameter as a float variable\n", + " \"\"\"\n", + " return proportion*100" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "9e31b820", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.45848" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "luissa_function(0.0045848)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "0dbfd5d0", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Help on function luissa_function in module __main__:\n", + "\n", + "luissa_function(proportion)\n", + " This function converts proportions into percents\n", + " User needs the proportion parameter as a float variable\n", + "\n" + ] + } + ], + "source": [ + "help(luissa_function)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "python-env", + "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.11.15" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}