Search for question
Question

{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Homework #03\n", "\n", "## Introduction\n", "\n", "[Fibonacci sequence in Medicine](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9883531/)\n", "\n", "Process diagrams are optional for this assignment, but

they can boost your score if you are unsure of your answe documentation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question (20 pts)\n", "\n", ] }, { "Using a While loop calculate the first 20 numbers of the fibonacci sequence and store them in a list. You may put "\n", "**Bonus (5 pts):** Make a process diagram showing your process. " "cell_type": "markdown", "metadata": {}, "source": [ "## Answer" ] }, { "cell_type": "code", "execution_count": 1, "metadata":{ "execution":{ } }, "iopub.execute_input": "2023-12-29T17:10:29.520194Z", "iopub.status.busy": "2023-12-29T17:10:29.519197Z", "iopub.status.idle": "2023-12-29T17:10:29.533517Z", "shell.execute_reply": "2023-12-29T17:10:29.533517Z", "shell.execute_reply.started": "2023-12-29T17:10:29.520194Z" "outputs": [], "source": [ "import iplantuml" ] }, { "cell_type": "code", "execution_count": 2, "metadata":{ "execution": { "iopub.execute_input": "2023-12-29T17:10:29.535491Z", "iopub.status.busy": "20 3-12-29T17:10:29.534490Z", "iopub.status.idle": "2023-12-29T17:10:30.283342Z", "shell.execute_reply": "2023-12-29T17:10:30.282399Z", } }, "outputs": [ { "data":{ "shell.execute_reply.started": "2023-12-29T17:10:29.535491Z" "image/svg+xml": [ "Repeated step 2 ,115.9688,140,127.9688,53,127.9688,41,115.9688,53,103.9688\" style=\"stroke:#181818;stroke-width:0.5;\"/>yesn less than 20?Repo 11\" ry=\"11\" style=\"stroke:#222222;stroke-width:1.0;\"/>< 8.2612,169,164.2612\" style=\"stroke:#181818;stroke-width:1.0;\"/>" ], ], } { ] }, "text/plain":[ }, "" ] "execution_count": 2, "metadata": {}, "output_type": "execute_result" "source": [ "%%plantuml\n", "@startuml\n", "start\n", "\n", ":step 1;\n", "\n", "while (n less than 20?) is (yes)\n", " :Repeated step 2;\n", "endwhile (no)\n", ":Report;\n", "\n", "stop\n", "@enduml" "cell_type": "code", "execution_count": 3, "metadata":{ "execution":{ } }, "outputs": [], "source": [ "# Answer\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question (30 pts)\n", "\n", "Using a For loop check ER patients blood sugar levels to determine which patients need immediate attention. For cked soon; those with very low, very high, or critical need to be checked now. Report patients needing immediate att "\n", "iopub.execute_input": "2023-12-29T17:10:30.284344Z", "iopub.status.busy": "2023-12-29T17:10:30.284344Z", "iopub.status.idle": "2023-12-29T17:10:30.290820Z", "shell.execute_reply": "2023-12-29T17:10:30.289821Z", "shell.execute_reply.started": "2023-12-29T17:10:30.2843447" ] "Bins:\n", "| Very Low | Low | Normal | High | Very High | Critical |\n", "|-- ·|-- -|· -|\n", "| 0-30 (mg/dL) | 30-70 | 70-100 | 100-125 | 125-250 | 250+ |\n", "\n", "Patients: [160, 56, 36, 256, 255, 129, 30, 228, 65, 100, 222, 138, 134, 26, 244, 98, 101, 227, 259, 187]" }, { "cell_type": "code", "execution_count": 4, "metadata":{ "execution": { }, "tags":[] }, "outputs": [], "source": [ "import numpy as np\n", "\n" }, { ] "iopub.execute_input": "2023-12-29T17:10:30.291820Z", "iopub.status.busy": "2023-12-29T17:10:30.291820Z", "iopub.status.idle": "2023-12-29T17:10:30.481745Z", "shell.execute_reply": "2023-12-29T17:10:30.481745Z", "shell.execute_reply.started": "2023-12-29T17:10:30.291820Z" "cell_type": "markdown", "metadata": {}, ] "source": [ "## Answer" }, { "cell_type": "code", "execution_count": 5, "metadata":{ "execution": { "iopub.execute_input": "2023-12-29T17:10:30.483713Z", "iopub.status.busy": "2023-12-29T17:10:30.483713Z", "iopub.status.idle": "2023-12-29T17:10:30.488960Z", "shell.execute_reply": "2023-12-29T17:10:30.488960Z", "shell.execute_reply.started": "2023-12-29T17:10:30.4837137" }, "tags":[] }, "outputs":[], "source": [ "# Answer\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question (20 pts)\n", "\n", "Repeat the last question using list comprehension" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Answer" ] }, { "cell_type": "code", "execution_count": 6, "metadata":{ "execution": { "iopub.execute_input": "2023-12-29T17:10:30.490959Z", "iopub.status.busy": "2023-12-29T17:10:30.489957Z", "iopub.status.idle": "2023-12-29T17:10:30.497031Z", "shell.execute_reply": "2023-12-29T17:10:30.497031Z", "shell.execute_reply.started": "2023-12-29T17:10:30.490959Z" }, "tags":[] }, "outputs": [], "source": [ "# Answer\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question (20 pts)\n", "\n", "Use filter to just get the list of glucose levels that are in the danger zones.\n", "\n", ] { "**Bonus (5 pts)**: Report patient ID too, just like the others. *Hint:* you might need range, zip, and map. ' 11 }, "cell_type": "code", "execution_count": 7, "metadata":{ "execution": { "iopub.execute_input": "2023-12-29T17:10:30.499026Z", "iopub.status.busy": "2023-12-29T17:10:30.499026Z", "iopub.status.idle": "2023-12-29T17:10:30.506025Z", "shell.execute_reply": "2023-12-29T17:10:30.505026Z", "shell.execute_reply.started": "2023-12-29T17:10:30.499026Z" }, "tags":[] }, "outputs": [], "source": [ "# Answer\n", "\n" ] }, { "cell_type": "code", "execution_count":8, "metadata":{ "execution": { }, "tags":[] }, "outputs": [], "source": [ { ] "# Answer (bonus)\n", "\n" }, "iopub.execute_input": "2023-12-29T17:10:30.507025Z", "iopub.status.busy": "2023-12-29T17:10:30.507025Z", "iopub.status.idle": "2023-12-29T17:10:30.513615Z", "shell.execute_reply": "2023-12-29T17:10:30.512618Z", "shell.execute_reply.started": "2023-12-29T17:10:30.507025Z" "cell_type": "markdown", "metadata": {}, "source": [ "## Question (10pts):\n", "\n", "How long did it take to run each of for loop, list comprehension, and filter versions?\n", "\n", "What was your preferred method, and why?" ] }, { "cell_type": "markdown", "metadata":{ "tags":[] }, "source": [