{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1a680ee7",
   "metadata": {},
   "source": [
    "# Control Flow & Data Structures Practice (Instructor Solutions)\n",
    "\n",
    "This notebook contains **15 Python practice problems** focused on **if/elif/else statements, for loops, and lists**.\n",
    "\n",
    "**Difficulty Distribution:**\n",
    "- **7 Extremely Easy Questions** (Questions 1-7)\n",
    "- **5 Intermediate Questions** (Questions 8-12)\n",
    "- **3 Extremely Hard Questions** (Questions 13-15)\n",
    "\n",
    "Each question includes:\n",
    "- Function definition with correct return statements\n",
    "- Clear explanation of what the function should return\n",
    "- Test cases with assertions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17da3759",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = 'student name'\n",
    "roll_number = 'student roll number'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec13c669",
   "metadata": {},
   "source": [
    "---\n",
    "## EXTREMELY EASY QUESTIONS (1-7)\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5481d68c",
   "metadata": {},
   "source": [
    "### 1. Check if a number is odd\n",
    "**Return:** `True` if the number is odd, `False` otherwise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b4b121e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def is_odd(n: int) -> bool:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83d7e03f",
   "metadata": {},
   "source": [
    "### 2. Classify age group\n",
    "**Return:** `'Child'` if age < 13, `'Teen'` if 13-19, `'Adult'` if 20-59, `'Senior'` if 60+"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5febf39a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def classify_age(age: int) -> str:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6695eefe",
   "metadata": {},
   "source": [
    "### 3. Find length of a list\n",
    "**Return:** The length of the list (number of elements)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d7a1dee",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find_length(lst: list) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69f9b169",
   "metadata": {},
   "source": [
    "### 4. Sum all elements in a list\n",
    "**Return:** The sum of all numbers in the list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7739ea9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def total_sum(lst: list[int]) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9a1c835",
   "metadata": {},
   "source": [
    "### 5. Check if list is empty\n",
    "**Return:** `True` if list is empty, `False` otherwise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e96dff75",
   "metadata": {},
   "outputs": [],
   "source": [
    "def is_empty(lst: list) -> bool:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e5849fe",
   "metadata": {},
   "source": [
    "### 6. Get absolute value of a number\n",
    "**Return:** The absolute value (always positive) of the number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6fcf163",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_absolute(n: int) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a8a1a093",
   "metadata": {},
   "source": [
    "### 7. Get the smaller of two numbers\n",
    "**Return:** The minimum value between two numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26506828",
   "metadata": {},
   "outputs": [],
   "source": [
    "def min_of_two(a: int, b: int) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2c2dbdc4",
   "metadata": {},
   "source": [
    "---\n",
    "## INTERMEDIATE QUESTIONS (8-12)\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a67cdb6",
   "metadata": {},
   "source": [
    "### 8. Count how many even numbers in a list\n",
    "**Return:** The count of even numbers\n",
    "**Example:** `[1, 2, 3, 4, 5, 6]` → `3` (because 2, 4, 6 are even)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "981e2681",
   "metadata": {},
   "outputs": [],
   "source": [
    "def count_even(lst: list[int]) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7fdcacc",
   "metadata": {},
   "source": [
    "### 9. Create list of squared numbers\n",
    "**Return:** A new list where each element is squared\n",
    "**Example:** `[1, 2, 3]` → `[1, 4, 9]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9be91799",
   "metadata": {},
   "outputs": [],
   "source": [
    "def square_all(lst: list[int]) -> list[int]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f9998de",
   "metadata": {},
   "source": [
    "### 10. Find maximum value in a list\n",
    "**Return:** The largest number in the list (assume list is not empty)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0615c31c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find_max(lst: list[int]) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d2cd7e37",
   "metadata": {},
   "source": [
    "### 11. Check if a number exists in a list\n",
    "**Return:** `True` if number is in list, `False` otherwise\n",
    "**Example:** `(5, [1, 2, 5, 8])` → `True`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "acfa1ea6",
   "metadata": {},
   "outputs": [],
   "source": [
    "def number_exists(num: int, lst: list[int]) -> bool:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7500d7e3",
   "metadata": {},
   "source": [
    "### 12. Create list with only odd numbers\n",
    "**Return:** A new list containing only odd numbers from input list\n",
    "**Example:** `[1, 2, 3, 4, 5]` → `[1, 3, 5]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "63d6a916",
   "metadata": {},
   "outputs": [],
   "source": [
    "def filter_odd(lst: list[int]) -> list[int]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96f74750",
   "metadata": {},
   "source": [
    "---\n",
    "## EXTREMELY HARD QUESTIONS (13-15)\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88940b64",
   "metadata": {},
   "source": [
    "### 13. Find all pairs in a list that sum to a target\n",
    "**Return:** A list of tuples, where each pair sums to target value\n",
    "**Example:** `([1, 2, 3, 4, 5], 6)` → `[(1, 5), (2, 4)]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0601e9ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find_pairs(lst: list[int], target: int) -> list[tuple]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a36db89b",
   "metadata": {},
   "source": [
    "### 14. Generate Fibonacci sequence up to n terms\n",
    "**Return:** A list of first n Fibonacci numbers\n",
    "**Example:** n=5 → `[0, 1, 1, 2, 3]` (each number is sum of previous two)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "36571dc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def fibonacci(n: int) -> list[int]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "16d43944",
   "metadata": {},
   "source": [
    "### 15. Check if a list is a palindrome\n",
    "**Return:** `True` if list reads the same forwards and backwards, `False` otherwise\n",
    "**Example:** `[1, 2, 3, 2, 1]` → `True`, but `[1, 2, 3]` → `False`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7fc750b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def is_palindrome(lst: list) -> bool:\n",
    "    pass"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv (3.13.7)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
