Homework 2 : Data Collection

 ## Notebook Presentation [6 points ]
# For web and html
import requests
from time import sleep
from bs4 import BeautifulSoup

#For working with raw files
import zipfile

#For working with data
import pandas as pd
from datetime import datetime

Problem 1 : What’s the secret code? [ 4 points ]

Q 1. Use the library we learned in class to get the page’s HTML. [ 1 point ]. See 2:36 in the Solutions Video

BONUS_URL = "https://csc380.beingenfa.com/Bonus/1.html"
bonus_req_obj = requests.get(BONUS_URL)
bonus_req_obj
<Response [200]>
bonus_page_html = bonus_req_obj.text
bonus_page_html
'<!DOCTYPE html>\n<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>\n\n<meta charset="utf-8">\n<meta name="generator" content="quarto-1.3.361">\n\n<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">\n\n\n<title>CSC 380 – quarto-inputa5805b45</title>\n<style>\ncode{white-space: pre-wrap;}\nspan.smallcaps{font-variant: small-caps;}\ndiv.columns{display: flex; gap: min(4vw, 1.5em);}\ndiv.column{flex: auto; overflow-x: auto;}\ndiv.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}\nul.task-list{list-style: none;}\nul.task-list li input[type="checkbox"] {\n  width: 0.8em;\n  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ \n  vertical-align: middle;\n}\n</style>\n\n\n<script src="../site_libs/quarto-nav/quarto-nav.js"></script>\n<script src="../site_libs/quarto-nav/headroom.min.js"></script>\n<script src="../site_libs/clipboard/clipboard.min.js"></script>\n<script src="../site_libs/quarto-search/autocomplete.umd.js"></script>\n<script src="../site_libs/quarto-search/fuse.min.js"></script>\n<script src="../site_libs/quarto-search/quarto-search.js"></script>\n<meta name="quarto:offset" content="../">\n<script src="../site_libs/quarto-html/quarto.js"></script>\n<script src="../site_libs/quarto-html/popper.min.js"></script>\n<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>\n<script src="../site_libs/quarto-html/anchor.min.js"></script>\n<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">\n<link href="../site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">\n<script src="../site_libs/bootstrap/bootstrap.min.js"></script>\n<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">\n<link href="../site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">\n<script id="quarto-search-options" type="application/json">{\n  "location": "sidebar",\n  "copy-button": false,\n  "collapse-after": 3,\n  "panel-placement": "start",\n  "type": "textbox",\n  "limit": 20,\n  "language": {\n    "search-no-results-text": "No results",\n    "search-matching-documents-text": "matching documents",\n    "search-copy-link-title": "Copy link to search",\n    "search-hide-matches-text": "Hide additional matches",\n    "search-more-match-text": "more match in this document",\n    "search-more-matches-text": "more matches in this document",\n    "search-clear-button-title": "Clear",\n    "search-detached-cancel-button-title": "Cancel",\n    "search-submit-button-title": "Submit",\n    "search-label": "Search"\n  }\n}</script>\n\n\n<link rel="stylesheet" href="../styles.css">\n</head>\n\n<body class="nav-sidebar docked">\n\n<div id="quarto-search-results"></div>\n  <header id="quarto-header" class="headroom fixed-top">\n  <nav class="quarto-secondary-nav">\n    <div class="container-fluid d-flex">\n      <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">\n        <i class="bi bi-layout-text-sidebar-reverse"></i>\n      </button>\n      <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item">\n      CSC 380\n      </li></ol></nav>\n      <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">      \n      </a>\n      <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">\n        <i class="bi bi-search"></i>\n      </button>\n    </div>\n  </nav>\n</header>\n<!-- content -->\n<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">\n<!-- sidebar -->\n  <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation docked overflow-auto">\n    <div class="pt-lg-2 mt-2 text-left sidebar-header">\n    <div class="sidebar-title mb-0 py-0">\n      <a href="../">CSC 380</a> \n    </div>\n      </div>\n        <div class="mt-2 flex-shrink-0 align-items-center">\n        <div class="sidebar-search">\n        <div id="quarto-search" class="" title="Search"></div>\n        </div>\n        </div>\n    <div class="sidebar-menu-container"> \n    <ul class="list-unstyled mt-1">\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true">\n <span class="menu-text">Course Content</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Course_Content/Week_1/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Week 1</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Course_Content/Week_2/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Week 2</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Course_Content/Week_3/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Week 3</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Course_Content/Week_4&amp;5/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Week 4 &amp; 5</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true">\n <span class="menu-text">Homework</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Homework/1/HW.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">HW1: Probability</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Homework/2/HW.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">HW2: Data Collection</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true">\n <span class="menu-text">Ethics Discussions</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_2.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W2: Political Content</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_3.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W3: Creative Work</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_4.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W4: Mental Health Support</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_6.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W6: Recommendations</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_7.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W7: Autonomous Driving</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_8.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W8: Housekeeping</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Ethics/Week_9.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">W9: Facial Recognition</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="true">\n <span class="menu-text">Bonus Questions</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-4" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Bonus/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Home</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-5" aria-expanded="true">\n <span class="menu-text">Participation</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-5" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-5" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Participation_Activities/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Home</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-6" aria-expanded="true">\n <span class="menu-text">Honors</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-6" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-6" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Honors/home.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Assignments</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n        <li class="sidebar-item sidebar-item-section">\n      <div class="sidebar-item-container"> \n            <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="true">\n <span class="menu-text">Syllabus</span></a>\n          <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="true" aria-label="Toggle section">\n            <i class="bi bi-chevron-right ms-2"></i>\n          </a> \n      </div>\n      <ul id="quarto-sidebar-section-7" class="collapse list-unstyled sidebar-section depth1 show">  \n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Syllabus/Key_Info.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Key Info</span></a>\n  </div>\n</li>\n          <li class="sidebar-item">\n  <div class="sidebar-item-container"> \n  <a href="../Syllabus/Syllabus.html" class="sidebar-item-text sidebar-link">\n <span class="menu-text">Official Syllabus</span></a>\n  </div>\n</li>\n      </ul>\n  </li>\n    </ul>\n    </div>\n</nav>\n<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>\n<!-- margin-sidebar -->\n    <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">\n        <nav id="TOC" role="doc-toc" class="toc-active">\n    <h2 id="toc-title">On this page</h2>\n   \n  <ul>\n  <li><a href="#sonams-dilemma---a-gift-for-few-or-a-chance-for-all" id="toc-sonams-dilemma---a-gift-for-few-or-a-chance-for-all" class="nav-link active" data-scroll-target="#sonams-dilemma---a-gift-for-few-or-a-chance-for-all">Sonam’s Dilemma - A Gift for Few or a Chance for All</a>\n  <ul class="collapse">\n  <li><a href="#instructions" id="toc-instructions" class="nav-link" data-scroll-target="#instructions">Instructions</a></li>\n  <li><a href="#question" id="toc-question" class="nav-link" data-scroll-target="#question">Question</a></li>\n  </ul></li>\n  </ul>\n</nav>\n    </div>\n<!-- main -->\n<main class="content" id="quarto-document-content">\n\n\n\n<section id="sonams-dilemma---a-gift-for-few-or-a-chance-for-all" class="level1">\n<h1>Sonam’s Dilemma - A Gift for Few or a Chance for All</h1>\n<section id="bonus-question-1-point" class="level6">\n<h6 class="anchored" data-anchor-id="bonus-question-1-point">Bonus Question : 1 point</h6>\n<p><br></p>\n</section>\n<section id="instructions" class="level3">\n<h3 class="anchored" data-anchor-id="instructions">Instructions</h3>\n<ul>\n<li>Due Date : July 7, Friday, 5 pm</li>\n<li>Submit your answer at D2 &gt; Quiz &gt; “Sonam’s Dilemma : a gift for few or a chance for all”</li>\n</ul>\n</section>\n<section id="question" class="level3">\n<h3 class="anchored" data-anchor-id="question">Question</h3>\n<p><br> <em>Source : Story I made up, text improved by ChatGPT, and then edited by myself.</em></p>\n<p>Once upon a time, in the grand kingdom of Razia, there existed a mesmerizing lead dancer named Sonam. She possesed a combination of charm, extraordinary talent, and intelligence that made her stand out amongst her peers. Sonam’s passion for dance was matched only by her love for her dance group,with 2000 other talented dancers, who all shared an unbreakable bond and admired their noble Queen above all.</p>\n<p>One fine day, as Sonam’s heart overflowed with gratitude for their benevolent ruler, she decided to express her deep admiration through the power of music. She crafted a beautiful song that portrayed the love and adoration her dance group held for Queen Razia. With eager anticipation, Sonam’s troupe dedicated themselves to perfecting their dance moves to match the rhythm and emotion of her heartfelt composition.</p>\n<p>The auspicious occasion of Queen Razia’s birthday arrived, filling the grand palace with a sense of joy and celebration. The Queen, known for her discerning taste and appreciation for the arts, eagerly awaited the performance of Sonam’s dance group. As the music began to play and the dancers gracefully glided across the grand ballroom, a spell was cast upon all those in attendance.</p>\n<p>The Queen was captivated by the talent displayed before her, and her heart swelled with pride and delight. She could not help but marvel at the synchronized movements and the sheer passion that emanated from each and every member of the dance group. As the performance reached its crescendo, Queen Razia’s decision was made in an instant—this remarkable group deserved a gift to commemorate their extraordinary dedication.</p>\n<div class="Secret">\n<dr_cynthia_breazeal></dr_cynthia_breazeal>\n</div>\n<p>However, there were only a limited number of gift available to give out right now. She presented Sonam with two choices, each with its own intriguing possibilities. The first option was straightforward : 660 randomly chosen dancers would receive a gift. This meant that a select few would be rewarded, leaving the remaining members without a token of appreciation.</p>\n<p>The second choice, however, offered a twist. Queen Shah proposed distributing the available gifts among all dancers, but with a twist of uncertainty. Each dancer would have a 33% chance of receiving a gift. 67% of not receiving a gift.</p>\n<p>Now faced with this dilemma, Sonam’s sharp mind began to evaluate the situation. Which option should Sonam pick? Why? Why not the other?</p>\n\n\n</section>\n</section>\n\n</main> <!-- /main -->\n<script id="quarto-html-after-body" type="application/javascript">\nwindow.document.addEventListener("DOMContentLoaded", function (event) {\n  const toggleBodyColorMode = (bsSheetEl) => {\n    const mode = bsSheetEl.getAttribute("data-mode");\n    const bodyEl = window.document.querySelector("body");\n    if (mode === "dark") {\n      bodyEl.classList.add("quarto-dark");\n      bodyEl.classList.remove("quarto-light");\n    } else {\n      bodyEl.classList.add("quarto-light");\n      bodyEl.classList.remove("quarto-dark");\n    }\n  }\n  const toggleBodyColorPrimary = () => {\n    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");\n    if (bsSheetEl) {\n      toggleBodyColorMode(bsSheetEl);\n    }\n  }\n  toggleBodyColorPrimary();  \n  const icon = "\ue9cb";\n  const anchorJS = new window.AnchorJS();\n  anchorJS.options = {\n    placement: \'right\',\n    icon: icon\n  };\n  anchorJS.add(\'.anchored\');\n  const isCodeAnnotation = (el) => {\n    for (const clz of el.classList) {\n      if (clz.startsWith(\'code-annotation-\')) {                     \n        return true;\n      }\n    }\n    return false;\n  }\n  const clipboard = new window.ClipboardJS(\'.code-copy-button\', {\n    text: function(trigger) {\n      const codeEl = trigger.previousElementSibling.cloneNode(true);\n      for (const childEl of codeEl.children) {\n        if (isCodeAnnotation(childEl)) {\n          childEl.remove();\n        }\n      }\n      return codeEl.innerText;\n    }\n  });\n  clipboard.on(\'success\', function(e) {\n    // button target\n    const button = e.trigger;\n    // don\'t keep focus\n    button.blur();\n    // flash "checked"\n    button.classList.add(\'code-copy-button-checked\');\n    var currentTitle = button.getAttribute("title");\n    button.setAttribute("title", "Copied!");\n    let tooltip;\n    if (window.bootstrap) {\n      button.setAttribute("data-bs-toggle", "tooltip");\n      button.setAttribute("data-bs-placement", "left");\n      button.setAttribute("data-bs-title", "Copied!");\n      tooltip = new bootstrap.Tooltip(button, \n        { trigger: "manual", \n          customClass: "code-copy-button-tooltip",\n          offset: [0, -8]});\n      tooltip.show();    \n    }\n    setTimeout(function() {\n      if (tooltip) {\n        tooltip.hide();\n        button.removeAttribute("data-bs-title");\n        button.removeAttribute("data-bs-toggle");\n        button.removeAttribute("data-bs-placement");\n      }\n      button.setAttribute("title", currentTitle);\n      button.classList.remove(\'code-copy-button-checked\');\n    }, 1000);\n    // clear code selection\n    e.clearSelection();\n  });\n  function tippyHover(el, contentFn) {\n    const config = {\n      allowHTML: true,\n      content: contentFn,\n      maxWidth: 500,\n      delay: 100,\n      arrow: false,\n      appendTo: function(el) {\n          return el.parentElement;\n      },\n      interactive: true,\n      interactiveBorder: 10,\n      theme: \'quarto\',\n      placement: \'bottom-start\'\n    };\n    window.tippy(el, config); \n  }\n  const noterefs = window.document.querySelectorAll(\'a[role="doc-noteref"]\');\n  for (var i=0; i<noterefs.length; i++) {\n    const ref = noterefs[i];\n    tippyHover(ref, function() {\n      // use id or data attribute instead here\n      let href = ref.getAttribute(\'data-footnote-href\') || ref.getAttribute(\'href\');\n      try { href = new URL(href).hash; } catch {}\n      const id = href.replace(/^#\\/?/, "");\n      const note = window.document.getElementById(id);\n      return note.innerHTML;\n    });\n  }\n      let selectedAnnoteEl;\n      const selectorForAnnotation = ( cell, annotation) => {\n        let cellAttr = \'data-code-cell="\' + cell + \'"\';\n        let lineAttr = \'data-code-annotation="\' +  annotation + \'"\';\n        const selector = \'span[\' + cellAttr + \'][\' + lineAttr + \']\';\n        return selector;\n      }\n      const selectCodeLines = (annoteEl) => {\n        const doc = window.document;\n        const targetCell = annoteEl.getAttribute("data-target-cell");\n        const targetAnnotation = annoteEl.getAttribute("data-target-annotation");\n        const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));\n        const lines = annoteSpan.getAttribute("data-code-lines").split(",");\n        const lineIds = lines.map((line) => {\n          return targetCell + "-" + line;\n        })\n        let top = null;\n        let height = null;\n        let parent = null;\n        if (lineIds.length > 0) {\n            //compute the position of the single el (top and bottom and make a div)\n            const el = window.document.getElementById(lineIds[0]);\n            top = el.offsetTop;\n            height = el.offsetHeight;\n            parent = el.parentElement.parentElement;\n          if (lineIds.length > 1) {\n            const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);\n            const bottom = lastEl.offsetTop + lastEl.offsetHeight;\n            height = bottom - top;\n          }\n          if (top !== null && height !== null && parent !== null) {\n            // cook up a div (if necessary) and position it \n            let div = window.document.getElementById("code-annotation-line-highlight");\n            if (div === null) {\n              div = window.document.createElement("div");\n              div.setAttribute("id", "code-annotation-line-highlight");\n              div.style.position = \'absolute\';\n              parent.appendChild(div);\n            }\n            div.style.top = top - 2 + "px";\n            div.style.height = height + 4 + "px";\n            let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");\n            if (gutterDiv === null) {\n              gutterDiv = window.document.createElement("div");\n              gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");\n              gutterDiv.style.position = \'absolute\';\n              const codeCell = window.document.getElementById(targetCell);\n              const gutter = codeCell.querySelector(\'.code-annotation-gutter\');\n              gutter.appendChild(gutterDiv);\n            }\n            gutterDiv.style.top = top - 2 + "px";\n            gutterDiv.style.height = height + 4 + "px";\n          }\n          selectedAnnoteEl = annoteEl;\n        }\n      };\n      const unselectCodeLines = () => {\n        const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];\n        elementsIds.forEach((elId) => {\n          const div = window.document.getElementById(elId);\n          if (div) {\n            div.remove();\n          }\n        });\n        selectedAnnoteEl = undefined;\n      };\n      // Attach click handler to the DT\n      const annoteDls = window.document.querySelectorAll(\'dt[data-target-cell]\');\n      for (const annoteDlNode of annoteDls) {\n        annoteDlNode.addEventListener(\'click\', (event) => {\n          const clickedEl = event.target;\n          if (clickedEl !== selectedAnnoteEl) {\n            unselectCodeLines();\n            const activeEl = window.document.querySelector(\'dt[data-target-cell].code-annotation-active\');\n            if (activeEl) {\n              activeEl.classList.remove(\'code-annotation-active\');\n            }\n            selectCodeLines(clickedEl);\n            clickedEl.classList.add(\'code-annotation-active\');\n          } else {\n            // Unselect the line\n            unselectCodeLines();\n            clickedEl.classList.remove(\'code-annotation-active\');\n          }\n        });\n      }\n  const findCites = (el) => {\n    const parentEl = el.parentElement;\n    if (parentEl) {\n      const cites = parentEl.dataset.cites;\n      if (cites) {\n        return {\n          el,\n          cites: cites.split(\' \')\n        };\n      } else {\n        return findCites(el.parentElement)\n      }\n    } else {\n      return undefined;\n    }\n  };\n  var bibliorefs = window.document.querySelectorAll(\'a[role="doc-biblioref"]\');\n  for (var i=0; i<bibliorefs.length; i++) {\n    const ref = bibliorefs[i];\n    const citeInfo = findCites(ref);\n    if (citeInfo) {\n      tippyHover(citeInfo.el, function() {\n        var popup = window.document.createElement(\'div\');\n        citeInfo.cites.forEach(function(cite) {\n          var citeDiv = window.document.createElement(\'div\');\n          citeDiv.classList.add(\'hanging-indent\');\n          citeDiv.classList.add(\'csl-entry\');\n          var biblioDiv = window.document.getElementById(\'ref-\' + cite);\n          if (biblioDiv) {\n            citeDiv.innerHTML = biblioDiv.innerHTML;\n          }\n          popup.appendChild(citeDiv);\n        });\n        return popup.innerHTML;\n      });\n    }\n  }\n});\n</script>\n</div> <!-- /content -->\n\n\n\n</body></html>'

Q 2. Find the section with the secret code by using the Beautiful Soup’s find function [ 2 points ]. See 5:53 in the Solutions Video

bonus_bs4_obj = BeautifulSoup(bonus_page_html,"html.parser")
bonus_bs4_obj.prettify
<bound method Tag.prettify of <!DOCTYPE html>

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>
<meta charset="utf-8"/>
<meta content="quarto-1.3.361" name="generator"/>
<meta content="width=device-width, initial-scale=1.0, user-scalable=yes" name="viewport"/>
<title>CSC 380 – quarto-inputa5805b45</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
  width: 0.8em;
  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
  vertical-align: middle;
}
</style>
<script src="../site_libs/quarto-nav/quarto-nav.js"></script>
<script src="../site_libs/quarto-nav/headroom.min.js"></script>
<script src="../site_libs/clipboard/clipboard.min.js"></script>
<script src="../site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="../site_libs/quarto-search/fuse.min.js"></script>
<script src="../site_libs/quarto-search/quarto-search.js"></script>
<meta content="../" name="quarto:offset"/>
<script src="../site_libs/quarto-html/quarto.js"></script>
<script src="../site_libs/quarto-html/popper.min.js"></script>
<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="../site_libs/quarto-html/anchor.min.js"></script>
<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet"/>
<link href="../site_libs/quarto-html/quarto-syntax-highlighting.css" id="quarto-text-highlighting-styles" rel="stylesheet"/>
<script src="../site_libs/bootstrap/bootstrap.min.js"></script>
<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet"/>
<link data-mode="light" href="../site_libs/bootstrap/bootstrap.min.css" id="quarto-bootstrap" rel="stylesheet"/>
<script id="quarto-search-options" type="application/json">{
  "location": "sidebar",
  "copy-button": false,
  "collapse-after": 3,
  "panel-placement": "start",
  "type": "textbox",
  "limit": 20,
  "language": {
    "search-no-results-text": "No results",
    "search-matching-documents-text": "matching documents",
    "search-copy-link-title": "Copy link to search",
    "search-hide-matches-text": "Hide additional matches",
    "search-more-match-text": "more match in this document",
    "search-more-matches-text": "more matches in this document",
    "search-clear-button-title": "Clear",
    "search-detached-cancel-button-title": "Cancel",
    "search-submit-button-title": "Submit",
    "search-label": "Search"
  }
}</script>
<link href="../styles.css" rel="stylesheet"/>
</head>
<body class="nav-sidebar docked">
<div id="quarto-search-results"></div>
<header class="headroom fixed-top" id="quarto-header">
<nav class="quarto-secondary-nav">
<div class="container-fluid d-flex">
<button aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" class="quarto-btn-toggle btn" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" data-bs-toggle="collapse" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }" type="button">
<i class="bi bi-layout-text-sidebar-reverse"></i>
</button>
<nav aria-label="breadcrumb" class="quarto-page-breadcrumbs"><ol class="breadcrumb"><li class="breadcrumb-item">
      CSC 380
      </li></ol></nav>
<a aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" class="flex-grow-1" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" data-bs-toggle="collapse" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }" role="button">
</a>
<button aria-label="" class="btn quarto-search-button" onclick="window.quartoOpenSearch();" type="button">
<i class="bi bi-search"></i>
</button>
</div>
</nav>
</header>
<!-- content -->
<div class="quarto-container page-columns page-rows-contents page-layout-article" id="quarto-content">
<!-- sidebar -->
<nav class="sidebar collapse collapse-horizontal sidebar-navigation docked overflow-auto" id="quarto-sidebar">
<div class="pt-lg-2 mt-2 text-left sidebar-header">
<div class="sidebar-title mb-0 py-0">
<a href="../">CSC 380</a>
</div>
</div>
<div class="mt-2 flex-shrink-0 align-items-center">
<div class="sidebar-search">
<div class="" id="quarto-search" title="Search"></div>
</div>
</div>
<div class="sidebar-menu-container">
<ul class="list-unstyled mt-1">
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-1" data-bs-toggle="collapse">
<span class="menu-text">Course Content</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-1" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-1">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Course_Content/Week_1/home.html">
<span class="menu-text">Week 1</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Course_Content/Week_2/home.html">
<span class="menu-text">Week 2</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Course_Content/Week_3/home.html">
<span class="menu-text">Week 3</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Course_Content/Week_4&amp;5/home.html">
<span class="menu-text">Week 4 &amp; 5</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-2" data-bs-toggle="collapse">
<span class="menu-text">Homework</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-2" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-2">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Homework/1/HW.html">
<span class="menu-text">HW1: Probability</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Homework/2/HW.html">
<span class="menu-text">HW2: Data Collection</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-3" data-bs-toggle="collapse">
<span class="menu-text">Ethics Discussions</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-3" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-3">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_2.html">
<span class="menu-text">W2: Political Content</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_3.html">
<span class="menu-text">W3: Creative Work</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_4.html">
<span class="menu-text">W4: Mental Health Support</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_6.html">
<span class="menu-text">W6: Recommendations</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_7.html">
<span class="menu-text">W7: Autonomous Driving</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_8.html">
<span class="menu-text">W8: Housekeeping</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Ethics/Week_9.html">
<span class="menu-text">W9: Facial Recognition</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-4" data-bs-toggle="collapse">
<span class="menu-text">Bonus Questions</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-4" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-4">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Bonus/home.html">
<span class="menu-text">Home</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-5" data-bs-toggle="collapse">
<span class="menu-text">Participation</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-5" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-5">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Participation_Activities/home.html">
<span class="menu-text">Home</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-6" data-bs-toggle="collapse">
<span class="menu-text">Honors</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-6" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-6">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Honors/home.html">
<span class="menu-text">Assignments</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a aria-expanded="true" class="sidebar-item-text sidebar-link text-start" data-bs-target="#quarto-sidebar-section-7" data-bs-toggle="collapse">
<span class="menu-text">Syllabus</span></a>
<a aria-expanded="true" aria-label="Toggle section" class="sidebar-item-toggle text-start" data-bs-target="#quarto-sidebar-section-7" data-bs-toggle="collapse">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul class="collapse list-unstyled sidebar-section depth1 show" id="quarto-sidebar-section-7">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Syllabus/Key_Info.html">
<span class="menu-text">Key Info</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link" href="../Syllabus/Syllabus.html">
<span class="menu-text">Official Syllabus</span></a>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
<div data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" data-bs-toggle="collapse" id="quarto-sidebar-glass"></div>
<!-- margin-sidebar -->
<div class="sidebar margin-sidebar" id="quarto-margin-sidebar">
<nav class="toc-active" id="TOC" role="doc-toc">
<h2 id="toc-title">On this page</h2>
<ul>
<li><a class="nav-link active" data-scroll-target="#sonams-dilemma---a-gift-for-few-or-a-chance-for-all" href="#sonams-dilemma---a-gift-for-few-or-a-chance-for-all" id="toc-sonams-dilemma---a-gift-for-few-or-a-chance-for-all">Sonam’s Dilemma - A Gift for Few or a Chance for All</a>
<ul class="collapse">
<li><a class="nav-link" data-scroll-target="#instructions" href="#instructions" id="toc-instructions">Instructions</a></li>
<li><a class="nav-link" data-scroll-target="#question" href="#question" id="toc-question">Question</a></li>
</ul></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<section class="level1" id="sonams-dilemma---a-gift-for-few-or-a-chance-for-all">
<h1>Sonam’s Dilemma - A Gift for Few or a Chance for All</h1>
<section class="level6" id="bonus-question-1-point">
<h6 class="anchored" data-anchor-id="bonus-question-1-point">Bonus Question : 1 point</h6>
<p><br/></p>
</section>
<section class="level3" id="instructions">
<h3 class="anchored" data-anchor-id="instructions">Instructions</h3>
<ul>
<li>Due Date : July 7, Friday, 5 pm</li>
<li>Submit your answer at D2 &gt; Quiz &gt; “Sonam’s Dilemma : a gift for few or a chance for all”</li>
</ul>
</section>
<section class="level3" id="question">
<h3 class="anchored" data-anchor-id="question">Question</h3>
<p><br/> <em>Source : Story I made up, text improved by ChatGPT, and then edited by myself.</em></p>
<p>Once upon a time, in the grand kingdom of Razia, there existed a mesmerizing lead dancer named Sonam. She possesed a combination of charm, extraordinary talent, and intelligence that made her stand out amongst her peers. Sonam’s passion for dance was matched only by her love for her dance group,with 2000 other talented dancers, who all shared an unbreakable bond and admired their noble Queen above all.</p>
<p>One fine day, as Sonam’s heart overflowed with gratitude for their benevolent ruler, she decided to express her deep admiration through the power of music. She crafted a beautiful song that portrayed the love and adoration her dance group held for Queen Razia. With eager anticipation, Sonam’s troupe dedicated themselves to perfecting their dance moves to match the rhythm and emotion of her heartfelt composition.</p>
<p>The auspicious occasion of Queen Razia’s birthday arrived, filling the grand palace with a sense of joy and celebration. The Queen, known for her discerning taste and appreciation for the arts, eagerly awaited the performance of Sonam’s dance group. As the music began to play and the dancers gracefully glided across the grand ballroom, a spell was cast upon all those in attendance.</p>
<p>The Queen was captivated by the talent displayed before her, and her heart swelled with pride and delight. She could not help but marvel at the synchronized movements and the sheer passion that emanated from each and every member of the dance group. As the performance reached its crescendo, Queen Razia’s decision was made in an instant—this remarkable group deserved a gift to commemorate their extraordinary dedication.</p>
<div class="Secret">
<dr_cynthia_breazeal></dr_cynthia_breazeal>
</div>
<p>However, there were only a limited number of gift available to give out right now. She presented Sonam with two choices, each with its own intriguing possibilities. The first option was straightforward : 660 randomly chosen dancers would receive a gift. This meant that a select few would be rewarded, leaving the remaining members without a token of appreciation.</p>
<p>The second choice, however, offered a twist. Queen Shah proposed distributing the available gifts among all dancers, but with a twist of uncertainty. Each dancer would have a 33% chance of receiving a gift. 67% of not receiving a gift.</p>
<p>Now faced with this dilemma, Sonam’s sharp mind began to evaluate the situation. Which option should Sonam pick? Why? Why not the other?</p>
</section>
</section>
</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
  const toggleBodyColorMode = (bsSheetEl) => {
    const mode = bsSheetEl.getAttribute("data-mode");
    const bodyEl = window.document.querySelector("body");
    if (mode === "dark") {
      bodyEl.classList.add("quarto-dark");
      bodyEl.classList.remove("quarto-light");
    } else {
      bodyEl.classList.add("quarto-light");
      bodyEl.classList.remove("quarto-dark");
    }
  }
  const toggleBodyColorPrimary = () => {
    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
    if (bsSheetEl) {
      toggleBodyColorMode(bsSheetEl);
    }
  }
  toggleBodyColorPrimary();  
  const icon = "";
  const anchorJS = new window.AnchorJS();
  anchorJS.options = {
    placement: 'right',
    icon: icon
  };
  anchorJS.add('.anchored');
  const isCodeAnnotation = (el) => {
    for (const clz of el.classList) {
      if (clz.startsWith('code-annotation-')) {                     
        return true;
      }
    }
    return false;
  }
  const clipboard = new window.ClipboardJS('.code-copy-button', {
    text: function(trigger) {
      const codeEl = trigger.previousElementSibling.cloneNode(true);
      for (const childEl of codeEl.children) {
        if (isCodeAnnotation(childEl)) {
          childEl.remove();
        }
      }
      return codeEl.innerText;
    }
  });
  clipboard.on('success', function(e) {
    // button target
    const button = e.trigger;
    // don't keep focus
    button.blur();
    // flash "checked"
    button.classList.add('code-copy-button-checked');
    var currentTitle = button.getAttribute("title");
    button.setAttribute("title", "Copied!");
    let tooltip;
    if (window.bootstrap) {
      button.setAttribute("data-bs-toggle", "tooltip");
      button.setAttribute("data-bs-placement", "left");
      button.setAttribute("data-bs-title", "Copied!");
      tooltip = new bootstrap.Tooltip(button, 
        { trigger: "manual", 
          customClass: "code-copy-button-tooltip",
          offset: [0, -8]});
      tooltip.show();    
    }
    setTimeout(function() {
      if (tooltip) {
        tooltip.hide();
        button.removeAttribute("data-bs-title");
        button.removeAttribute("data-bs-toggle");
        button.removeAttribute("data-bs-placement");
      }
      button.setAttribute("title", currentTitle);
      button.classList.remove('code-copy-button-checked');
    }, 1000);
    // clear code selection
    e.clearSelection();
  });
  function tippyHover(el, contentFn) {
    const config = {
      allowHTML: true,
      content: contentFn,
      maxWidth: 500,
      delay: 100,
      arrow: false,
      appendTo: function(el) {
          return el.parentElement;
      },
      interactive: true,
      interactiveBorder: 10,
      theme: 'quarto',
      placement: 'bottom-start'
    };
    window.tippy(el, config); 
  }
  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  for (var i=0; i<noterefs.length; i++) {
    const ref = noterefs[i];
    tippyHover(ref, function() {
      // use id or data attribute instead here
      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
      try { href = new URL(href).hash; } catch {}
      const id = href.replace(/^#\/?/, "");
      const note = window.document.getElementById(id);
      return note.innerHTML;
    });
  }
      let selectedAnnoteEl;
      const selectorForAnnotation = ( cell, annotation) => {
        let cellAttr = 'data-code-cell="' + cell + '"';
        let lineAttr = 'data-code-annotation="' +  annotation + '"';
        const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
        return selector;
      }
      const selectCodeLines = (annoteEl) => {
        const doc = window.document;
        const targetCell = annoteEl.getAttribute("data-target-cell");
        const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
        const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
        const lines = annoteSpan.getAttribute("data-code-lines").split(",");
        const lineIds = lines.map((line) => {
          return targetCell + "-" + line;
        })
        let top = null;
        let height = null;
        let parent = null;
        if (lineIds.length > 0) {
            //compute the position of the single el (top and bottom and make a div)
            const el = window.document.getElementById(lineIds[0]);
            top = el.offsetTop;
            height = el.offsetHeight;
            parent = el.parentElement.parentElement;
          if (lineIds.length > 1) {
            const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
            const bottom = lastEl.offsetTop + lastEl.offsetHeight;
            height = bottom - top;
          }
          if (top !== null && height !== null && parent !== null) {
            // cook up a div (if necessary) and position it 
            let div = window.document.getElementById("code-annotation-line-highlight");
            if (div === null) {
              div = window.document.createElement("div");
              div.setAttribute("id", "code-annotation-line-highlight");
              div.style.position = 'absolute';
              parent.appendChild(div);
            }
            div.style.top = top - 2 + "px";
            div.style.height = height + 4 + "px";
            let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
            if (gutterDiv === null) {
              gutterDiv = window.document.createElement("div");
              gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
              gutterDiv.style.position = 'absolute';
              const codeCell = window.document.getElementById(targetCell);
              const gutter = codeCell.querySelector('.code-annotation-gutter');
              gutter.appendChild(gutterDiv);
            }
            gutterDiv.style.top = top - 2 + "px";
            gutterDiv.style.height = height + 4 + "px";
          }
          selectedAnnoteEl = annoteEl;
        }
      };
      const unselectCodeLines = () => {
        const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
        elementsIds.forEach((elId) => {
          const div = window.document.getElementById(elId);
          if (div) {
            div.remove();
          }
        });
        selectedAnnoteEl = undefined;
      };
      // Attach click handler to the DT
      const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
      for (const annoteDlNode of annoteDls) {
        annoteDlNode.addEventListener('click', (event) => {
          const clickedEl = event.target;
          if (clickedEl !== selectedAnnoteEl) {
            unselectCodeLines();
            const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
            if (activeEl) {
              activeEl.classList.remove('code-annotation-active');
            }
            selectCodeLines(clickedEl);
            clickedEl.classList.add('code-annotation-active');
          } else {
            // Unselect the line
            unselectCodeLines();
            clickedEl.classList.remove('code-annotation-active');
          }
        });
      }
  const findCites = (el) => {
    const parentEl = el.parentElement;
    if (parentEl) {
      const cites = parentEl.dataset.cites;
      if (cites) {
        return {
          el,
          cites: cites.split(' ')
        };
      } else {
        return findCites(el.parentElement)
      }
    } else {
      return undefined;
    }
  };
  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  for (var i=0; i<bibliorefs.length; i++) {
    const ref = bibliorefs[i];
    const citeInfo = findCites(ref);
    if (citeInfo) {
      tippyHover(citeInfo.el, function() {
        var popup = window.document.createElement('div');
        citeInfo.cites.forEach(function(cite) {
          var citeDiv = window.document.createElement('div');
          citeDiv.classList.add('hanging-indent');
          citeDiv.classList.add('csl-entry');
          var biblioDiv = window.document.getElementById('ref-' + cite);
          if (biblioDiv) {
            citeDiv.innerHTML = biblioDiv.innerHTML;
          }
          popup.appendChild(citeDiv);
        });
        return popup.innerHTML;
      });
    }
  }
});
</script>
</div> <!-- /content -->
</body></html>>
secret_section = bonus_bs4_obj.find("div","Secret")
secret_section
<div class="Secret">
<dr_cynthia_breazeal></dr_cynthia_breazeal>
</div>

Q 3. Clean up the secret code and print it as “The Secret Code is: CSC380” [ 1 point ]. See 10:30 in the Solutions Video

list(secret_section.children)
['\n', <dr_cynthia_breazeal></dr_cynthia_breazeal>, '\n']
secret_code_tag = list(secret_section.children)[1]
secret_code_tag
<dr_cynthia_breazeal></dr_cynthia_breazeal>
secret_code = secret_code_tag.name
secret_code
'dr_cynthia_breazeal'
print("The Secret Code is: ",secret_code)
The Secret Code is:  dr_cynthia_breazeal

Problem 2. Random Facts API [ 11 points ].

RANDOM_FACT_WEBSITE_URL = "https://uselessfacts.jsph.pl"
RANDOM_FACTS_ENDPOINT = "/api/v2/facts/random"
TODAY_RANDOM_FACT_ENDPOINT = "/api/v2/facts/today"

Q1. Find the URL for random facts API. [1 point]. See 13:38 in the Solutions Video

random_facts_api = RANDOM_FACT_WEBSITE_URL+RANDOM_FACTS_ENDPOINT
random_facts_api
'https://uselessfacts.jsph.pl/api/v2/facts/random'

Qs. 2,3,4 . Collect 10 Random Facts [3 point]. See 16:48 in the Solutions Video

random_facts_list_of_json = []
nos_of_facts = 10

for fact_no in range(nos_of_facts):

    random_fact_req_obj = requests.get(random_facts_api)

    if random_fact_req_obj.status_code == 200:

        random_facts_list_of_json.append(random_fact_req_obj.json())

    sleep(2)
len(random_facts_list_of_json)
10
random_facts_list_of_json
[{'id': 'e5ab712476d43f31e76bb1729af8d864',
  'text': 'The Main Library at Indiana University sinks over an inch every year because when it was built, engineers failed to take into account the weight of all the books that would occupy the building.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/e5ab712476d43f31e76bb1729af8d864'},
 {'id': 'f3b6f48bf9ab74f1937f61e2c00cddfe',
  'text': 'In 1912 a law passed in Nebraska where drivers in the country at night were required to stop every 150 yards, send up a skyrocket, wait eight minutes for the road to clear before proceeding cautiously, all the while blowing their horn and shooting off flares.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/f3b6f48bf9ab74f1937f61e2c00cddfe'},
 {'id': 'ec0e1f3ff567de996194a62062e5e295',
  'text': 'Tehran is the most expensive city on earth.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/ec0e1f3ff567de996194a62062e5e295'},
 {'id': 'be3e622e9fee8b4e6e21e1d6d7359edf',
  'text': 'The shape of plant collenchyma’s cells and the shape of the bubbles in beer foam are the same - they are orthotetrachidecahedrons.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/be3e622e9fee8b4e6e21e1d6d7359edf'},
 {'id': '1173c33c84146fcc7825c04683ce9496',
  'text': 'One-fourth of the world`s population lives on less than $200 a year.\xa0 Ninety million people survive on less than $75 a year.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/1173c33c84146fcc7825c04683ce9496'},
 {'id': '3f4bac8655449adc95b7eb89c129e17e',
  'text': 'Tigers not only have striped fur, they have striped skin!',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/3f4bac8655449adc95b7eb89c129e17e'},
 {'id': '3639a3cf749725c9b903dc0e500be8cc',
  'text': 'One third of all cancers are sun related.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/3639a3cf749725c9b903dc0e500be8cc'},
 {'id': '3b99d35171dc8fc7abbc1891aab4d6cb',
  'text': 'The dot over the letter `i` is called a tittle. \xa0',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/3b99d35171dc8fc7abbc1891aab4d6cb'},
 {'id': '1c7d8f7a7ebb804addf2cbd60b454db7',
  'text': 'The electric chair was invented by a dentist.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/1c7d8f7a7ebb804addf2cbd60b454db7'},
 {'id': 'ca89075fd3a528c2be2feac0be27383a',
  'text': 'A spider has transparent blood.',
  'source': 'djtech.net',
  'source_url': 'http://www.djtech.net/humor/useless_facts.htm',
  'language': 'en',
  'permalink': 'https://uselessfacts.jsph.pl/api/v2/facts/ca89075fd3a528c2be2feac0be27383a'}]

Q.5 Creating the Dataframe [1 point]. See 22:26 in the Solutions Video

random_facts_df = pd.DataFrame(random_facts_list_of_json)
random_facts_df.sample(2)
id text source source_url language permalink
9 ca89075fd3a528c2be2feac0be27383a A spider has transparent blood. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/ca89...
2 ec0e1f3ff567de996194a62062e5e295 Tehran is the most expensive city on earth. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/ec0e...
random_facts_df
id text source source_url language permalink
0 e5ab712476d43f31e76bb1729af8d864 The Main Library at Indiana University sinks o... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/e5ab...
1 f3b6f48bf9ab74f1937f61e2c00cddfe In 1912 a law passed in Nebraska where drivers... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/f3b6...
2 ec0e1f3ff567de996194a62062e5e295 Tehran is the most expensive city on earth. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/ec0e...
3 be3e622e9fee8b4e6e21e1d6d7359edf The shape of plant collenchyma’s cells and the... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/be3e...
4 1173c33c84146fcc7825c04683ce9496 One-fourth of the world`s population lives on ... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/1173...
5 3f4bac8655449adc95b7eb89c129e17e Tigers not only have striped fur, they have st... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/3f4b...
6 3639a3cf749725c9b903dc0e500be8cc One third of all cancers are sun related. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/3639...
7 3b99d35171dc8fc7abbc1891aab4d6cb The dot over the letter `i` is called a tittle. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/3b99...
8 1c7d8f7a7ebb804addf2cbd60b454db7 The electric chair was invented by a dentist. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/1c7d...
9 ca89075fd3a528c2be2feac0be27383a A spider has transparent blood. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/ca89...

Q 6. Display Full Facts [2 points]. See 24:03 in the Solutions Video

random_facts_series = random_facts_df['text'] # Part a
random_facts_series
0    The Main Library at Indiana University sinks o...
1    In 1912 a law passed in Nebraska where drivers...
2          Tehran is the most expensive city on earth.
3    The shape of plant collenchyma’s cells and the...
4    One-fourth of the world`s population lives on ...
5    Tigers not only have striped fur, they have st...
6            One third of all cancers are sun related.
7    The dot over the letter `i` is called a tittle.  
8        The electric chair was invented by a dentist.
9                      A spider has transparent blood.
Name: text, dtype: object
random_facts_list = random_facts_series.to_list() # Part b
random_facts_list
['The Main Library at Indiana University sinks over an inch every year because when it was built, engineers failed to take into account the weight of all the books that would occupy the building.',
 'In 1912 a law passed in Nebraska where drivers in the country at night were required to stop every 150 yards, send up a skyrocket, wait eight minutes for the road to clear before proceeding cautiously, all the while blowing their horn and shooting off flares.',
 'Tehran is the most expensive city on earth.',
 'The shape of plant collenchyma’s cells and the shape of the bubbles in beer foam are the same - they are orthotetrachidecahedrons.',
 'One-fourth of the world`s population lives on less than $200 a year.\xa0 Ninety million people survive on less than $75 a year.',
 'Tigers not only have striped fur, they have striped skin!',
 'One third of all cancers are sun related.',
 'The dot over the letter `i` is called a tittle. \xa0',
 'The electric chair was invented by a dentist.',
 'A spider has transparent blood.']

Q 7. Show 3 random facts from the data frame [1 point]. See 25:58

random_facts_df.sample(3)
id text source source_url language permalink
1 f3b6f48bf9ab74f1937f61e2c00cddfe In 1912 a law passed in Nebraska where drivers... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/f3b6...
9 ca89075fd3a528c2be2feac0be27383a A spider has transparent blood. djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/ca89...
3 be3e622e9fee8b4e6e21e1d6d7359edf The shape of plant collenchyma’s cells and the... djtech.net http://www.djtech.net/humor/useless_facts.htm en https://uselessfacts.jsph.pl/api/v2/facts/be3e...

Q8. What is today’s random fact? [3 points]. See 26:29 in the Solutions Video

Part a

todays_random_fact_api = RANDOM_FACT_WEBSITE_URL+ TODAY_RANDOM_FACT_ENDPOINT
todays_random_fact_api
'https://uselessfacts.jsph.pl/api/v2/facts/today'
today_fact_req_obj = requests.get(todays_random_fact_api)
today_fact_req_obj.status_code
200
random_fact_of_the_day = today_fact_req_obj.json()['text'] #Part a
random_fact_of_the_day
'Ants closely resemble human manners:\xa0 When they wake, they stretch & appear to yawn in a human manner before taking up the tasks of the day.'

Part b

time_rn = datetime.today()
print('Time right now is :',time_rn.strftime("%Y-%m-%d %I:%M:%S %p"))
Time right now is : 2023-07-13 02:52:59 AM

Part c

print("At", time_rn.strftime("%Y-%m-%d %I:%M:%S %p"), " the random fact of the day is ",random_fact_of_the_day)
At 2023-07-13 02:52:59 AM  the random fact of the day is  Ants closely resemble human manners:  When they wake, they stretch & appear to yawn in a human manner before taking up the tasks of the day.

Part 3. Movies and Shows [29 points]

Q1. Download the following dataset [2 points]. See 34:18 in the Solutions Video

dataset_names = ['hulu','disney','prime','netflix']
for dataset_name in dataset_names:
    with zipfile.ZipFile(dataset_name+".zip","r") as zip_ref:
        zip_ref.extractall(dataset_name)

Q2. Create one large dataframe [3 points]. See 39:10 in the Solutions Video

Part a

hulu_df = pd.read_csv('hulu/hulu_titles.csv')
hulu_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description
1058 s1059 TV Show WWE Main Event NaN NaN United States January 7, 2021 2012 TV-PG 8 Seasons Sports Join us each week for WWE Main Event, as the S...
netflix_df = pd.read_csv('netflix/netflix_titles.csv')
netflix_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description
6487 s6488 TV Show City in the Sky NaN NaN United Kingdom October 1, 2017 2016 TV-PG 1 Season British TV Shows, Docuseries, Science & Nature TV This series explores the magnitude and scale o...
prime_df = pd.read_csv('prime/amazon_prime_titles.csv')
prime_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description
7912 s7913 Movie One More Saturday Night Dennis Klein Tom Davis, Al Franken, Moira Sinise, Frank How... NaN NaN 1986 R 96 min Comedy The problems faced by both teenagers and adult...
disney_df = pd.read_csv('disney/disney_plus_titles.csv')
disney_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description
1020 s1021 Movie Lilo & Stitch Christopher Sanders, Dean DeBlois Daveigh Chase, Christopher Sanders, Tia Carrer... United States November 12, 2019 2002 TV-PG 86 min Action-Adventure, Animation, Family A little girl adopts a wanted alien wreaking h...

Part b

hulu_df['Platform'] = "Hulu"
netflix_df['Platform'] = "Netflix"
disney_df['Platform'] = "Disney"
prime_df['Platform'] = "Prime"
hulu_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
1193 s1194 TV Show A Sap Story NaN NaN NaN November 13, 2020 2016 NaN 1 Season News Cancel your plans, there’s sap coming out of a... Hulu
netflix_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
6818 s6819 Movie G-Force Hoyt Yeatman Bill Nighy, Will Arnett, Zach Galifianakis, Ke... United States March 15, 2019 2009 PG 88 min Children & Family Movies, Comedies When a billionaire sets out to take over the w... Netflix
disney_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
1135 s1136 Movie Pixel Perfect Mark Dippé Ricky Ullman, Leah Pipes, Spencer Redford, Chr... United States November 12, 2019 2004 TV-G 90 min Comedy, Coming of Age, Music A techno whiz must protect his hologram from f... Disney
prime_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
7077 s7078 Movie Japanese Story Sue Brooks Toni Collette, Otaro Tsunashima, Matthew Dykty... NaN NaN 2003 R 99 min Arthouse, Arts, Entertainment, and Culture, Drama Sandy (Toni Collette), a geologist, finds hers... Prime

Part c

all_platforms_df = pd.concat([prime_df,netflix_df,disney_df,hulu_df])
all_platforms_df.sample(5)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
6181 s6182 Movie April and the Extraordinary World Christian Desmares, Franck Ekinci Angela Galuppo, Paul Giamatti, Susan Sarandon,... France, Canada, Belgium October 1, 2017 2015 PG 107 min Action & Adventure, Comedies, International Mo... After the world's top scientists disappear, or... Netflix
2290 s2291 Movie Tanu Weds Manu Aanand Rai Madhavan, Kangana Ranaut, Jimmy Shergill, Deep... India July 5, 2020 2011 TV-14 114 min Comedies, Dramas, International Movies When London-based doctor Manu reluctantly retu... Netflix
4278 s4279 Movie Aggretsuko: We Wish You a Metal Christmas Rarecho Kaolip, Shingo Kato, Komegumi Koiwasaki, Maki ... Japan December 20, 2018 2018 TV-PG 22 min Movies While Retsuko desperately makes plans for Chri... Netflix
1802 s1803 TV Show The Other Guy NaN NaN Australia February 14, 2020 2017 TV-PG 2 Seasons Comedy, Drama, International A successful radio host finds himself unexpect... Hulu
2403 s2404 Movie Galapagos: Realm of Giant Sharks Thomas Lucas NaN NaN NaN 2012 ALL 53 min Documentary This visually rich production follows a group ... Prime

Q3. Longest show and movie [6 points]. See 44:49 for part a, and 55:20 for part b, in the Solutions Video

Part a

shows_df = all_platforms_df[all_platforms_df['type']=='TV Show']
shows_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
2137 s2138 TV Show Light as a Feather NaN NaN United States July 26, 2019 2018 TV-14 2 Seasons Drama, Horror, Teen An innocent game of “Light as a Feather, Stiff... Hulu
shows_count_df = shows_df.value_counts("duration").to_frame()
shows_count_df.sample(3)
0
duration
4 Seasons 280
19 Seasons 3
26 Seasons 1
shows_count_df.reset_index(inplace=True)
shows_count_df.sample(3)
duration 0
24 26 Seasons 1
12 13 Seasons 6
15 16 Seasons 4
shows_count_df = shows_count_df.rename({
    'duration' : 'Number of seasons',
    0: 'No of shows'
    }, axis = 1)

shows_count_df.sample(3)
Number of seasons No of shows
22 32 Seasons 1
6 7 Seasons 89
0 1 Season 4183
print("Before preprocessing , Longest running season appears to be :",shows_count_df['Number of seasons'].max())
Before preprocessing , Longest running season appears to be : 9 Seasons

Bonus

shows_count_df['Number of seasons'] = shows_count_df['Number of seasons'].apply(lambda x : int(x.replace('Seasons','').replace('Season','')))
shows_count_df.sample()
Number of seasons No of shows
6 7 89
print("After preprocessing , Longest running season appears to be :",shows_count_df['Number of seasons'].max(), "Seasons")
After preprocessing , Longest running season appears to be : 34 Seasons

Part b

movies_df = all_platforms_df[all_platforms_df['type']=='Movie']
movies_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
2595 s2596 Movie Dwayne Perkins: Take Note Ian Harris Dwayne Perkins NaN NaN 2016 18+ 68 min Arts, Entertainment, and Culture, Comedy, Spec... Dwayne delivers his first hour special with a ... Prime
movies_count_df = movies_df.value_counts("duration").to_frame()
movies_count_df.sample(3)
0
duration
25 min 25
69 min 66
229 min 1
movies_count_df.reset_index(inplace=True)
movies_count_df.sample(3)
duration 0
184 175 min 5
159 160 min 13
100 145 min 43
movies_count_df = movies_count_df.rename({
    'duration' : 'Duration in minutes',
    0: 'No of movies'
    }, axis = 1)

movies_count_df.sample(3)
Duration in minutes No of movies
88 48 min 54
31 111 min 153
55 125 min 87

Part i

movies_count_df_i = movies_count_df.sort_values(by="Duration in minutes", ascending=False)
movies_count_df_i
Duration in minutes No of movies
12 99 min 288
13 98 min 286
8 97 min 324
10 96 min 303
7 95 min 340
... ... ...
16 101 min 253
14 100 min 260
126 10 min 25
165 1 min 11
166 0 min 10

225 rows × 2 columns

longest_movie_duration = movies_count_df_i.head(1)['Duration in minutes'].to_list()[0]
print("Longest Movie Duration is : ",longest_movie_duration)
Longest Movie Duration is :  99 min
longest_movies_df = movies_df[movies_df["duration"] == longest_movie_duration ]
longest_movies_df.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
4293 s4294 Movie Caught Up Darin Scott Bokeem Woodbine, Snoop Doggy Dogg, LL Cool J, ... NaN NaN 1998 16+ 99 min Action, Drama, Suspense After being released from prison a man finds h... Prime
5277 s5278 Movie #realityhigh Fernando Lebrija Nesta Cooper, Kate Walsh, John Michael Higgins... United States September 8, 2017 2017 TV-14 99 min Comedies When nerdy high schooler Dani finally attracts... Netflix
print("Longest Movie Duration is : ",longest_movie_duration)
print("The Movies are : ","\n".join(longest_movies_df['title'].to_list()))
Longest Movie Duration is :  99 min
The Movies are :  Woman Of Desire
Why We Fight
Valley Uprising
The Zookeeper
The Woman in Black 2: Angel of Death
The Ultimate Legacy
The Italian Job (1969)
The Hungry
The Donkey King
Super Size Me
Sunshine Hotel
Street Dance
Storm Boy
Shottas
Our Town
My Foolish Heart
Line of Duty
Honest Thief
Hiding Out
Hellbound: Hellraiser 2
Hearts in Bondage
Happythankyoumoreplease
Grace of God
Go Fast. Go North.
Doe
Digging to China
Better Luck Tomorrow
Belle and Sebastian
Atlas Shrugged: Part III
Anna
23 Blast
The Adventurer: The Curse of the Midas Box
Hallowed Be Thy Name
Madness in the Method
Hick
Assault on Wall Street
The Baytown Outlaws
Rolling Stone: Life And Death Of Brian Jones
Dark Was the Night
Caught Up
Stinger
Goodbye, Butterfly
Little Kingdom
PERSECUTION
Blame it On Fidel
Reversion
Happy Home
Super Fast
Intersection
Tusks
The Shootist
DeepStar Six
Firefly
Rock the Casbah
Nightingale: A Melody of Life
Toys Storage 2
Hoop Soldiers
The Naked Truth
Alejandro
P!nk: All I Know So Far
Vivarium
Thaen
CBI Vs Lovers
Night Hunter
DIVOS!
The Map of Tiny Perfect Things
The Booksellers
Seven Days In Utopia
Tales of an American Hoodrat
Road to Damascus
Perfect Strangers
Boonie Bears: The Big Top Secret
Punarjagran
Someone to Carry Me
Kansas City Confidential
The Silent Mountain
Playback
Tobruk
May Morning
The Grotto
Transmigrate (The Troubled One)
B. A. Pass
Sideshow
Angel And The Badman
Partners
M.O.M. Mothers of Monsters
Bottom Feeders
Run For The Sun
All About Steve
Japanese Story
Azhaggiye Thee
Across The Line
Not That Funny
The Woman In The Window
Ilakku
A Social Cure
Black and White
Cruel Train
Delicatessen
Absence of The Good
Fair Play
The Boss
Physical Evidence
Bad Impulse
Mara
Chinese Box
Blue Juice
Route 24
Rebirth
The Descent
Paper Dragons
Alienated
The Bloody Vampire
Passer By
Death Machine
The Omega Code
Golden Job
Madison
Little Man Tate
Totò Eva e il pennello proibito
The Lady Doctor
The Intruder
Outlaws: The Legend of O.B. Taggart
Gli Onorevoli
No Loss, No Gain
The Sacrament
Red Sun Rising
Driven to Dance
The Trench
Ong Bak 3
Dead Serious
What Happens in Vegas
The Rocky Horror Picture Show
InuYasha the Movie 2: The Castle Beyond the Looking Glass
InuYasha the Movie 3: Swords of an Honorable Ruler
Here and There
Good Luck Chuck
My Girl 2
Cousins
Rogue Warfare: Death of a Nation
Copenhagen
Black Holes | The Edge of All We Know
Ninja Assassin
Swordfish
678
Cinema Bandi
Dance of the Forty One
Monster
Dead Again in Tombstone
The Whole Nine Yards
Sniper: Ghost Shooter
The Block Island Sound
The Misadventures of Hedi and Cokeman
Is Love Enough? Sir
Tony Parker: The Final Shot
U-Turn
Dolly Parton’s Christmas on the Square
Zozo
A Babysitter's Guide to Monster Hunting
#Alive
What Keeps You Alive
Ride Like a Girl
Freej Al Taibeen
Curtiz
MindGamers
A Trip to Jamaica
In My Country
Up North
The Bling Lagosians
Rim of the World
Nappily Ever After
Studio 54
The Last Laugh
All's Well, End's Well (2009)
Errementari: The Blacksmith and the Devil
Harishchandrachi Factory
Thi Mai
I Am not an Easy Man
Layla M.
Bad Day for the Cut
The Worthy
#realityhigh
In the Shadow of Iris
Slam
Life 2.0
Operações Especiais
Tini: The New Life of Violetta
Journey to Greenland
Mercenary
Welcome Mr. President
Audrie & Daisy
Winter on Fire: Ukraine's Fight for Freedom
Çok Filim Hareketler Bunlar
50 First Dates
A.X.L.
Adrishya
American Hangman
B.A. Pass
Barely Lethal
Because We're Heading Out
Being AP
Berlin Kaplani
Bobbi Jene
Bobby Robson: More Than a Manager
Bolt
Candyman
Chasing Trane
Christian Mingle
Christmas with the Kranks
Democrats
Detention Letter
Don't Be Afraid of the Dark
Driven to Dance
Eyyvah Eyyvah
Familiye
Fireflies
Froning: The Fittest Man in History
Good Luck
Hangman
Haunting on Fraternity Row
Indiscretion
Inuyasha the Movie - La spada del dominatore del mondo
InuYasha: The Movie 2: The Castle Beyond the Looking Glass
Kaleidoscope
Knock Knock
Kung Fu Hustle
Like Arrows
Mad Money
Mara
May We Chat
My Dog is My Guide
My Scientology Movie
My Week with Marilyn
My Wife and My Wifey
Nowhere Boy
Race to Witch Mountain
Reaction
Salem: His Sister's Father
Say When
The Aerial
The Croods
The Damned Rain
The Drowning
The Heroes of Evil
The Intent
The Invention of Lying
The Nutcracker and the Four Realms
The Sapphires
The Tuxedo
Tremors 5:  Bloodline
VS.
Maleficent
Dan in Real Life
Baby's Day Out
Rio
Cheaper By the Dozen
Secret Society of Second-Born Royals
Morning Light
The Princess Bride
Cool Runnings
Geek Charming
Ice Princess
The Princess and the Frog
WALL-E
Maggie's Plan
Class
Intersection
Light It Up
The Rocky Horror Picture Show
Transporter 3
Girls! Girls! Girls!
Chasing Trane: The John Coltrane Documentary
Her Name Is Chef
The Donut King
Priceless
Sonic the Hedgehog
Emperor
Bernie the Dolphin 2
Lucky Day
'71
The Wolf Hour
Vault
Brian Banks
Hellbound: Hellraiser II
Untouchable
Ask Dr. Ruth
DriverX
Dust 2 Glory

Part ii

movies_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
8078 s8079 Movie St. Agatha Darren Lynn Bousman Sabrina Kern, Carolyn Hennesy, Courtney Halver... United States August 8, 2019 2018 TV-MA 103 min Horror Movies, Independent Movies Unwed and pregnant, a young woman flees her ab... Netflix
movies_count_df_ii = movies_df["duration"].value_counts().to_frame()
movies_count_df_ii.sample()
duration
20 min 25
longest_duration_for_movies = movies_count_df_ii.sort_index().tail(1).index[0]
longest_duration_for_movies
'99 min'
longest_movies_df = movies_df[movies_df["duration"] == longest_movie_duration ]
longest_movies_df.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
875 s876 Movie Street Dance Dania Pasquini, Max Giwa Nichola Burley, Richard Winsor, Charlotte Ramp... NaN NaN 2013 13+ 99 min Arts, Entertainment, and Culture, Drama A high-energy dance drama about a street dance... Prime
2352 s2353 Movie Dust 2 Glory NaN NaN United States November 15, 2018 2017 NaN 99 min Documentaries Filmmaker Dana Brown explores the SCORE Baja 1... Hulu
print("Longest Movie Duration is : ",longest_movie_duration)
print("The Movies are : ","\n".join(longest_movies_df['title'].to_list()))
Longest Movie Duration is :  99 min
The Movies are :  Woman Of Desire
Why We Fight
Valley Uprising
The Zookeeper
The Woman in Black 2: Angel of Death
The Ultimate Legacy
The Italian Job (1969)
The Hungry
The Donkey King
Super Size Me
Sunshine Hotel
Street Dance
Storm Boy
Shottas
Our Town
My Foolish Heart
Line of Duty
Honest Thief
Hiding Out
Hellbound: Hellraiser 2
Hearts in Bondage
Happythankyoumoreplease
Grace of God
Go Fast. Go North.
Doe
Digging to China
Better Luck Tomorrow
Belle and Sebastian
Atlas Shrugged: Part III
Anna
23 Blast
The Adventurer: The Curse of the Midas Box
Hallowed Be Thy Name
Madness in the Method
Hick
Assault on Wall Street
The Baytown Outlaws
Rolling Stone: Life And Death Of Brian Jones
Dark Was the Night
Caught Up
Stinger
Goodbye, Butterfly
Little Kingdom
PERSECUTION
Blame it On Fidel
Reversion
Happy Home
Super Fast
Intersection
Tusks
The Shootist
DeepStar Six
Firefly
Rock the Casbah
Nightingale: A Melody of Life
Toys Storage 2
Hoop Soldiers
The Naked Truth
Alejandro
P!nk: All I Know So Far
Vivarium
Thaen
CBI Vs Lovers
Night Hunter
DIVOS!
The Map of Tiny Perfect Things
The Booksellers
Seven Days In Utopia
Tales of an American Hoodrat
Road to Damascus
Perfect Strangers
Boonie Bears: The Big Top Secret
Punarjagran
Someone to Carry Me
Kansas City Confidential
The Silent Mountain
Playback
Tobruk
May Morning
The Grotto
Transmigrate (The Troubled One)
B. A. Pass
Sideshow
Angel And The Badman
Partners
M.O.M. Mothers of Monsters
Bottom Feeders
Run For The Sun
All About Steve
Japanese Story
Azhaggiye Thee
Across The Line
Not That Funny
The Woman In The Window
Ilakku
A Social Cure
Black and White
Cruel Train
Delicatessen
Absence of The Good
Fair Play
The Boss
Physical Evidence
Bad Impulse
Mara
Chinese Box
Blue Juice
Route 24
Rebirth
The Descent
Paper Dragons
Alienated
The Bloody Vampire
Passer By
Death Machine
The Omega Code
Golden Job
Madison
Little Man Tate
Totò Eva e il pennello proibito
The Lady Doctor
The Intruder
Outlaws: The Legend of O.B. Taggart
Gli Onorevoli
No Loss, No Gain
The Sacrament
Red Sun Rising
Driven to Dance
The Trench
Ong Bak 3
Dead Serious
What Happens in Vegas
The Rocky Horror Picture Show
InuYasha the Movie 2: The Castle Beyond the Looking Glass
InuYasha the Movie 3: Swords of an Honorable Ruler
Here and There
Good Luck Chuck
My Girl 2
Cousins
Rogue Warfare: Death of a Nation
Copenhagen
Black Holes | The Edge of All We Know
Ninja Assassin
Swordfish
678
Cinema Bandi
Dance of the Forty One
Monster
Dead Again in Tombstone
The Whole Nine Yards
Sniper: Ghost Shooter
The Block Island Sound
The Misadventures of Hedi and Cokeman
Is Love Enough? Sir
Tony Parker: The Final Shot
U-Turn
Dolly Parton’s Christmas on the Square
Zozo
A Babysitter's Guide to Monster Hunting
#Alive
What Keeps You Alive
Ride Like a Girl
Freej Al Taibeen
Curtiz
MindGamers
A Trip to Jamaica
In My Country
Up North
The Bling Lagosians
Rim of the World
Nappily Ever After
Studio 54
The Last Laugh
All's Well, End's Well (2009)
Errementari: The Blacksmith and the Devil
Harishchandrachi Factory
Thi Mai
I Am not an Easy Man
Layla M.
Bad Day for the Cut
The Worthy
#realityhigh
In the Shadow of Iris
Slam
Life 2.0
Operações Especiais
Tini: The New Life of Violetta
Journey to Greenland
Mercenary
Welcome Mr. President
Audrie & Daisy
Winter on Fire: Ukraine's Fight for Freedom
Çok Filim Hareketler Bunlar
50 First Dates
A.X.L.
Adrishya
American Hangman
B.A. Pass
Barely Lethal
Because We're Heading Out
Being AP
Berlin Kaplani
Bobbi Jene
Bobby Robson: More Than a Manager
Bolt
Candyman
Chasing Trane
Christian Mingle
Christmas with the Kranks
Democrats
Detention Letter
Don't Be Afraid of the Dark
Driven to Dance
Eyyvah Eyyvah
Familiye
Fireflies
Froning: The Fittest Man in History
Good Luck
Hangman
Haunting on Fraternity Row
Indiscretion
Inuyasha the Movie - La spada del dominatore del mondo
InuYasha: The Movie 2: The Castle Beyond the Looking Glass
Kaleidoscope
Knock Knock
Kung Fu Hustle
Like Arrows
Mad Money
Mara
May We Chat
My Dog is My Guide
My Scientology Movie
My Week with Marilyn
My Wife and My Wifey
Nowhere Boy
Race to Witch Mountain
Reaction
Salem: His Sister's Father
Say When
The Aerial
The Croods
The Damned Rain
The Drowning
The Heroes of Evil
The Intent
The Invention of Lying
The Nutcracker and the Four Realms
The Sapphires
The Tuxedo
Tremors 5:  Bloodline
VS.
Maleficent
Dan in Real Life
Baby's Day Out
Rio
Cheaper By the Dozen
Secret Society of Second-Born Royals
Morning Light
The Princess Bride
Cool Runnings
Geek Charming
Ice Princess
The Princess and the Frog
WALL-E
Maggie's Plan
Class
Intersection
Light It Up
The Rocky Horror Picture Show
Transporter 3
Girls! Girls! Girls!
Chasing Trane: The John Coltrane Documentary
Her Name Is Chef
The Donut King
Priceless
Sonic the Hedgehog
Emperor
Bernie the Dolphin 2
Lucky Day
'71
The Wolf Hour
Vault
Brian Banks
Hellbound: Hellraiser II
Untouchable
Ask Dr. Ruth
DriverX
Dust 2 Glory

Part iii

movies_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
1999 s2000 Movie Journey Through The Stars Mark Knight NaN NaN NaN 2020 ALL 60 min Documentary, Special Interest An out-of-this-world experience where we dance... Prime
movies_df['duration'].max()
TypeError: ignored
movies_df.idxmax(axis="columns")
TypeError: ignored

Max function tried to compare values in the column. But the column had two datatypes in it - string and float( for null values ). Comparison was not a permitted operation between string and float. Hence the error

Q 4.Shows streaming on multiple platforms [7 points]. See 1:19:12 in the Solutions Video

all_platforms_df.sample()
show_id type title director cast country date_added release_year rating duration listed_in description Platform
2235 s2236 TV Show Dark Desire NaN Maite Perroni, Erik Hayser, Alejandro Speitzer... Mexico July 15, 2020 2020 TV-MA 1 Season Crime TV Shows, International TV Shows, Spanis... Married Alma spends a fateful weekend away fro... Netflix

Part a

print("The number of rows is :",all_platforms_df.shape[0])
The number of rows is : 22998

Part b

unique_titles = all_platforms_df['title'].unique()
unique_titles
array(['The Grand Seduction', 'Take Care Good Night',
       'Secrets of Deception', ..., 'Star Trek: The Original Series',
       'The Twilight Zone', 'Tokyo Magnitude 8.0'], dtype=object)
print('Number of unique titles :',len(unique_titles))
Number of unique titles : 22115
# alternative solution from student submissions
print(f"Number of unique titles: {all_platforms_df['title'].nunique()}")
Number of unique titles: 22115

Part c

titles_count_df = all_platforms_df['title'].value_counts().to_frame()
titles_count_df.sample(2)
title
Once Upon a Time in China III 1
Catch-22 2

Part d

titles_count_df.reset_index(inplace=True)
titles_count_df.rename({
    "index":"name"
}, axis = 1, inplace = True)
titles_count_df.sample(5)
name title
6530 America's Future: The Power of the Latino Vote 1
1021 Flavors of Youth: International Version 1
13793 Rock the Casbah 1
7422 Son of Zorn 1
12259 Celebrity Close Calls 1

Part e

titles_count_df.rename({
    'name' : "Movie or Show Name",
    "title" : "No of Platforms"
}, axis = 1, inplace = True)
titles_count_df.sample(5)
Movie or Show Name No of Platforms
20247 Jeevan Ek Sanghursh 1
21334 Under Crystal Lake 1
4994 Sisters 1
18946 Chhota Bheem & Krishna: Mayanagari 1
17751 Gajendra 1

Part f

max_platform_shows = shows_df['title'].value_counts().to_frame()['title'].max()
max_platform_shows
3
print("The Maximum number of platforms a show is on is ",max_platform_shows)
The Maximum number of platforms a show is on is  3

Q5. Favorite show or movie [2 points]. See 1:31:20 in the Solutions Video

Part a

duplicated_shows = shows_df[shows_df.duplicated(subset=['title'], keep = False)]
duplicated_shows.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
8117 s8118 TV Show Suits NaN Jang Dong-gun, Park Hyung-sik, Jin Hee-kyung, ... South Korea December 1, 2019 2018 TV-MA 1 Season International TV Shows, Korean TV Shows, TV Co... A renowned corporate attorney at a prestigious... Netflix
326 s327 TV Show Cosmos: Possible Worlds NaN Neil deGrasse Tyson United States December 25, 2020 2020 TV-14 1 Season Action-Adventure, Docuseries, Family COSMOS: POSSIBLE WORLDS continues Carl Sagan’s... Disney

Part b

favorite_movie = 'Everything Everywhere All at Once'
all_platforms_df[all_platforms_df['title'].apply(lambda x : True if x.lower()==favorite_movie.lower() else False )]
show_id type title director cast country date_added release_year rating duration listed_in description Platform
random_row = all_platforms_df.sample(1)
random_title = random_row['title'].values[0]
print(random_title)
random_row
Fear Street Part 2: 1978
show_id type title director cast country date_added release_year rating duration listed_in description Platform
479 s480 Movie Fear Street Part 2: 1978 Leigh Janiak Sadie Sink, Emily Rudd, Ryan Simpkins, McCabe ... NaN July 9, 2021 2021 R 111 min Horror Movies In the cursed town of Shadyside, a killer's mu... Netflix
all_platforms_df[all_platforms_df['title'] == random_title]
show_id type title director cast country date_added release_year rating duration listed_in description Platform
479 s480 Movie Fear Street Part 2: 1978 Leigh Janiak Sadie Sink, Emily Rudd, Ryan Simpkins, McCabe ... NaN July 9, 2021 2021 R 111 min Horror Movies In the cursed town of Shadyside, a killer's mu... Netflix

Q 6. Save Data [1 points]. See 1:39:11 in the Solutions Video

target_file_name = "streaming_titles.csv"
all_platforms_df.to_csv(target_file_name,index=False)

Q 7 . Name starts with [8 points]. See 1:39:29 in the Solutions Video

Part a

streaming_titles_df = pd.read_csv(target_file_name)
streaming_titles_df.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
5757 s5758 Movie Wildflower Nicholas DiBella Nathalia Ramos, Cody Longo, Shari Rigby, Alex ... NaN NaN 2016 PG-13 92 min Drama, Suspense When a college student starts having a reoccur... Prime
19196 s722 Movie Alice in Wonderland Clyde Geronimi, Hamilton Luske, Wilfred Jackson Ed Wynn, Richard Haydn, Sterling Holloway, Jer... United States November 12, 2019 1951 G 79 min Action-Adventure, Animation, Family Join Alice as she chases the White Rabbit into... Disney

Part b

first_name = "Enfa"
first_letter_match_movies = movies_df[movies_df['title'].str.startswith(first_name[0])]
first_letter_match_movies.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
6721 s6722 Movie Exit Strategy Michael Whitton Jameel Saleem, Kimelia Weathers, Quincy Harris... United States March 3, 2019 2012 NR 79 min Comedies, Romantic Movies When James's living situation turns sour, he h... Netflix
4188 s4189 Movie Echcharikkai Sarjun Sathyaraj, Varalakshmi Sarathkumar, Kishore Ku... India January 15, 2019 2018 TV-14 127 min International Movies, Thrillers After kidnapping a millionaire’s daughter, two... Netflix

Part c

first_letter_match_shows = shows_df[shows_df['title'].str.startswith(first_name[0])]
first_letter_match_shows.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
2583 s2584 TV Show Ed Gamble: Blood Sugar NaN NaN NaN NaN 2019 16+ 1 Season Arts, Entertainment, and Culture Stand-up comedian Ed Gamble's first special, B... Prime
6690 s6691 TV Show Emogenius NaN Hunter March United States December 15, 2018 2017 TV-PG 1 Season Reality TV Two pairs of contestants go head-to-head for s... Netflix
print("Number of unique shows that start with my first name first letter are : ",len(first_letter_match_shows['title'].unique()))
Number of unique shows that start with my first name first letter are :  140

Part d

TA_first_letter = 'B'
first_letter_match_movies = movies_df[movies_df['title'].str.startswith(TA_first_letter)]
first_letter_match_movies.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
240 s241 Movie Baby's Day Out Patrick Read Johnson Joe Mantegna, Lara Flynn Boyle, Joe Pantoliano... United States April 23, 2021 1994 PG 99 min Action-Adventure, Comedy, Crime Three bumbling kidnappers attempt to nab the b... Disney
4840 s4841 Movie Bad Genius Nattawut Poonpiriya Chutimon Chuengcharoensukying, Chanon Santinat... Thailand June 1, 2018 2017 TV-MA 130 min Dramas, International Movies, Thrillers A top student gets pulled into a cheating rack... Netflix

Part e

first_letter_match_shows = shows_df[shows_df['title'].str.startswith(TA_first_letter)]
first_letter_match_shows.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
9240 s9241 TV Show Bucket NaN Frog Stone, Miriam Margolyes NaN NaN 2017 TV-14 1 Season Comedy, Drama Fran is a reserved high school history teacher... Prime
3151 s3152 TV Show Barbie Dreamtopia NaN Erica Lindbeck, Meira Blinkoff, Lucien Dodge NaN NaN 2019 TV-Y 1 Season Animation, Kids Join Barbie and Chelsea on magical adventures ... Prime
first_name_TA_uniq = len(first_letter_match_shows['title'].unique())
print("Number of unique shows that start with our TA's first name first letter are : ",first_name_TA_uniq)
Number of unique shows that start with our TA's first name first letter are :  428

Part f

first_letter_match_shows = shows_df[shows_df['title'].str.startswith(TA_first_letter)]
first_letter_match_shows.sample(2)
show_id type title director cast country date_added release_year rating duration listed_in description Platform
2801 s2802 TV Show Bakuman NaN NaN Japan May 1, 2016 2010 TV-14 3 Seasons Anime, Comedy, Drama The creators of Death Note return with this in... Hulu
1940 s1941 TV Show Black Jesus NaN NaN United States December 24, 2019 2014 TV-MA 3 Seasons Black Stories, Comedy Black Jesus, the live-action comedy from award... Hulu
last_name_TA_uniq = len(first_letter_match_shows['title'].unique())
print("Number of unique shows that start with our TA's Last name first letter are : ",last_name_TA_uniq)
Number of unique shows that start with our TA's Last name first letter are :  428

Part g

print("Diff between f and g is", last_name_TA_uniq-first_name_TA_uniq)
Diff between f and g is 0