From 961477a5bf3831630bc74846893994a9a931c2d6 Mon Sep 17 00:00:00 2001 From: kaylielau Date: Fri, 28 Nov 2025 01:38:25 +0000 Subject: [PATCH 1/2] Upload live code --- 04_this_cohort/live-code/11_27_2025.ipynb | 1895 +++++++++++++++++++++ 1 file changed, 1895 insertions(+) create mode 100644 04_this_cohort/live-code/11_27_2025.ipynb diff --git a/04_this_cohort/live-code/11_27_2025.ipynb b/04_this_cohort/live-code/11_27_2025.ipynb new file mode 100644 index 000000000..8b285a0a2 --- /dev/null +++ b/04_this_cohort/live-code/11_27_2025.ipynb @@ -0,0 +1,1895 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "fee8cbc9", + "metadata": {}, + "outputs": [], + "source": [ + "# logic operators\n", + "\n", + "# not: negate the truth value of the statement" + ] + }, + { + "cell_type": "markdown", + "id": "75dd7129", + "metadata": {}, + "source": [ + "|X|`not` X|\n", + "|-|-|\n", + "|True|False|\n", + "|False|True|" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "f26de1bf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not True" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "8d897cf6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not False" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "9b9b2b8f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "3 == 3" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "fa2d9fce", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not (3 == 3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5702b645", + "metadata": {}, + "outputs": [], + "source": [ + "# and: check if the statements on both sides are true" + ] + }, + { + "cell_type": "markdown", + "id": "b08151f9", + "metadata": {}, + "source": [ + "|X|Y|X `and` Y|\n", + "|-|-|-|\n", + "|True|True|True|\n", + "|False|True|False|\n", + "|True|False|False|\n", + "|False|False|False|" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "e9ef2132", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True and True" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "2f9cb490", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "False and True" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "75f091b5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True and False" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "982685be", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "False and False" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "417c0b80", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "7 == 7.0 and 32 > 9" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "39b37165", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(7 == 7.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "108c482d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(32 > 9)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "c3b6c4d2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "('Python' == 'python') and True" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "43b1090a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "('Python' == 'python')" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "8b6d43e0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_winter = True\n", + "is_grey = True\n", + "\n", + "is_winter and is_grey" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "04ab474e", + "metadata": {}, + "outputs": [], + "source": [ + "# or: check if at least one of the statements are true" + ] + }, + { + "cell_type": "markdown", + "id": "d3c8bf1a", + "metadata": {}, + "source": [ + "|X|Y|X `or` Y|\n", + "|-|-|-|\n", + "|True|True|True|\n", + "|False|True|True|\n", + "|True|False|True|\n", + "|False|False|False|" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "4367a955", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True or True" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "fef4e13c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "False or True" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "84a08c66", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True or False" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "ce175acd", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "False or False" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "c185ff55", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"Python\" == \"python\" or True" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "f47183bd", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"Python\" == \"python\"" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "317edb77", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not (7 % 2 == 1) or False" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "adde0a5f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "7 % 2" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "c36b362c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "7 % 2 == 1" + ] + }, + { + "cell_type": "markdown", + "id": "903f0645", + "metadata": {}, + "source": [ + "| Order | Operator | Description |\n", + "|---|---|---|\n", + "| 1 | `**` | Exponentiation |\n", + "| 2 | `-`| Negation |\n", + "| 3 | `*`, `/`, `//`, `%` | Multiplication, division, integer division, and modulo |\n", + "| 4 | `+`, `-` | Addition and subtraction |\n", + "| 5 | `<`, `<=`, `>`, `>=`, `==`, `!=` | Less than, less than or equal to, greater than, greater than or equal to, equal, not equal |\n", + "| 6 | `not` | Not |\n", + "| 7 | `and` | And |\n", + "| 8 | `or` | Or|" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "19de0b84", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1 or True" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "3e5cc94b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Thursday'" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"Thursday\" or True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb1da455", + "metadata": {}, + "outputs": [], + "source": [ + "# return the first truthy value encountered \n", + "# or the last falsy value if all operands are False" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "c483a2f4", + "metadata": {}, + "outputs": [], + "source": [ + "year = 2024\n", + "output = 'no'\n", + "\n", + "if year >= 2000 and output == 'yes':\n", + " print('We are in the 21st century.')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9d12c4a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "year >= 2000 and output == 'yes' # True and False" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "ac0ea391", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "We are not in the 21st century\n" + ] + } + ], + "source": [ + "year = 1999\n", + "\n", + "if year >= 2000:\n", + " print('We are in the 21st century.')\n", + "else:\n", + " print('We are not in the 21st century')" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "f6d3d0ec", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "We are in the 21st century.\n" + ] + } + ], + "source": [ + "# elif short for \"else if\"\n", + "\n", + "year = 2002\n", + "\n", + "if year >= 2000:\n", + " print('We are in the 21st century.')\n", + "elif year >= 1900:\n", + " print('We are in the 20th century.')\n", + "elif year >= 1800:\n", + " print('We are in the 19th century.')\n", + "else:\n", + " print('We have gone way back in time!')" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "d3f53773", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Weekend\n" + ] + } + ], + "source": [ + "day_of_week = 'Saturday'\n", + "\n", + "if day_of_week == 'Saturday' or day_of_week == 'Sunday': # True or False\n", + " print('Weekend')\n", + "else:\n", + " print('Weekday')" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "8ac99a7f", + "metadata": {}, + "outputs": [], + "source": [ + "def eye_exam_covered(age, qualifying_condition, time_since_last_exam):\n", + " # assumptions:\n", + " # age int\n", + " # qualifying_condition bool, True if have an eligible medical condition, False otherwise\n", + " # time_since_last_exam int, number of months since last examination\n", + "\n", + " if 0 <= age <= 19: # False\n", + " if time_since_last_exam >= 12:\n", + " return \"You are eligible for 1 major eye exam and any minor assessments needed\"\n", + " else:\n", + " return \"It hasn't been 12 months since your last major eye exam but you can have a minor assessments\"\n", + " \n", + " elif 20 <= age <= 64: # False\n", + " if qualifying_condition: \n", + " if time_since_last_exam >= 12: \n", + " return \"You are eligible for 1 major eye exam and 2 additional follow-up minor assessments\"\n", + " else:\n", + " return \"It hasn't been 12 months since your last major eye exam, but you have follow-up minor assessments\"\n", + " else:\n", + " return \"You do not have an eligible medical condition\"\n", + " \n", + " elif age >= 65: # True\n", + " if time_since_last_exam >= 18: # False\n", + " return \"You are eligible for 1 major eye exam and 2 follow-up minor assessments\"\n", + " else:\n", + " return \"It hasn't been 18 months since your last major eye exam, but you have 2 follow-up minor assessments\"\n", + " \n", + " else:\n", + " return \"Invalid age input.\"\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "dcc4ad6a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Invalid age input.'" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(-100, True, 5)" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "c4f78764", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"It hasn't been 18 months since your last major eye exam, but you have 2 follow-up minor assessments\"" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(65, True, 10)" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "18e32bd4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You are eligible for 1 major eye exam and 2 additional follow-up minor assessments'" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(50, True, 18)" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "6c7c8689", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You do not have an eligible medical condition'" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(23, False, 10)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "b691b45c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"It hasn't been 12 months since your last major eye exam but you can have a minor assessments\"" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(15, True, 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "38ed2f8e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You are eligible for 1 major eye exam and any minor assessments needed'" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(19, False, 14)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "id": "9e7ed128", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['a', 'e', ' i', 'o', 'u']" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vowels = ['a', 'e', ' i', 'o', 'u']\n", + "vowels" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "id": "5e231cbe", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[90, 80, 82, 91, 80]" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "score = [90, 80, 82, 91, 80]\n", + "score" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "id": "2dc8329f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['K', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grades = ['K', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n", + "grades" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "id": "9792541b", + "metadata": {}, + "outputs": [], + "source": [ + "summary_functions = [len, sum, max, min]" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "id": "e2328b22", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "empty_list_1 = []\n", + "empty_list_1" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "id": "d529ace3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "empty_list_2 = list()\n", + "empty_list_2" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "id": "653f6bdb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[['Sherlock', 'Watson'],\n", + " ['Scooby', 'Shaggy', 'Fred', 'Daphne', 'Velma'],\n", + " 'Nancy Drew']" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mystery_solvers =[['Sherlock', 'Watson'],\n", + " ['Scooby', 'Shaggy', 'Fred', 'Daphne', 'Velma'],\n", + " 'Nancy Drew']\n", + "mystery_solvers" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "id": "11a401a9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['K', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# lists are ordered\n", + "\n", + "grades" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "id": "b6eee486", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'K'" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grades[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "39bd6bb6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['a', 'e', ' i', 'o', 'u']" + ] + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vowels" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "id": "4c12889c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['e', ' i']" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vowels[1:3]" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "ea95bb03", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'o'" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vowels[-2]" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "id": "a8b90be1", + "metadata": {}, + "outputs": [ + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mIndexError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[82]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mvowels\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m10000\u001b[39;49m\u001b[43m]\u001b[49m\n", + "\u001b[31mIndexError\u001b[39m: list index out of range" + ] + } + ], + "source": [ + "vowels[10000]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "957955a3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 4, 9, 16, 25, 36, 49]" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "perfect_squares = [1, 4, 9, 16, 25, 37, 49]\n", + "\n", + "perfect_squares[5] = 36\n", + "\n", + "perfect_squares" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "id": "c8b82c80", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'cheese sandwich'" + ] + }, + "execution_count": 84, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xindi_sandwich = 'cheese sandwich'\n", + "xindi_sandwich" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "id": "686c324e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'cheese sandwich'" + ] + }, + "execution_count": 86, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kaylie_sandwich = xindi_sandwich\n", + "kaylie_sandwich" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "id": "49225fa2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'tomato sandwich'" + ] + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xindi_sandwich = 'tomato sandwich'\n", + "xindi_sandwich" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "id": "0ca50664", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'cheese sandwich'" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kaylie_sandwich" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "id": "e580fbb3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['bread', 'cheese', 'bread']" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xindi_sandwich2 = ['bread', 'cheese', 'bread']\n", + "xindi_sandwich2" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "id": "6e95f874", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['bread', 'cheese', 'bread']" + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kaylie_sandwich2 = xindi_sandwich2\n", + "kaylie_sandwich2" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "id": "1ac1cb08", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['bread', 'tomato', 'bread']" + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xindi_sandwich2[1] = 'tomato'\n", + "xindi_sandwich2" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "id": "5cb5a056", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['bread', 'tomato', 'bread']" + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kaylie_sandwich2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6e3bd2ea", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4499422832" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(xindi_sandwich) #tomato sandwich" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "id": "0e881821", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4498736752" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(kaylie_sandwich)" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "id": "d86d88c1", + "metadata": {}, + "outputs": [], + "source": [ + "xindi_sandwich = 'cheese sandwich'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "05a7a06c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4499440048" + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(xindi_sandwich) #cheese sandwich" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "id": "dd3c95e4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4498736752" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(kaylie_sandwich)" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "id": "f7eeb8c3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 99, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = 1\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "id": "582fb185", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b = a\n", + "b" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "id": "744e609c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4375949656" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "id": "2c379733", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4375949656" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(b)" + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "id": "15e99362", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = 2\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "id": "ccd1681b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4375949688" + ] + }, + "execution_count": 105, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "id": "cde64269", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "49b91ea9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4375949656" + ] + }, + "execution_count": 107, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(b)" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "id": "fd57f6ac", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2]" + ] + }, + "execution_count": 108, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = [1, 2]\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "id": "82a56bd5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2]" + ] + }, + "execution_count": 111, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b = a\n", + "b" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "221edb6b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[6, 2]" + ] + }, + "execution_count": 113, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a[0] = 6\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "id": "da8b3ec7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[6, 2]" + ] + }, + "execution_count": 114, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "id": "c6d5f4b8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4499442816" + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "id": "767facda", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4499442816" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id(b)" + ] + }, + { + "cell_type": "code", + "execution_count": 117, + "id": "815323c0", + "metadata": {}, + "outputs": [], + "source": [ + "combo = ['burger', 'fries', 'drink']\n", + "kid_meal = list(combo)" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "id": "9a97a9a4", + "metadata": {}, + "outputs": [], + "source": [ + "combo[0] = 'chicken sandwich'" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "id": "c7eb5596", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['chicken sandwich', 'fries', 'drink']" + ] + }, + "execution_count": 119, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "combo" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "id": "0c9d233a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['burger', 'fries', 'drink']" + ] + }, + "execution_count": 120, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kid_meal" + ] + }, + { + "cell_type": "code", + "execution_count": 121, + "id": "53bb045e", + "metadata": {}, + "outputs": [], + "source": [ + "combo[1] = 'fruit'" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "id": "9821bad5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['chicken sandwich', 'fruit', 'drink']" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "combo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "00365352", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "python-env", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From b766839453ff3af5886a1b9e8c296e6a6c6869fc Mon Sep 17 00:00:00 2001 From: kaylielau Date: Fri, 28 Nov 2025 01:38:46 +0000 Subject: [PATCH 2/2] Update assignment #1 --- 02_activities/assignments/assignment_1.ipynb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 625be0241..e5f40f66e 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -44,7 +44,7 @@ "\n", "Examples of anagrams:\n", "* Silent and Listen\n", - "* Night and Think\n", + "* Night and Thing\n", "\n", "Example outputs:\n", "```python\n", @@ -108,6 +108,15 @@ "anagram_checker(\"Silent\", \"listen\", False) # True" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "anagram_checker(\"Silent\", \"listen\", True) # False" + ] + }, { "cell_type": "code", "execution_count": null,