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
29 changes: 26 additions & 3 deletions 01_materials/slides/01_data_types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand All @@ -318,7 +341,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "python-env",
"language": "python",
"name": "python3"
},
Expand All @@ -332,7 +355,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.13"
}
},
"nbformat": 4,
Expand Down
98 changes: 86 additions & 12 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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\")"
]
Expand All @@ -97,22 +137,56 @@
},
{
"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"
]
},
{
"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"
]
Expand All @@ -130,7 +204,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": "python-env",
"language": "python",
"name": "python3"
},
Expand All @@ -144,7 +218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.13"
}
},
"nbformat": 4,
Expand Down