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
110 changes: 94 additions & 16 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,78 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# For testing purposes, we will write our code in the function\n",
"# For testing purposes, we will write our code in the function, Ignoring case for now, so make everything upper or lower case!\n",
"def anagram_checker(word_a, word_b):\n",
" # Your code here\n",
" #convert all to lower, in order to ignore case sensitivity\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" #checking lengths of the individual strings first using the len() function!\n",
" if len(word_a) != len(word_b):\n",
" return False #if the lenghts are not equal, they cannot be anagrams\n",
" #sort the words and compare their letters, this time using the sorted() function\n",
" elif sorted(word_a) == sorted(word_b):\n",
" return True #if the sorted letters are equal, they are anagrams\n",
" #all other conditions\n",
" else:\n",
" return False\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Night\")"
"anagram_checker(\"Silent\", \"Night\") #different string lengths!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"night\", \"Thing\")"
"anagram_checker(\"night\", \"Thing\") # True"
]
},
{
Expand All @@ -97,22 +141,56 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 38,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
" #checking lengths first again\n",
" if len(word_a) != len(word_b):\n",
" return False\n",
" #if case sensitivity is not required\n",
" elif is_case_sensitive == False:\n",
" return sorted(word_a.lower()) == sorted(word_b.lower())\n",
" #if case sensitivity is required\n",
" elif is_case_sensitive == True:\n",
" return sorted(word_a) == sorted(word_b)\n",
" #other conditions\n",
" else:\n",
" return False\n",
" \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": 37,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
Expand All @@ -130,7 +208,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": "python-env",
"language": "python",
"name": "python3"
},
Expand All @@ -144,7 +222,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.13"
}
},
"nbformat": 4,
Expand Down
216 changes: 215 additions & 1 deletion 02_activities/homework/01_data_types.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1,215 @@
{"cells":[{"cell_type":"markdown","metadata":{"id":"jNAI57ELh-I8"},"source":["# Getting Started: Python Fundamentals\n","## Practice Problems"]},{"cell_type":"markdown","metadata":{"id":"5xeRB_0jiT5n"},"source":["### 1. What types are involved in the following expressions? What data type will each expression evaluate to?\n","\n","`8 * 2.5`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":158,"status":"ok","timestamp":1667929890889,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"C6c48sSBOUeE","outputId":"3628ffce-faf6-4d23-daff-5e09edf76541"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"4eICUfHi_Z-K"},"source":["`9 / 2`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":43,"status":"ok","timestamp":1667929891449,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"QVdbNoA2OiQ_","outputId":"ab9f4fac-b1cc-4afc-cc54-10592b92abb1"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"DhrJoWbj_cNe"},"source":["`9 // -2`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":39,"status":"ok","timestamp":1667929891450,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"cSsGq3r0Opx6","outputId":"13df11ef-d136-4a42-884e-be1e369aae52"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"lW4UnVfw_eYy"},"source":["`1.5 * 2 >= 7 - 3`"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":34,"status":"ok","timestamp":1667929891452,"user":{"displayName":"Kaylie Lau","userId":"01284785813595846851"},"user_tz":300},"id":"54N6gcNPOylS","outputId":"938208fc-c4c3-4e58-dd18-b50d3acc84d8"},"outputs":[],"source":["# Your code here"]},{"cell_type":"markdown","metadata":{"id":"5T-ytiTw-KvJ"},"source":["### 2. In which order will the expressions be evaluated.\n","\n","`6 * 3 + 7 * 4`\n","\n","\n","<details>\n"," <summary>Answer</summary>\n","\n"," `*` > `*` > `+` \n","</details>\n","\n","\n","`5 - 2 * 3 ** 4`\n","\n","<details>\n"," <summary>Answer</summary>\n","\n"," `**` > `*` > `-`\n","</details>\n","\n","`(5 - 2) * 3 ** 4`\n","\n","<details>\n"," <summary>Answer</summary>\n","\n"," `(-)` > `**` > `*` \n","</details>\n","\n","`5 + 2 >= 3 * 4`\n","\n","<details>\n"," <summary>Answer</summary>\n","\n"," `*` > `+` > `>=`\n","</details>"]}],"metadata":{"colab":{"authorship_tag":"ABX9TyMhUBNX+UP2C+YDtVSxQKBK","collapsed_sections":[],"provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "jNAI57ELh-I8"
},
"source": [
"# Getting Started: Python Fundamentals\n",
"## Practice Problems"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5xeRB_0jiT5n"
},
"source": [
"### 1. What types are involved in the following expressions? What data type will each expression evaluate to?\n",
"\n",
"`8 * 2.5`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"executionInfo": {
"elapsed": 158,
"status": "ok",
"timestamp": 1667929890889,
"user": {
"displayName": "Kaylie Lau",
"userId": "01284785813595846851"
},
"user_tz": 300
},
"id": "C6c48sSBOUeE",
"outputId": "3628ffce-faf6-4d23-daff-5e09edf76541"
},
"outputs": [],
"source": [
"# Your code here\n",
"#integer with float "
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4eICUfHi_Z-K"
},
"source": [
"`9 / 2`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"executionInfo": {
"elapsed": 43,
"status": "ok",
"timestamp": 1667929891449,
"user": {
"displayName": "Kaylie Lau",
"userId": "01284785813595846851"
},
"user_tz": 300
},
"id": "QVdbNoA2OiQ_",
"outputId": "ab9f4fac-b1cc-4afc-cc54-10592b92abb1"
},
"outputs": [],
"source": [
"# Your code here\n",
"#integer with integer"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "DhrJoWbj_cNe"
},
"source": [
"`9 // -2`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"executionInfo": {
"elapsed": 39,
"status": "ok",
"timestamp": 1667929891450,
"user": {
"displayName": "Kaylie Lau",
"userId": "01284785813595846851"
},
"user_tz": 300
},
"id": "cSsGq3r0Opx6",
"outputId": "13df11ef-d136-4a42-884e-be1e369aae52"
},
"outputs": [],
"source": [
"# Your code here\n",
"#integer with integer "
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "lW4UnVfw_eYy"
},
"source": [
"`1.5 * 2 >= 7 - 3`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"executionInfo": {
"elapsed": 34,
"status": "ok",
"timestamp": 1667929891452,
"user": {
"displayName": "Kaylie Lau",
"userId": "01284785813595846851"
},
"user_tz": 300
},
"id": "54N6gcNPOylS",
"outputId": "938208fc-c4c3-4e58-dd18-b50d3acc84d8"
},
"outputs": [],
"source": [
"# Your code here\n",
"#integer with float, will return a boolean "
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5T-ytiTw-KvJ"
},
"source": [
"### 2. In which order will the expressions be evaluated.\n",
"\n",
"`6 * 3 + 7 * 4`\n",
"\n",
"\n",
"<details>\n",
" <summary>Answer</summary>\n",
"\n",
" `*` > `*` > `+` \n",
"</details>\n",
"\n",
"\n",
"`5 - 2 * 3 ** 4`\n",
"\n",
"<details>\n",
" <summary>Answer</summary>\n",
"\n",
" `**` > `*` > `-`\n",
"</details>\n",
"\n",
"`(5 - 2) * 3 ** 4`\n",
"\n",
"<details>\n",
" <summary>Answer</summary>\n",
"\n",
" `(-)` > `**` > `*` \n",
"</details>\n",
"\n",
"`5 + 2 >= 3 * 4`\n",
"\n",
"<details>\n",
" <summary>Answer</summary>\n",
"\n",
" `*` > `+` > `>=`\n",
"</details>"
]
}
],
"metadata": {
"colab": {
"authorship_tag": "ABX9TyMhUBNX+UP2C+YDtVSxQKBK",
"collapsed_sections": [],
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}