{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Practicum 1 - February 14, 2025" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Due Date: Thursday, February 14th no later than 10:50 a.m.\n", "- Submission Instructions: Upload your solution, entitled **YourFirstName-YourLastName-Practicum1.ipynb** to the \n", "BrightSpace Practicum 1 Dropbox.\n", "- Note: For all questions, determine the answer using python constructs (as opposed to eyeballing the csv file)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Starting Code" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from datascience import *\n", "%matplotlib inline\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data File" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The stock symbol for Southwest Airlines is LUV. Since it is Valentine's Day, your are going to\n", "use your Data Science skills to study LUV! \n", "Download [luv.csv](https://www.cs.montana.edu/paxton/classes/spring-2025/intro-ds/practicums/practicum1/luv.csv)\n", "and place it in the same directory as your Jupyter notebook. The file contains one year's worth of recent\n", "information about Southwest Airline's stock." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Place the csv file in the same directory as this notebook\n", "luv = Table().read_table(\"luv.csv\")\n", "luv.show(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1 - 10 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the highest value that Southwest Airline's stock reached. For full credit, do not display a table, only display\n", "the amount as a number with 2 significant digits to the right of the decimal, e.g. 30.32 " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 2 - 20 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add a column named \"% Change\" that displays the percentage change of the stock's closing price in\n", "comparison to its opening price. Display a table that shows just the \"Date\" and \"% Change\" information of the 7 days where the \n", "\"% Change\" has the highest gains. The \"% Change\" column should be formatted to display percentages, e.g. **1.03%**\n", "or **-2.45%**." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 3 - 20 Points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display an overlaid line graph that plots both \"Date\" / \"High\" and \"Date\" / \"Low\" combinations for every 25th entry \n", "in the original data set starting with the first data point. Thus the graph will contain entry 0, entry 25, etc. \n", "Do not be concerned that the x-axis dates might look messy." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 4 - 10 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display a histogram that shows how many times that \"High\" appears in the following buckets:\n", "[24, 26), [26, 28), [28, 30), [30, 32), [32, 34), [34, 36), [36, 38)." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 5 - 10 points" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "def classify_day(opening_price, closing_price):\n", " if closing_price >= opening_price:\n", " return \"Up Day\"\n", " else:\n", " return \"Down Day\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The *classify_day* function compares a stock's opening price with its closing price and returns\n", "whether the day was an \"Up Day\" or a \"Down Day\". Add a column named **Day Type**\n", "to the luv table that contains this information. Display the most recent 5 entries of the table (the\n", "most recent entry is 2/12/2025)." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 6 - 10 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Write a function named *classify_stock_movement* that when provided with the percent change (\"% Change\") of an \n", "entry in the luv table, returns \"Big Move\" if the the stock price changed by at least 2% (up or down), \n", "\"Medium Move\" if the price changed by at least 1% (up or down) and \"Small Move\" otherwise." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# Place answer here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 7 - 10 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add a column named **Movement Type** to the luv table that contains the information from Question 6. \n", "Display the most recent 5 entries of the table." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 8 - 10 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display a pivot table that shows how many times each combination of\n", "**Day Type** and **Movement Type** occurred. The values for \"Movement Type\"\n", "should be the column labels." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Place answer 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.1" } }, "nbformat": 4, "nbformat_minor": 4 }