{ "cells": [ { "cell_type": "markdown", "id": "09d7b732", "metadata": {}, "source": [ "# Homework 5" ] }, { "cell_type": "markdown", "id": "6217bd91-a129-4614-9630-fd21c58a579b", "metadata": {}, "source": [ "- Due Date: Friday, February 27th -- no later than 11:59 p.m.\n", "- Partner Information: You may complete this assignment individually or with exactly one classmate.\n", "- Submission Instructions (working alone): Upload your solution, entitled **YourFirstName-YourLastName-Assignment5.ipynb** to the \n", "Canvas Assignment 5 Dropbox.\n", "- Submission Instructions (working with one classmate): Upload your solution, entitled \n", "**YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Assignment5.ipynb** to the Canvas Assignment 5 Dropbox. Note: If you \n", "work with a partner, only one person needs to submit a solution. If you both submit a solution, the submission that will be graded is the one \n", "from the partner whose last name comes alphabetically first.\n", "- Deadline Reminder: Once the submission deadline passes, Canvas 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." ] }, { "cell_type": "markdown", "id": "96e67964", "metadata": {}, "source": [ "# Starting Code" ] }, { "cell_type": "code", "execution_count": null, "id": "eb7a773d-1e75-42e5-9560-350dbe7821f0", "metadata": {}, "outputs": [], "source": [ "from datascience import *\n", "import numpy as np\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "id": "e717598b", "metadata": {}, "outputs": [], "source": [ "# Place the csv file in the same directory as your solution\n", "file_path = \"1980sClassics.csv\"\n", "classics = Table.read_table(file_path)\n", "classics.show(5)" ] }, { "cell_type": "markdown", "id": "d0765612-7c7b-4e43-90cb-70f67b0ec950", "metadata": {}, "source": [ "## Question 1a (2 points)\n", "\n", "Identify the 10 most popular artists in this dataset. Specifically, in descending order, display the 10 artists \n", "with the highest number of songs and visualize this distribution using a bar chart. *Hint: Madonna was the \n", "most popular artist in the 1980s and should appear at the top of the bar chart.*" ] }, { "cell_type": "code", "execution_count": null, "id": "17760d43-40b9-41ac-8ca8-ac67e7c1b74b", "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "id": "b5ebb8c1-8a01-422c-8a81-db8d8937fa70", "metadata": {}, "source": [ "## Question 1b (3 points).\n", "\n", "For the 10 most popular artists of Question 1a, display a table with two columns: \"Artist\"\n", "and \"Average Popularity\". The \"Average Popularity\" should display 1 significant digit to the\n", "right of the decimal and be sorted in descending order by the highest average popularity. \n", "*Hint: The average popularity of Madonna's songs is 65.1*" ] }, { "cell_type": "code", "execution_count": null, "id": "4c03e45d-1155-44eb-8d5c-7f2339a01a72", "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "id": "bf280bc0-1e63-4868-b381-f65412d8b3da", "metadata": {}, "source": [ "## Question 2a (1 point)\n", "\n", "Display the average popularity of all songs in the entire data set in the following format:\n", "\n", "*Average song popularity of all songs = dd.d*" ] }, { "cell_type": "code", "execution_count": null, "id": "09200796-69ef-4538-b11e-dbe7b4c501d7", "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "id": "0ff7f0cf-b1bb-470d-96c0-eebe7d4f46a2", "metadata": {}, "source": [ "## Question 2b (3 points)\n", "\n", "Randomly sample 25 song popularities from the entire dataset with replacement 500 times. Display a histogram \n", "with the default bins that show the resulting 500 popularity averages. Repeat the experiment but this time randomly sample 250\n", "song popularities with replacement. Use a function to avoid duplicating similar code." ] }, { "cell_type": "code", "execution_count": null, "id": "6c2cf6fa-44c8-41d0-a005-e16e644b3ba9", "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "id": "82124a9b-e7aa-411e-b484-d21e1b1fb3f4", "metadata": {}, "source": [ "## Question 2c (1 point)\n", "\n", "Carefully describe the differences between the two histograms and the cause of\n", "those differences." ] }, { "cell_type": "markdown", "id": "a862f10e-9f16-4c6c-befb-a5f04a2a7b1c", "metadata": {}, "source": [ "**Answer:**" ] } ], "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.14.2" } }, "nbformat": 4, "nbformat_minor": 5 }