{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a1b2c3d4",
   "metadata": {},
   "source": [
    "# Ch07 Homework"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2c3d4e5",
   "metadata": {},
   "source": [
    "## Problem 1 — Word Frequency\n",
    "\n",
    "Write a function `word_freq(text)` that takes a string and returns a dictionary mapping each word (lowercased, stripped of punctuation) to the number of times it appears.\n",
    "\n",
    "Test it on: `\"To be or not to be that is the question\"`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c3d4e5f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Your solution here\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4e5f6a7",
   "metadata": {},
   "source": [
    "## Problem 2 — Dictionary Lookup\n",
    "\n",
    "Given this dictionary of course rosters:\n",
    "\n",
    "```python\n",
    "rosters = {\n",
    "    'CS101': ['alice', 'bob', 'carol', 'dave'],\n",
    "    'DS201': ['bob', 'carol', 'eve', 'frank'],\n",
    "}\n",
    "```\n",
    "\n",
    "Write code that builds a dictionary mapping each student name to the list of courses they are enrolled in."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e5f6a7b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Your solution here\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6a7b8c9",
   "metadata": {},
   "source": [
    "## Problem 3 — defaultdict Grouping\n",
    "\n",
    "Given a list of `(city, temperature)` tuples, use `defaultdict(list)` to group temperatures by city, then compute the average temperature per city."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a7b8c9d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "readings = [\n",
    "    ('Rolla', 72), ('Springfield', 68), ('Rolla', 78),\n",
    "    ('KC', 85), ('Springfield', 71), ('KC', 82), ('Rolla', 69),\n",
    "]\n",
    "\n",
    "# Your solution here\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.11.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
