From 80d3e36f8cc7cb39f617aab8c04e05ea609b9286 Mon Sep 17 00:00:00 2001 From: Andy Kuemmel <kuemmel@wisc.edu> Date: Wed, 26 Oct 2022 09:58:34 -0500 Subject: [PATCH] Update f22/andy_lec_notes/lec21_Oct26_Copying/lec21_copying_template.ipynb --- .../lec21_copying_template.ipynb | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/f22/andy_lec_notes/lec21_Oct26_Copying/lec21_copying_template.ipynb b/f22/andy_lec_notes/lec21_Oct26_Copying/lec21_copying_template.ipynb index 217afb5..0cc0433 100644 --- a/f22/andy_lec_notes/lec21_Oct26_Copying/lec21_copying_template.ipynb +++ b/f22/andy_lec_notes/lec21_Oct26_Copying/lec21_copying_template.ipynb @@ -22,24 +22,13 @@ "metadata": {}, "outputs": [], "source": [ - "college_dict = {\n", - " \"UW\": {'name': \"University of Wisconsin\", 'type':'public', 'year': 1850, 'enrollment': 35474 },\n", - " \"MI\": {'name': \"University of Michigan\", 'type':'public', 'year': 1817, 'enrollment': 44718 },\n", - " \"MU\": {'name': \"Marquette University\", 'type':'private', 'year': 1881, 'enrollment': 11294 },\n", - " \"EDG\": {'name': \"Edgewood College\", 'type':'private', 'year': 1927, 'enrollment': 2650 },\n", - " }\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Warmup 1: What is the name of the university that is the oldest?\n", + "# Warmup 1: determine the key that has the highest value in a dict\n", "\n", - "oldest_name = None\n", - "year_founded = None\n" + "# which dog is the oldest?\n", + "dog_dict = {\"Miles\": 2, \"Gertie\": 4, \"Sammy\": 11, \"Fido\": 3, \"Jordy\": 5}\n", + "oldest_dog = None\n", + "max_age = 0\n", + "\n" ] }, { @@ -48,12 +37,12 @@ "metadata": {}, "outputs": [], "source": [ - "#Warmup 2: using one dict to make a new dict\n", - "\n", - "# let's make a new dictionary of the total enrollment by type\n", - "# key is the type, value is the total enrollment for that type\n", - "\n", - "enrollment_by_type_dict = {}" + "#Warmup 2: Which dog is the oldest?\n", + "dog_list = [ {'id': 34523, 'name': \"Miles\", 'age': 2},\n", + " {'id': 22334, 'name': \"Gertie\", 'age': 4},\n", + " {'id': 87654, 'name': \"Fido\", 'age': 3'} ]\n", + "oldest_dog = None\n", + "max_age = 0 " ] }, { -- GitLab