{ "cells": [ { "cell_type": "markdown", "id": "6222aa57-6370-469d-9031-8f8bc1775716", "metadata": {}, "source": [ "# Homework 1 - Chapter 6" ] }, { "cell_type": "markdown", "id": "6c8c39c6-9ffb-4983-b63e-23f836970379", "metadata": {}, "source": [ "- Due Date: Wednesday, September 3rd no later than 11:59 p.m.\n", "- Partner Information: Complete this assignment individually.\n", "- Submission Instructions: Upload your solution, entitled **YourFirstName-YourLastName-Homework1.ipynb** to the the appropriate Canvas DropBox.\n", "- Deadline Reminder: Once the submission deadline passes, BrightSpace will no longer accept your submission and you will no longer be able to earn credit. \n", "Thus, if you are not able to fully complete the assignment, submit whatever you have before the deadline so that partial credit can be earned.\n" ] }, { "cell_type": "markdown", "id": "3ab7a42d-d467-4094-a8c5-eaf374d93eaa", "metadata": {}, "source": [ "## Data File and Starting Code" ] }, { "cell_type": "markdown", "id": "695fccba-3491-4519-b87c-e01b19ed2a9c", "metadata": {}, "source": [ "Data File: Download this modified Kaggle [Dogs of Zurich](https://www.cs.montana.edu/paxton/classes/fall-2025/intro-ds/homeworks/hw1/dogs-of-zurich.csv) csv file and place it in\n", "the same directory as your Jupyter notebook." ] }, { "cell_type": "code", "execution_count": null, "id": "507f86cd-c05b-4614-aedb-c07fd3707d43", "metadata": {}, "outputs": [], "source": [ "from datascience import *" ] }, { "cell_type": "code", "execution_count": null, "id": "a08087ae-0322-4986-94ba-c1adc1dba856", "metadata": {}, "outputs": [], "source": [ "# Read in the file that contains information about dogs and their owners in Zurich\n", "original_dogs = Table().read_table(\"dogs-of-zurich.csv\")\n", "original_dogs" ] }, { "cell_type": "code", "execution_count": null, "id": "e4ad168c-eaf4-4831-84d6-0fd8d4ca3bd9", "metadata": {}, "outputs": [], "source": [ "# Convert german gender markers to english ones\n", "def german_to_english(ch):\n", " if ch == \"m\":\n", " return \"male\"\n", " elif ch == \"w\":\n", " return \"female\"\n", " else:\n", " return \"unknown\"" ] }, { "cell_type": "code", "execution_count": null, "id": "234cb9c2-5489-4481-ad70-c3b436f1975b", "metadata": {}, "outputs": [], "source": [ "# Do some simple data cleaning to make the Table data more understandable.\n", "dogs = original_dogs.with_column(\"Owner-Gender\", original_dogs.apply(german_to_english, \"Owner-Gender\"))\n", "dogs = dogs.with_column(\"Dog-Gender\", dogs.apply(german_to_english, \"Dog-Gender\"))\n", "dogs.show(3)" ] }, { "cell_type": "markdown", "id": "953488a9-0828-49aa-afad-6730b42fc2db", "metadata": {}, "source": [ "## Question 1 - 1 point" ] }, { "cell_type": "markdown", "id": "5d3db18d-24cf-4a14-8195-33d70628bacc", "metadata": {}, "source": [ "Determine the number of dogs in the data set. Print the answer in the following format: \n", "\n", "*The number of dogs in the data set = ???*" ] }, { "cell_type": "code", "execution_count": null, "id": "b24b0b34-2dba-44c6-9a91-d1670677e7d7", "metadata": {}, "outputs": [], "source": [ "# Place your answer to Question 1 here." ] }, { "cell_type": "markdown", "id": "bf8a3c3d-4406-4cd8-a6f2-fe62e4fcee7d", "metadata": {}, "source": [ "## Question 2 - 2 points" ] }, { "cell_type": "markdown", "id": "88b886b7-2cc6-4832-aaef-6087bf7c10d5", "metadata": {}, "source": [ "Determine the percentage of dog owners between 21 and 30. Print the answer in the following format: \n", "\n", "*The percentage of dog owners between 21 and 30 = dd.dd%*" ] }, { "cell_type": "code", "execution_count": null, "id": "da385568-62fc-4496-8dd3-7071f484e9ee", "metadata": {}, "outputs": [], "source": [ "# Place your answer to Question 2 here." ] }, { "cell_type": "markdown", "id": "d4f43948-131c-47eb-a47b-d179554675be", "metadata": {}, "source": [ "## Question 3 - 3 points" ] }, { "cell_type": "markdown", "id": "2e9ec839-e21e-4666-8f2c-f4a2478eb278", "metadata": {}, "source": [ "Determine (1) the percentage of male dog owners, (2) the percentage of male dog owners who own female dogs and\n", "(3) the percentage of female dog owners who own female dogs. Print the answer in the following format: \n", "\n", "*The percentage of male dog owners = dd.dd%* \n", "*The percentage of male dog owners who own female dogs = dd.dd%* \n", "*The percentage of female dog owners who own female dogs = dd.dd%*" ] }, { "cell_type": "code", "execution_count": null, "id": "f6e85044-d0bb-4676-855c-2e51cb358647", "metadata": {}, "outputs": [], "source": [ "# Place your answer to Question 3 here." ] }, { "cell_type": "markdown", "id": "2d9624fe-eacd-4b6f-ac52-9af177cbc485", "metadata": {}, "source": [ "## Question 4 - 2 points" ] }, { "cell_type": "markdown", "id": "f7909a3f-e18e-46e4-bbbd-a92bea102e0b", "metadata": {}, "source": [ "Determine the percentage of dogs whose color contains brown (in german, brown is braun).\n", "Print the answer in the following format: \n", "\n", "*The percentage of dogs whose color includes brown = dd.dd%*" ] }, { "cell_type": "code", "execution_count": null, "id": "9c27a2da-718a-4bcf-bd16-35e3703b5386", "metadata": {}, "outputs": [], "source": [ "# Place your answer to Question 4 here." ] }, { "cell_type": "markdown", "id": "d33b208b-7c86-4de7-b21e-8c3baeb8b09b", "metadata": {}, "source": [ "## Question 5 - 2 points" ] }, { "cell_type": "markdown", "id": "62444f4d-efcf-4b80-80c0-5fccea153496", "metadata": {}, "source": [ "Create a table with 3 columns: Owner-Age, Number and Percentage.\n", "The table should contain one row for each of the possible Owner-Age\n", "values (e.g. 11-20, ..., 91-100). The table should be sorted so that the most\n", "common Owner-Age appears in the top data row and the least common Owner-Age appears\n", "in the bottom row. \n", "\n", "Hint: If this problem is solved correctly, the first two rows of the table should look like this:" ] }, { "attachments": { "f0bce0de-2c47-4021-83f2-c701d79e7054.png": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAANsAAAA7CAYAAADyx//CAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAlkSURBVHhe7Z1BiupMEMf/7ztIQIWRnELzdiIOOYMuxJ2I4BUMDOJOXHgGw4i4e5lTGCKYRS6Sb9HdSXcncTSjGd+8+oEwdmJSXd3VVV0DXb/iOI5BEMTD+U9vIAjiMZCxEURFkLERREWQsRFERZCxEURFkLERREWQsRFERZCxEURFkLERREV8ydjcQR31uvQZuPotz4c7SORtO75+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fHn2FsUI+X/kp05+48NPAuhRsi9PQRnA0o5QmaLzDE+ft/Gd5E75/AhzM6oLOasaIcefgOlmfpmPmHwPR93RH1Ah/vB+AlkELewhAwwCmSKhp5O66HACe8oOk7GJ3GuYtuWX6Gsdkb5fz+8+SzmL4IVmDCOwAr/rz98IzJwJXq0knkVtt5fuTCI/vhGRNpQrqDLg4dqchlDu7bGuDHyT8Kd9DFujG+KEeWAKcowvrUS/q3aOTVvPPhtCc4D6fca9mYDs9JdSOMX/E+OmG8Qbr3KzTa6/kZxiZjzrAaIlPO6hbSUJGXjfJ2cPPKCd2rmsw3Ys5WGILXqHMHmGDxyVHrLnaehfHFe74CS27semWr5hgYSi7X7mmhvu+gXR8Bq1DpJwu7mYFOgxEOnSkwmACL1Gj1WpK38vOMTatgeRv5dcpSeIwvCE6IRA20vxbhsX04S08Jxycer2Qjx+XuDt5DarOBG9oOvStKQ+WTsyDK+A7aI2CVKU0lwferqxmUbYPds6T9Y0n0jMnfSHGWSeLa7Nm2H9ek+7b9WprNy8lG5mYtn4hjJhu5jfvS9+O8JfVJZdvPZiO3/cf1+bpnZ7ONspxqf+SM8TGet3LmhYJ6jyzPdbJd5od4trRUbL17QEepXnkj9obtY8TqjkUaztgbLBppTbOirOXTI3mv7qGD/dWFAV3sPC1JdDf4fjlJ3JTbK5mzj8wYsXCR7+fkem919X+QvjNS9qv2ZgFweSZYfHms6cAfgqiIf9bY3EFOnWZL8mIEcWf+WWMjiKr5IXs2gnh+yNgIoiLI2AiiIsjYCKIiyNgIoiL+BwI9/MIsWAo1AAAAAElFTkSuQmCC" } }, "cell_type": "markdown", "id": "f4dfc58b-da91-452c-808e-41b99e8b0678", "metadata": {}, "source": [ "![Screenshot 2025-08-22 162931.png](attachment:f0bce0de-2c47-4021-83f2-c701d79e7054.png)" ] }, { "cell_type": "code", "execution_count": null, "id": "6772cf76-e997-4449-8814-ea5e1b68e6ff", "metadata": {}, "outputs": [], "source": [ "# Place your answer to Question 5 here." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.13.7" } }, "nbformat": 4, "nbformat_minor": 5 }