{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Student Assignment Notebook\n",
        "Implement the following functions. Do not change function names or parameters."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "725d8c74",
      "metadata": {},
      "outputs": [],
      "source": [
        "name = \"Zero guy\"\n",
        "roll_number = \"0000\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Sum of Unique Elements\n",
        "\n",
        "Return the sum of unique elements in a list (each element counted once)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_one(nums: list[int]) -> int:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Reverse List\n",
        "\n",
        "Return a new list that is the reverse of input list."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_two(xs: list) -> list:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Count Occurrences\n",
        "\n",
        "Return a dict mapping element -> count."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_three(xs: list) -> dict:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Flatten Nested List (one level)\n",
        "\n",
        "Flatten a list containing lists by one level."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_four(nested: list[list]) -> list:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Invert Dictionary (values -> list of keys)\n",
        "\n",
        "Invert a dict mapping k->v into v->list_of_k."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_five(d: dict) -> dict:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Merge Dicts Summing Values\n",
        "\n",
        "Given two dicts with numeric values, return merged dict summing values for same keys."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_six(a: dict, b: dict) -> dict:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Top-K Frequent Elements (small k)\n",
        "\n",
        "Return top k frequent elements (order not important)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_seven(nums: list[int], k: int) -> list[int]:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Split Words from Sentence\n",
        "\n",
        "Split a sentence into words (split on whitespace)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_eight(s: str) -> list[str]:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Join Words with Separator\n",
        "\n",
        "Join a list of words with given separator."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_nine(words: list[str], sep: str = \" \") -> str:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Longest Word Length\n",
        "\n",
        "Return length of the longest word in sentence."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_ten(sentence: str) -> int:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Set Intersection\n",
        "\n",
        "Return intersection of two lists as a set."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_eleven(a: list, b: list) -> set:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Deduplicate Preserve Order\n",
        "\n",
        "Remove duplicates preserving the first occurrence order."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_twelve(xs: list) -> list:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Square Each Element (map)\n",
        "\n",
        "Return list of squares."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_thirteen(nums: list[int]) -> list[int]:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Filter Even Numbers\n",
        "\n",
        "Return only even numbers in original order."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_fourteen(nums: list[int]) -> list[int]:\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Pandas Series value_counts\n",
        "\n",
        "Given a list, return a pandas Series of value_counts sorted by index."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_fifteen(values: list) -> 'pd.Series':\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Pandas: Split 'name' column into first/last\n",
        "\n",
        "Given DataFrame with column 'name' = 'First Last', split into 'first' and 'last' columns."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_sixteen(df: 'pd.DataFrame') -> 'pd.DataFrame':\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Pandas: Merge two DataFrames on key 'id'\n",
        "\n",
        "Perform inner merge on 'id' and return merged DataFrame."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_seventeen(a: 'pd.DataFrame', b: 'pd.DataFrame') -> 'pd.DataFrame':\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Pandas: Concatenate DataFrames vertically\n",
        "\n",
        "Return concatenated DataFrame with reset index."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_eighteen(dfs: list) -> 'pd.DataFrame':\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Pandas: GroupBy Sum\n",
        "\n",
        "Group by 'key' and sum numeric column 'val'. Return DataFrame sorted by key."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_nineteen(df: 'pd.DataFrame') -> 'pd.DataFrame':\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Pandas: Fill missing values\n",
        "\n",
        "Fill NA in numeric column 'num' with given fill_value and return DataFrame."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def question_twenty(df: 'pd.DataFrame', fill_value=0) -> 'pd.DataFrame':\n",
        "    # TODO: implement\n",
        "    pass\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
