{
 "nbformat": 4,
 "nbformat_minor": 5,
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.x"
  },
  "colab": {
   "provenance": []
  }
 },
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Lab 1 — Hello, Colab 👋\n",
    "### CIS 350: AI for Cybersecurity — Smart Defense for the Digital Business\n",
    "\n",
    "**Worth:** 50 points  ·  **Time:** ~45–60 minutes  ·  **Submit:** this `.ipynb` file in Canvas\n",
    "\n",
    "Welcome to your first lab! No coding experience is needed — every step is guided. You'll run Python in Google Colab and use it to explore a small (made-up) list of leaked passwords, just like a security analyst would.\n",
    "\n",
    "**What you'll do**\n",
    "1. Run your first Python cell.\n",
    "2. Load a small leaked-password dataset with pandas.\n",
    "3. Find the most common passwords.\n",
    "4. Measure how many are weak (too short).\n",
    "5. Make a simple chart and interpret the results.\n",
    "\n",
    "**How to run a cell:** click it, then press **Shift + Enter**. Run the cells in order from top to bottom. Look for **`TODO`** comments — that's where you fill in the blank (`____`).\n",
    "\n",
    "> **Academic integrity:** This is individual or pair work. **AI tools (ChatGPT, Claude, Copilot, etc.) are not permitted** on labs — the code and answers must be your own."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 0 · Run your first cell\n",
    "Click the cell below and press **Shift + Enter**."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "# Press Shift+Enter to run this cell.\n",
    "print(\"Hello, Colab! I am running Python.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 1 · Load the leaked-password dataset\n",
    "We'll use a small, **fictional** list of passwords from a pretend breach (no real data). Run the cell, then fill in **TODO 1**."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "# A small (fictional) list of passwords from a pretend data breach.\n",
    "leaked_passwords = [\n",
    "    \"123456\", \"123456\", \"123456\", \"123456\", \"123456\", \"123456\",\n",
    "    \"password\", \"password\", \"password\", \"password\", \"password\",\n",
    "    \"qwerty\", \"qwerty\", \"qwerty\", \"qwerty\",\n",
    "    \"111111\", \"111111\", \"111111\",\n",
    "    \"abc123\", \"abc123\", \"abc123\",\n",
    "    \"iloveyou\", \"iloveyou\",\n",
    "    \"admin\", \"admin\",\n",
    "    \"letmein\", \"letmein\",\n",
    "    \"monkey\", \"dragon\", \"sunshine\", \"football\", \"welcome\",\n",
    "    \"G7$kLm9!pQ2\", \"Tr0ub4dour&3\", \"correcthorsebatterystaple\",\n",
    "]\n",
    "\n",
    "# Put the list into a pandas Series (think: one spreadsheet column).\n",
    "passwords = pd.Series(leaked_passwords)\n",
    "\n",
    "# TODO 1: print how many passwords are in the dataset.\n",
    "# Hint: len(passwords)\n",
    "print(\"Total passwords:\", ____)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 2 · Which passwords are most common?\n",
    "`value_counts()` counts how often each value appears."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "# TODO 2: count each password and show the top 10.\n",
    "# Hint: replace the blank with the value_counts method.\n",
    "counts = passwords.____\n",
    "print(counts.head(10))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 3 · How many passwords are *weak*?\n",
    "A quick proxy: passwords **shorter than 8 characters** are easy to crack. (Real weakness is more than length — but this is a good start.)"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "# A True/False value for each password: is it shorter than 8 chars?\n",
    "is_short = passwords.str.len() < 8\n",
    "\n",
    "# TODO 3a: count how many passwords are short (weak).\n",
    "# Hint: is_short.sum()\n",
    "weak_count = ____\n",
    "\n",
    "# TODO 3b: what percent of all passwords are weak? (0-100)\n",
    "# Hint: weak_count / len(passwords) * 100\n",
    "weak_percent = ____\n",
    "\n",
    "print(\"Weak (< 8 chars):\", weak_count)\n",
    "print(\"Percent weak: {:.1f}%\".format(weak_percent))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 4 · Picture it — a bar chart\n",
    "Charts make patterns obvious. Run the cell and finish **TODO 4**."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "top10 = passwords.value_counts().head(10)\n",
    "\n",
    "plt.figure(figsize=(8, 4))\n",
    "top10.plot(kind=\"bar\", color=\"#1E4D2B\")\n",
    "# TODO 4: give your chart a clear title (put text in the quotes).\n",
    "plt.title(\"\")\n",
    "plt.xlabel(\"Password\")\n",
    "plt.ylabel(\"Times seen in the breach\")\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 5 · What does it mean? (Guided questions)\n",
    "Double-click the cell below to edit it, and replace each *your answer here* with your response."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Your answers** — replace the italics.\n",
    "\n",
    "1. **Most common password and how many times it appears:** *your answer here*\n",
    "2. **Percent of passwords shorter than 8 characters:** *your answer here*\n",
    "3. **Why are passwords like these dangerous?** (2–3 sentences) *your answer here*\n",
    "4. **Two things a business could do to reduce weak passwords:** *your answer here*\n",
    "5. **Which CIA-triad goal do weak passwords most threaten, and why?** *your answer here*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ✅ Before you submit\n",
    "\n",
    "- [ ] Click **Runtime → Run all** — every cell runs with no errors.\n",
    "- [ ] All `TODO` blanks (`____`) are filled in.\n",
    "- [ ] You answered all 5 guided questions above.\n",
    "- [ ] **File → Download → Download .ipynb**, then upload it to Canvas.\n",
    "\n",
    "If you worked in a pair, put **both names** in the cell at the top and make sure both of you understand every step."
   ]
  }
 ]
}