diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 625be0241..495f91804 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,13 +56,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 28, + "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", + " #word_a = word_a.lower()\n", + " #word_b = word_b.lower()\n", + " a = sorted(word_a.lower())\n", + " b = sorted(word_b.lower())\n", + " if a == b:\n", + " return True\n", + " else:\n", + " return False\n", + "\n", + "\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -70,18 +91,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -97,12 +140,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " # Modify your existing code here\n", + " a = sorted(word_a)\n", + " b = sorted(word_b)\n", + " if is_case_sensitive:\n", + " if a == b:\n", + " return True\n", + " else:\n", + " return False\n", + " elif is_case_sensitive == False:\n", + " a = sorted(word_a.lower())\n", + " b = sorted(word_b.lower())\n", + " if a == b:\n", + " return True\n", + " else:\n", + " return False\n", + "\n", + " \n", + "\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -110,9 +181,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -130,7 +212,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "python-env", "language": "python", "name": "python3" }, @@ -144,7 +226,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.11.14" } }, "nbformat": 4, diff --git a/02_activities/assignments/assignment_2.ipynb b/02_activities/assignments/assignment_2.ipynb index fdaead283..a21332861 100644 --- a/02_activities/assignments/assignment_2.ipynb +++ b/02_activities/assignments/assignment_2.ipynb @@ -72,11 +72,138 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "id": "n0m48JsS-nMC" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0,0,0,1,3,4,6,5,2,7,7,8,6,11,5,6,10,4,5,9,15,15,14,13,14,12,10,9,8,8,6,6,6,6,5,4,2,1,1,0\n", + "\n", + "0,0,2,2,4,2,1,7,5,7,3,6,10,5,5,14,14,9,11,10,5,5,5,15,6,6,10,13,6,8,3,5,7,7,3,2,2,0,2,1\n", + "\n", + "0,1,2,3,2,1,4,1,8,7,4,5,10,3,11,5,11,8,18,4,17,9,5,6,15,14,11,5,6,4,7,2,5,6,4,5,4,0,2,1\n", + "\n", + "0,0,0,0,1,2,4,7,3,5,8,7,5,13,10,7,11,8,18,6,13,4,10,13,5,5,4,3,8,9,2,3,2,3,5,3,1,3,1,1\n", + "\n", + "0,1,0,2,1,2,3,6,5,2,9,3,5,12,9,5,8,11,9,4,19,19,15,9,6,12,9,3,6,2,9,9,8,5,3,5,3,0,2,1\n", + "\n", + "0,0,1,3,4,4,2,2,6,3,2,9,4,11,12,8,6,8,8,7,18,11,13,13,10,5,7,11,3,6,9,6,4,5,1,4,1,0,0,0\n", + "\n", + "0,1,0,3,2,3,2,2,4,6,4,11,11,8,3,9,11,7,12,16,10,5,17,8,11,15,6,8,11,10,6,9,4,3,3,3,1,3,1,1\n", + "\n", + "0,1,2,1,4,1,2,7,2,2,8,9,5,6,12,12,6,14,6,5,12,11,11,5,10,7,6,6,10,2,4,5,8,3,5,3,3,0,0,1\n", + "\n", + "0,0,1,2,2,1,4,2,7,4,10,6,4,3,6,5,8,13,8,8,12,4,13,4,13,4,14,5,12,10,6,3,2,1,5,3,4,3,2,0\n", + "\n", + "0,1,1,1,4,2,1,3,5,3,2,3,11,3,4,5,14,4,5,8,18,18,13,5,11,4,13,12,11,4,10,9,3,3,6,3,2,0,2,0\n", + "\n", + "0,1,0,0,2,3,5,2,5,8,4,7,7,8,5,5,8,15,14,4,10,12,8,14,11,14,5,13,4,6,8,3,6,5,5,2,4,2,2,1\n", + "\n", + "0,1,2,3,2,5,6,4,2,4,6,9,6,9,6,6,14,11,6,18,6,13,18,7,15,13,3,12,8,8,5,2,5,7,4,2,2,3,2,0\n", + "\n", + "0,0,0,1,4,1,4,1,7,7,8,7,7,4,9,3,8,17,17,9,13,19,5,10,8,7,5,3,7,4,6,5,4,1,5,2,1,0,0,0\n", + "\n", + "0,0,2,1,1,4,5,7,8,5,5,3,6,9,7,8,10,10,13,19,18,15,4,11,6,4,8,11,7,5,4,3,7,3,5,4,4,0,1,0\n", + "\n", + "0,1,0,3,4,3,3,7,6,8,4,11,6,10,10,7,12,9,11,17,10,16,17,4,5,8,4,8,10,8,5,5,4,7,4,2,3,1,0,1\n", + "\n", + "0,0,0,3,1,3,5,1,6,5,3,4,8,11,11,3,4,12,14,17,7,9,4,8,8,15,3,12,9,10,6,6,3,3,2,5,4,3,1,0\n", + "\n", + "0,1,0,0,4,5,5,6,8,9,2,11,4,13,5,15,13,5,13,7,7,5,12,4,12,10,7,4,4,10,10,7,8,2,4,3,4,0,1,1\n", + "\n", + "0,0,2,0,2,3,2,4,4,3,10,5,8,9,8,12,15,10,9,4,17,5,13,12,15,5,8,10,9,5,3,9,4,2,6,4,2,0,1,1\n", + "\n", + "0,0,2,1,3,4,3,2,7,3,5,7,9,8,6,3,7,12,13,15,20,7,5,17,13,5,5,13,8,6,8,4,5,1,1,5,3,2,1,1\n", + "\n", + "0,0,0,3,4,2,2,5,2,8,6,10,7,13,7,11,10,6,12,14,8,7,9,12,11,5,5,13,7,7,4,9,4,7,2,1,2,3,0,1\n", + "\n", + "0,1,1,2,4,1,6,3,8,8,8,9,8,7,12,9,5,7,9,11,8,7,11,6,8,13,14,5,3,7,10,6,8,6,5,4,4,2,0,0\n", + "\n", + "0,0,2,3,3,1,5,3,3,6,8,4,12,8,12,11,14,9,5,7,11,13,13,4,13,12,14,6,7,5,3,4,3,1,1,3,4,3,2,1\n", + "\n", + "0,1,2,3,2,4,1,3,6,2,10,11,7,3,9,6,11,15,4,19,16,9,18,4,6,12,6,5,9,6,9,5,2,4,6,2,1,3,2,1\n", + "\n", + "0,1,0,3,4,5,6,5,4,3,3,9,9,13,10,12,14,7,15,16,15,7,15,6,9,7,10,9,4,8,2,6,8,2,6,4,1,3,0,1\n", + "\n", + "0,1,0,1,4,2,2,7,7,8,7,11,9,5,5,6,14,7,6,14,8,17,5,13,8,6,13,13,10,10,4,2,2,7,6,3,4,1,1,1\n", + "\n", + "0,0,2,2,2,4,3,7,6,9,10,10,3,5,14,14,9,15,16,17,15,10,4,14,12,6,8,12,4,3,6,4,8,3,2,5,1,1,2,1\n", + "\n", + "0,1,0,2,3,5,3,6,3,7,6,5,11,7,14,9,7,8,6,4,12,5,12,6,5,6,3,7,3,8,7,7,4,7,5,3,2,2,2,0\n", + "\n", + "0,1,1,0,2,3,4,1,3,8,8,8,7,6,6,11,13,9,9,9,10,14,8,5,13,4,5,3,3,2,9,2,2,6,5,2,1,1,1,1\n", + "\n", + "0,0,2,3,4,5,2,3,8,6,6,5,10,8,7,15,14,6,6,6,8,7,12,10,7,12,5,8,12,11,4,5,5,6,6,2,2,2,0,0\n", + "\n", + "0,0,1,1,3,2,4,3,4,8,4,3,4,13,11,14,6,6,15,16,10,19,10,15,14,13,7,9,4,2,6,8,2,1,1,5,4,2,1,1\n", + "\n", + "0,1,0,2,2,2,3,1,4,9,9,2,5,6,13,7,13,8,17,15,7,13,11,13,9,5,7,13,10,5,9,3,8,4,6,1,2,3,1,1\n", + "\n", + "0,0,1,1,1,3,5,4,2,2,6,10,9,9,5,5,5,11,18,18,6,14,12,8,15,5,4,4,11,4,5,7,3,4,6,3,2,1,2,1\n", + "\n", + "0,1,0,2,2,5,2,3,2,9,4,2,12,11,6,4,9,11,4,18,19,5,4,6,7,7,10,13,9,2,8,4,3,5,4,2,3,0,0,1\n", + "\n", + "0,1,1,3,2,5,2,5,2,2,9,5,10,11,14,14,15,8,4,13,6,13,11,13,9,5,10,12,8,8,2,2,2,2,6,5,3,1,1,0\n", + "\n", + "0,1,1,2,2,3,2,7,7,8,7,9,4,5,3,9,8,8,11,19,5,16,13,7,16,12,8,7,11,8,3,4,6,1,1,1,4,3,1,0\n", + "\n", + "0,1,1,2,4,4,4,4,4,5,5,11,3,5,6,13,8,14,5,14,9,6,9,15,9,6,4,7,4,6,7,2,4,4,4,3,1,2,0,1\n", + "\n", + "0,0,2,1,1,1,4,7,3,2,9,7,11,4,5,4,16,16,9,4,16,5,16,17,4,9,6,4,10,11,9,9,6,4,6,1,1,0,2,1\n", + "\n", + "0,0,1,1,3,1,4,4,4,7,9,2,3,11,5,10,12,8,6,6,16,13,10,6,7,10,9,7,4,6,5,7,4,3,6,3,1,2,1,1\n", + "\n", + "0,0,1,0,3,3,1,7,4,8,8,2,12,5,12,15,4,12,12,13,20,8,14,5,14,15,6,5,4,4,6,9,5,1,2,1,4,2,0,0\n", + "\n", + "0,1,0,1,4,2,2,5,4,7,3,11,3,12,11,6,4,15,15,16,8,4,16,15,8,7,12,10,5,5,9,5,8,1,3,4,4,2,0,0\n", + "\n", + "0,0,1,2,3,5,4,6,7,7,2,8,9,6,4,9,7,14,6,11,17,16,13,12,16,12,6,5,8,3,8,5,3,1,4,3,1,2,0,1\n", + "\n", + "0,1,2,3,1,3,5,2,2,4,5,9,12,4,7,13,15,4,15,12,15,18,5,16,4,15,8,9,4,9,2,2,6,1,2,3,3,2,1,0\n", + "\n", + "0,1,1,1,2,2,6,3,5,2,10,4,7,13,3,5,14,10,9,16,18,11,15,5,9,14,8,4,3,3,2,8,4,1,4,1,1,1,2,1\n", + "\n", + "0,1,1,2,1,1,5,3,5,4,9,8,11,3,5,15,6,6,8,19,8,15,18,10,12,10,10,6,9,3,10,9,7,6,3,3,1,2,0,0\n", + "\n", + "0,1,2,0,2,1,4,1,5,7,3,2,5,6,6,9,4,17,11,10,16,12,17,13,10,7,13,6,8,9,8,3,8,2,6,1,1,3,2,0\n", + "\n", + "0,0,1,2,3,2,3,5,3,9,8,4,3,9,8,14,6,15,13,4,17,8,9,17,9,5,6,8,10,6,3,7,4,4,3,1,1,0,2,0\n", + "\n", + "0,1,1,0,1,1,2,7,8,6,4,4,9,3,10,14,14,11,6,8,18,5,13,10,4,5,3,12,9,7,8,8,2,4,3,4,3,2,1,1\n", + "\n", + "0,0,0,1,1,1,4,2,5,4,10,9,7,9,3,15,12,6,14,17,16,18,5,8,10,12,10,11,11,8,10,9,8,5,1,3,4,3,0,1\n", + "\n", + "0,0,0,2,4,4,1,2,7,4,7,7,10,7,14,9,6,17,8,8,8,9,6,15,15,12,10,9,11,6,4,7,7,2,4,1,4,1,1,1\n", + "\n", + "0,1,1,1,1,1,1,3,3,4,10,2,6,7,12,8,6,5,11,19,8,10,6,9,15,7,13,7,10,3,3,8,2,2,1,3,2,0,2,1\n", + "\n", + "0,1,1,2,2,4,5,3,4,6,2,3,10,3,7,15,10,8,12,7,13,12,9,7,8,4,9,8,12,10,6,2,4,3,4,3,3,1,0,0\n", + "\n", + "0,0,0,1,3,2,6,5,6,6,7,8,3,13,5,12,4,12,10,18,13,7,7,4,15,13,5,8,10,3,7,6,3,4,5,5,2,1,1,0\n", + "\n", + "0,0,1,0,2,2,3,3,4,8,5,2,8,7,9,7,9,4,7,4,6,11,10,10,8,14,4,5,3,10,6,5,8,3,6,2,3,3,2,0\n", + "\n", + "0,0,2,2,2,1,6,4,4,2,2,3,7,4,8,15,8,12,17,10,17,8,13,13,8,7,3,9,6,2,3,4,8,2,1,1,2,1,2,0\n", + "\n", + "0,0,0,1,4,2,1,4,8,7,7,10,12,5,4,4,12,7,18,9,16,19,11,7,14,8,11,11,10,9,9,8,4,7,6,5,2,2,1,1\n", + "\n", + "0,0,2,2,4,2,3,6,4,5,4,2,5,4,11,13,4,10,16,16,6,16,7,14,5,7,11,10,12,10,8,6,4,1,2,2,4,1,2,0\n", + "\n", + "0,1,0,2,2,1,6,2,2,2,9,5,9,12,5,12,10,13,9,4,17,14,5,10,12,3,13,4,9,8,8,6,7,4,4,5,4,0,2,0\n", + "\n", + "0,0,2,0,4,3,5,5,6,9,4,5,4,3,10,3,7,11,12,10,19,16,17,14,16,9,12,5,10,11,6,7,7,3,3,1,1,0,2,0\n", + "\n", + "0,0,0,3,3,1,5,7,7,7,6,8,7,6,10,14,6,12,5,15,20,18,14,17,14,11,13,10,9,5,5,5,5,7,1,5,3,2,2,0\n", + "\n", + "0,1,2,0,4,5,6,6,2,5,10,10,3,7,13,9,5,16,6,18,15,10,13,11,12,15,10,12,3,8,8,7,5,6,2,5,2,3,2,0\n", + "\n" + ] + } + ], "source": [ "all_paths = [\n", " \"../../05_src/data/assignment_2_data/inflammation_01.csv\",\n", @@ -93,10 +220,12 @@ " \"../../05_src/data/assignment_2_data/inflammation_12.csv\"\n", "]\n", "\n", - "with open(all_paths[0], 'r') as f:\n", + "with open(all_paths[1], '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" + " file_lines = f.readlines()\n", + " # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection\n", + " for line in file_lines:\n", + " print(line)" ] }, { @@ -141,16 +270,31 @@ "def patient_summary(file_path, operation):\n", " data = np.loadtxt(fname=file_path, delimiter=',') # Load the data from the file\n", " ax = 1 # This specifies that the operation should be done for each row (patient)\n", + " #summary_values = [] # created empty list to use in append method\n", "\n", " # 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 = data.mean(axis = ax) # calculating using axis on multi dimention array\n", + " \n", + " # below is another way of calculating using loop\n", + " '''for patient in data: \n", + " avg = patient.mean()\n", + " summary_values.append(avg)'''\n", "\n", " elif operation == 'max':\n", " # YOUR CODE HERE: Calculate the maximum number of flare-ups experienced by each patient\n", + " summary_values = data.max(axis = ax)\n", + " '''for patient in data:\n", + " maximum = patient.max()\n", + " summary_values.append(maximum)'''\n", "\n", " elif operation == 'min':\n", " # YOUR CODE HERE: Calculate the minimum number of flare-ups experienced by each patient\n", + " summary_values = data.min(axis = ax)\n", + " '''for patient in data:\n", + " minimum = patient.min()\n", + " summary_values.append(minimum)'''\n", "\n", " else:\n", " # If the operation is not one of the expected values, raise an error\n", @@ -161,15 +305,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": { "id": "3TYo0-1SDLrd" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + "60\n" + ] + } + ], "source": [ "# Test it out on the data file we read in and make sure the size is what we expect i.e., 60\n", "# Your output for the first file should be 60\n", - "data_min = patient_summary(all_paths[0], 'min')\n", + "data_min = patient_summary(all_paths[2], 'min')\n", + "print(data_min)\n", "print(len(data_min))" ] }, @@ -228,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": { "id": "_svDiRkdIwiT" }, @@ -251,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": { "id": "LEYPM5v4JT0i" }, @@ -261,19 +417,27 @@ "\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", - "\n", - " return" + " a = check_zeros(patient_summary(file_path, 'mean')) # calling the function within function and assigning the result of check_zeros to a to return\n", + " return a" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 53, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], "source": [ "# Test out your code here\n", "# Your output for the first file should be False\n", - "print(detect_problems(all_paths[0]))" + "print(detect_problems(all_paths[7]))" ] }, { @@ -314,7 +478,8 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "python-env", + "language": "python", "name": "python3" }, "language_info": { @@ -327,7 +492,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.11.14" } }, "nbformat": 4, diff --git a/1_Functions.ipynb b/1_Functions.ipynb new file mode 100644 index 000000000..eb305b1b9 --- /dev/null +++ b/1_Functions.ipynb @@ -0,0 +1,214 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "id": "e8686024", + "metadata": {}, + "outputs": [], + "source": [ + "def divide(divident,divisor):\n", + " result = divident / divisor\n", + " return result\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "dca148b0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2.0" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "divide(10,5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "92d87af4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.65\n", + "0.4\n" + ] + } + ], + "source": [ + "# default value assignment\n", + "\n", + "def calc_sales_tax(price, tax_rate=0.13):\n", + " sales_tax = price * tax_rate\n", + " return sales_tax\n", + "\n", + "print(calc_sales_tax(5))\n", + "print(calc_sales_tax(5,0.08)) # this overrides the default value\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "16cb9446", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "256.0\n", + "262.0\n" + ] + } + ], + "source": [ + "# keyword arguments, position of the supplied parameters while calling the function is important\n", + "# docstring using 3 single quote \n", + "def calc_total_bill(price, tax_rate=0.13,tip_rate=0.15):\n", + " '''Calculate total bill with tax and tip'''\n", + " tax = price * tax_rate\n", + " tip = price * tip_rate\n", + " total = price + tax + tip\n", + " return total\n", + "\n", + "print(calc_total_bill(200))\n", + "\n", + "print(calc_total_bill(200,tip_rate=0.18)) # position of argument matter so kerword argument is used" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "8b5db084", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Help on function calc_total_bill in module __main__:\n", + "\n", + "calc_total_bill(price, tax_rate=0.13, tip_rate=0.15)\n", + " Calculate total bill with tax and tip\n", + "\n" + ] + } + ], + "source": [ + "# docstring - creating help text for functions\n", + "\n", + "help(calc_total_bill)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c127b2b6", + "metadata": {}, + "outputs": [], + "source": [ + "# variable scope\n", + "# variables within functions are local - only access it within that function and not outside\n", + "# You can explicitely define global variables within function using the keyword global" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "75086155", + "metadata": {}, + "outputs": [], + "source": [ + "def calc_total_bill(price, tax_rate=0.13, tip_rate=\"standard\"):\n", + "\n", + " tip_presets = {\n", + "\n", + " \"low\": 0.10,\n", + "\n", + " \"standard\": 0.15,\n", + "\n", + " \"high\": 0.20\n", + "\n", + " }\n", + "\n", + " \n", + "\n", + " # only convert if it's one of the known presets\n", + "\n", + " if tip_rate in tip_presets:\n", + "\n", + " tip_rate = tip_presets[tip_rate]\n", + "\n", + " \n", + "\n", + " tax = price * tax_rate\n", + "\n", + " tip = price * tip_rate\n", + "\n", + " total = price + tax + tip\n", + "\n", + " return total" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "4ce3079b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "50\n", + "51\n" + ] + } + ], + "source": [ + "# input function - always takes in value as string\n", + "\n", + "age = input('How old are you?')\n", + "\n", + "print(age)\n", + "\n", + "age_next_bday = (int(age) + 1)\n", + "print(age_next_bday)" + ] + } + ], + "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.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/2_Method.ipynb b/2_Method.ipynb new file mode 100644 index 000000000..7984fc760 --- /dev/null +++ b/2_Method.ipynb @@ -0,0 +1,238 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "b7d75098", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'I AM NOT YELLLING'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# method is a function that only works for a specific data type\n", + "# syntax is object.method_name(parameters)\n", + "# https://docs.python.org/3/library/stdtypes.html#string-methods\n", + "\n", + "\n", + "\"I am not yellling\".upper()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "eafa0878", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"this string is unusual\".count('e')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "23c7fbdc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'file_name.csv'.endswith('.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "707947f1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'long_file_name_with_spaces.csv'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'long file name with spaces.csv'.replace(' ','_')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "129be9c7", + "metadata": {}, + "outputs": [], + "source": [ + "first_name = 'Ada'\n", + "last_name = 'Lovelace'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "07e95144", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"Ada Lovelace's initials are A. L.\"" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# formating string methods\n", + "# .format() string method\n", + "\n", + "'Ada Lovelace\\'s initials are {}. {}.'.format(first_name[0], last_name[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "8a439816", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'My favourite day of the week is Monday.'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "day_of_week = 'Monday'\n", + "'My favourite day of the week is {}.'.format(day_of_week)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "7b2c4093", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"Ada Lovelace's initials are A. L.\"" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# f-string method\n", + "f'Ada Lovelace\\'s initials are {first_name[0]}. {last_name[0]}.'\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "5f6c3050", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'My favourite sport is soccer'" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "favourite_sport = 'soccer'\n", + "\n", + "f'My favourite sport is {favourite_sport}'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a3268d13", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# you can nest methods\n", + "'first_name'.upper().count('F') " + ] + } + ], + "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.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/3_Strings.ipynb b/3_Strings.ipynb new file mode 100644 index 000000000..ee5c82eb5 --- /dev/null +++ b/3_Strings.ipynb @@ -0,0 +1,174 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "36f2bfdb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Mashed Potatoes\n" + ] + } + ], + "source": [ + "# you can use double or single quotes to define string\n", + "\n", + "favourite_food = 'Mashed Potatoes'\n", + "print(favourite_food)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "356b9482", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "let's see if this works\n" + ] + } + ], + "source": [ + "a = \"let's see if this works\"\n", + "print(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "6804df00", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'I am a multiline string\\nI span over many\\nmany\\nmany\\nlines'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# multiline string can be assigned using 3 single/double quotes\n", + "# \\n in the result means new line, \\t tab, \\' single quote, \\\" double quote\n", + "'''I am a multiline string\n", + "I span over many\n", + "many\n", + "many\n", + "lines'''" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "94e77062", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "this is \t a tab\n" + ] + } + ], + "source": [ + "print(\"this is \\t a tab\")" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "ccfad329", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "this is \\ a backslash\n" + ] + } + ], + "source": [ + "print(\"this is \\\\ a backslash\")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "b9241c1e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "this is \" a double quote\n" + ] + } + ], + "source": [ + "print(\"this is \\\" a double quote\")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6b1f63c8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "listic\n" + ] + } + ], + "source": [ + "word1 = \"supercalifragilisticexpialidocious\"\n", + "\n", + "n = len(word1)\n", + "\n", + "middle6 = word1[n//2 - 3 : n//2 + 3]\n", + "\n", + "print(middle6)\n", + "\n", + "#long_word[int((len(long_word)/2))-3:int((len(long_word)/2))+3] \n", + "# Length = 34 letters,middle_letters = word[17-3 : 17+3]\n", + "#print(middle_letters)" + ] + } + ], + "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.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/4_operators.ipynb b/4_operators.ipynb new file mode 100644 index 000000000..2c8df08b2 --- /dev/null +++ b/4_operators.ipynb @@ -0,0 +1,201 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "67c28fb5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Logic operators\n", + "\n", + "# not : negate the truth value of the statement\n", + "\n", + "not True\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ce8810cc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not False" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "f1c29595", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not (3 == 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "260026c9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "False\n" + ] + } + ], + "source": [ + "# and operator - going to check if the statements on both sides are true\n", + "\n", + "# T T = T\n", + "# F T = F\n", + "# T F = F\n", + "# F F = F\n", + "\n", + "print(True and True)\n", + "print(False and True)\n", + "print(True and False)\n", + "print(False and False)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "862858ed", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(7 == 7.0) and (32 > 9)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "6a58995e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "False\n" + ] + } + ], + "source": [ + "# or operator checkes if one of the statements are true\n", + "\n", + "print(True or True)\n", + "print(False or True)\n", + "print(True or False)\n", + "print(False or False)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "8663bf6f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# in python 0 is considered false\n", + "0 == False" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6dd5c3f1", + "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.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/5_conditions.ipynb b/5_conditions.ipynb new file mode 100644 index 000000000..6ede638fb --- /dev/null +++ b/5_conditions.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "id": "a186d670", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "we are not in the 21st century.\n" + ] + } + ], + "source": [ + "year = 1990\n", + "output = 'yes'\n", + "\n", + "if year >= 2000 and output == 'yes': \n", + " print('we are in the 21st century.')\n", + "else:\n", + " print('we are not in the 21st century.')" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "05a061fa", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "we have gone way back in time\n" + ] + } + ], + "source": [ + "# elif - shortform of else if\n", + "\n", + "year = 1700\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": 9, + "id": "ee3a21e8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Weekday\n" + ] + } + ], + "source": [ + "day_of_week = 'Thursday'\n", + "\n", + "if day_of_week == 'Saturday' or day_of_week == 'Sunday':\n", + " print('Weekend')\n", + "else:\n", + " print('Weekday')" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "acdd2070", + "metadata": {}, + "outputs": [], + "source": [ + "def eye_exam_covered(age, qualifying_condition, time_since_last_exam):\n", + " # Assumptions:\n", + " # age is an integer\n", + " # Qualifying conditon is boolean - true if you have eligible medical condition\n", + " # time_since_last_exam integer, number of months since last examination\n", + "\n", + " if 0 <= age <= 19:\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 assessment\"\n", + " \n", + " elif 20 <= age <=64:\n", + " if qualifying_condition:\n", + " if time_since_last_exam >= 12:\n", + " return \"You are eligible for one major eye exam and 2 additional followup minor assessments\"\n", + " else:\n", + " return \"it has'nt been 12 months since your last eye exam, but you have follow-up minor assessement\"\n", + " else:\n", + " return 'You dont have an eligible medical condition'\n", + " \n", + " elif age >=65:\n", + " if time_since_last_exam >=18:\n", + " return \"You are eligible for 1 major eye exam and 2 followup minor assessment\"\n", + " else:\n", + " return \"It has not been 18 minths since your last eye exam\"\n", + "\n", + " else:\n", + " return \"Invalid age input\" \n", + "\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "10709b63", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You are eligible for 1 major eye exam and any minor assessments needed'" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(19,False,14)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "b7a7cf4e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"It hasn't been 12 months since your last major eye exam but you can have a minor assessment\"" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(15,True,3)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "21404b2d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You dont have an eligible medical condition'" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(23,False,10)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "ec054d5a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'It has not been 18 minths since your last eye exam'" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(65, True,10)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "26d502c8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You are eligible for one major eye exam and 2 additional followup minor assessments'" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(50,True,18)" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "4ff436ee", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Invalid age input'" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eye_exam_covered(-10,True, 10)" + ] + } + ], + "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.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/6_lists.ipynb b/6_lists.ipynb new file mode 100644 index 000000000..29491f2e2 --- /dev/null +++ b/6_lists.ipynb @@ -0,0 +1,290 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "36620364", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['a', 'e', 'i', 'o', 'u']" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vowels = ['a','e','i','o','u']\n", + "vowels" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "0afb256a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[90, 80, 82, 91, 81]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "score = [90,80,82,91,81]\n", + "score" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "be32c29f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['K', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" + ] + }, + "execution_count": 4, + "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": 5, + "id": "a8dc45c3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[,\n", + " ,\n", + " ,\n", + " ]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "summary_functions = [len,sum,max,min]\n", + "summary_functions" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "abb1273d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[]\n", + "[]\n" + ] + } + ], + "source": [ + "empty_list = []\n", + "\n", + "empty_list_2 = list()\n", + "\n", + "print(empty_list)\n", + "print(empty_list_2)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "924e5687", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[['Sherlock', 'Watson'], ['Scooby', 'Shaggy', 'Fred'], 'Nancy Drew']" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# list within a list\n", + "\n", + "mystery_solvers = [['Sherlock','Watson'],\n", + " ['Scooby','Shaggy','Fred'],\n", + " 'Nancy Drew']\n", + "mystery_solvers" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "a83b6c68", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['a', 'e', 'i', 'o', 'u']\n", + "a\n", + "['e', 'i']\n", + "o\n" + ] + } + ], + "source": [ + "# we can slice lists or access list items using index\n", + "\n", + "print(vowels)\n", + "print(vowels[0])\n", + "print(vowels[1:3])\n", + "print(vowels[-2])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "b1386b9d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 4, 9, 16, 15, 100, 49]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# lists are mutable - so you can change the value in a list\n", + "\n", + "perfect_squares = [1,4,9,16,15,30,49]\n", + "\n", + "perfect_squares[5] = 100\n", + "\n", + "perfect_squares" + ] + }, + { + "cell_type": "markdown", + "id": "60bc4b0a", + "metadata": {}, + "source": [ + "Immutable: Can't be changed after creation. \n", + "\n", + "Examples: int, float, str. \n", + "\n", + "In memory: Reassignment creates a new object. Original stays unchanged.\n", + "\n", + "Mutable: Can be changed in place. \n", + "\n", + "Examples: list. \n", + "\n", + "In memory: Changes affect the same object, changes affect all references to the object." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "a05a0b19", + "metadata": {}, + "outputs": [], + "source": [ + "combo = ['burger', 'fries', 'drink']\n", + "kid_meal = list(combo)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "14970692", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['chicken sandwich', 'fries', 'drink']\n", + "['burger', 'fries', 'drink']\n" + ] + } + ], + "source": [ + "combo[0] = 'chicken sandwich'\n", + "print(combo)\n", + "print(kid_meal)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "254f9e4a", + "metadata": {}, + "outputs": [], + "source": [ + "# list operations\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7aa555fd", + "metadata": {}, + "outputs": [], + "source": [ + "# list methods" + ] + } + ], + "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.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}