diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 156d0408e..34220edf4 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,13 +56,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 4, + "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", + " if (type(word_a) == str) and (type(word_b) == str): # check for valid arguements\n", + " sorted_xters1 = sorted(word_a.lower()) # sort lower case of word_a\n", + " sorted_xters2 = sorted(word_b.lower()) # sort lower case of word_b\n", + " checker = sorted_xters1 == sorted_xters2 # check for equality in 2 strings\n", + " return checker\n", + " else:\n", + " print('Please run with valid arguements')\n", + "\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -70,18 +89,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -97,12 +138,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " # Modify your existing code here\n", + " if (type(word_a) == str) and (type(word_b) == str) and (type(is_case_sensitive) == bool) : # check for valid arguements\n", + " if is_case_sensitive :\n", + " sorted_xters1 = sorted(word_a) # sort string1\n", + " sorted_xters2 = sorted(word_b) # sort string2\n", + " checker = sorted_xters1 == sorted_xters2 # check for equality in 2 strings\n", + " else:\n", + " sorted_xters1 = sorted(word_a.lower()) # sort lower case of string1\n", + " sorted_xters2 = sorted(word_b.lower()) # sort lower case of string2\n", + " checker = sorted_xters1 == sorted_xters2 # check for equality in 2 strings\n", + " return checker #retun true or false\n", + " else:\n", + " print(\"Please enter valid arguements\")\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -110,9 +174,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -126,11 +201,28 @@ "|Code Execution|All code cells execute without errors.|Any code cell produces an error upon execution.|\n", "|Code Quality|Code is well-organized, concise, and includes necessary comments for clarity. E.g. Great use of variable names.|Code is unorganized, verbose, or lacks necessary comments. E.g. Single character variable names outside of loops.|" ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Please enter valid arguements\n" + ] + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Listen\",1)" + ] } ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "dsi_participant", "language": "python", "name": "python3" }, @@ -144,7 +236,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.9.19" } }, "nbformat": 4, diff --git a/02_activities/assignments/assignment_2.ipynb b/02_activities/assignments/assignment_2.ipynb index fd02cc6cc..b996681c8 100644 --- a/02_activities/assignments/assignment_2.ipynb +++ b/02_activities/assignments/assignment_2.ipynb @@ -79,24 +79,31 @@ "outputs": [], "source": [ "all_paths = [\n", - " \"python/05_src/data/assignment_2_data/inflammation_01.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_02.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_03.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_04.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_05.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_06.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_07.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_08.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_09.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_10.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_11.csv\",\n", - " \"python/05_src/data/assignment_2_data/inflammation_12.csv\"\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_01.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_02.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_03.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_04.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_05.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_06.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_07.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_08.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_09.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_10.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_11.csv\",\n", + " \"C:/Users/Mo/python/python/05_src/data/assignment_2_data/inflammation_12.csv\"\n", "]\n", "\n", "with open(all_paths[0], 'r') as f:\n", " # YOUR CODE HERE: Use the readline() or readlines() method to read the .csv file into a variable\n", - " \n", - " # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection" + " #for i in range(5):\n", + " Read_file = f.readlines()\n", + " #print(Read_file)\n", + "\n", + " # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection\n", + " for i in Read_file:\n", + " print(i)\n", + " \n", + " " ] }, { @@ -130,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "id": "82-bk4CBB1w4" }, @@ -145,12 +152,15 @@ " # Implement the specific operation based on the 'operation' argument\n", " if operation == 'mean':\n", " # YOUR CODE HERE: Calculate the mean (average) number of flare-ups for each patient\n", + " summary_values = data.mean(axis = ax)\n", "\n", " elif operation == 'max':\n", " # YOUR CODE HERE: Calculate the maximum number of flare-ups experienced by each patient\n", + " summary_values = data.max(axis = ax)\n", "\n", " elif operation == 'min':\n", " # YOUR CODE HERE: Calculate the minimum number of flare-ups experienced by each patient\n", + " summary_values = data.min(axis = ax)\n", "\n", " else:\n", " # If the operation is not one of the expected values, raise an error\n", @@ -161,11 +171,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "id": "3TYo0-1SDLrd" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "60\n" + ] + } + ], "source": [ "# Test it out on the data file we read in and make sure the size is what we expect i.e., 60\n", "# Your output for the first file should be 60\n", @@ -228,7 +246,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": { "id": "_svDiRkdIwiT" }, @@ -251,7 +269,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": { "id": "LEYPM5v4JT0i" }, @@ -261,15 +279,25 @@ "\n", "def detect_problems(file_path):\n", " #YOUR CODE HERE: Use patient_summary() to get the means and check_zeros() to check for zeros in the means\n", + " Y = patient_summary(file_path, 'mean')\n", + " Problem = check_zeros(Y)\n", "\n", - " return" + " return Problem" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], "source": [ "# Test out your code here\n", "# Your output for the first file should be False\n", @@ -314,7 +342,8 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "dsi_participant", + "language": "python", "name": "python3" }, "language_info": { @@ -327,7 +356,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.9.19" } }, "nbformat": 4,