Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 73 additions & 13 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,65 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 1,
"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",
" \n",
" return sorted(word_a.lower()) == sorted(word_b.lower())\n",
" \n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
]
},
{
"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\")"
]
Expand All @@ -99,20 +134,45 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
"\n",
" if is_case_sensitive:\n",
" return sorted(word_a) == sorted(word_b) # checking if they have the same letters\n",
" else:\n",
" return sorted(word_a.lower()) == sorted(word_b.lower())\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\", False) # True"
"anagram_checker(\"Silent\", \"liSten\", True) # True"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
Expand All @@ -130,7 +190,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": "python-env",
"language": "python",
"name": "python3"
},
Expand All @@ -144,7 +204,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.14"
}
},
"nbformat": 4,
Expand Down
22 changes: 17 additions & 5 deletions 02_activities/assignments/assignment_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@
"\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"
" lines = f.readlines()\n",
"\n",
" # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection\n",
" for row in lines:\n",
" print(row.strip())"
]
},
{
Expand Down Expand Up @@ -145,12 +148,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 = np.mean(data, 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 = np.max(data, 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 = np.min(data, axis=ax)\n",
"\n",
" else:\n",
" # If the operation is not one of the expected values, raise an error\n",
Expand Down Expand Up @@ -261,8 +267,13 @@
"\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",
" # Get the mean inflammation scores for all patients\n",
" means = patient_summary(file_path, 'mean')\n",
" \n",
" # Check if there are any zero values in the means\n",
" has_zeros = check_zeros(means)\n",
"\n",
" return"
" return has_zeros"
]
},
{
Expand Down Expand Up @@ -314,7 +325,8 @@
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "python-env",
"language": "python",
"name": "python3"
},
"language_info": {
Expand All @@ -327,7 +339,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.14"
}
},
"nbformat": 4,
Expand Down
Loading