{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3b350b7a",
   "metadata": {},
   "source": [
    "# Control Flow Assessment\n",
    "\n",
    "This notebook contains **15 Python practice problems** focused on **if/elif/else statements, for loops, and lists**.\n",
    "\n",
    "**Difficulty Distribution:**\n",
    "- **4 Extremely Easy Questions** (Questions 1-4)\n",
    "- **6 Intermediate Questions** (Questions 5-10)\n",
    "- **5 Extremely Hard Questions** (Questions 11-15)\n",
    "\n",
    "Each question includes:\n",
    "- Function definition with correct return statements\n",
    "- Clear explanation of what the function should return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc951a38",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = 'student name'\n",
    "roll_number = 'student roll number'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "283bacce",
   "metadata": {},
   "source": [
    "### 1. Check if a number is even\n",
    "**Return:** `True` if the number is even, `False` otherwise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "be1f8b36",
   "metadata": {},
   "outputs": [],
   "source": [
    "def is_even(n: int) -> bool:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6e631070",
   "metadata": {},
   "source": [
    "### 2. Return the maximum of two numbers\n",
    "**Return:** The larger of two numbers. If they are equal, return either."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6acd4f86",
   "metadata": {},
   "outputs": [],
   "source": [
    "def max_of_two(a: int, b: int) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e6374fe",
   "metadata": {},
   "source": [
    "### 3. Count elements in a list\n",
    "**Return:** The number of elements in the given list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aade60bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "def count_elements(lst: list) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9562ae80",
   "metadata": {},
   "source": [
    "### 4. Return sum of all elements in a list\n",
    "**Return:** The sum of all numbers in the list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b431351",
   "metadata": {},
   "outputs": [],
   "source": [
    "def sum_list(lst: list[int]) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b301f016",
   "metadata": {},
   "source": [
    "### 5. Grade classifier based on marks\n",
    "Given marks, return grade:\n",
    "- 90 and above: 'A'\n",
    "- 80-89: 'B'\n",
    "- 70-79: 'C'\n",
    "- 60-69: 'D'\n",
    "- Below 60: 'F'\n",
    "\n",
    "**Return:** A single character string representing the grade"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dd8c6e6a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def classify_grade(marks: int) -> str:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b9397877",
   "metadata": {},
   "source": [
    "### 6. Filter positive numbers from a list\n",
    "**Return:** A new list containing only positive numbers from the input list\n",
    "**Example:** Input `[-5, 3, -1, 7, 0, 2]` → Output `[3, 7, 2]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "edb4bb53",
   "metadata": {},
   "outputs": [],
   "source": [
    "def filter_positive(lst: list[int]) -> list[int]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "22ca7231",
   "metadata": {},
   "source": [
    "### 7. Reverse a list using a loop\n",
    "**Return:** A new list with elements in reverse order\n",
    "**Example:** Input `[1, 2, 3, 4]` → Output `[4, 3, 2, 1]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bafbb66a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def reverse_list(lst: list) -> list:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "55769736",
   "metadata": {},
   "source": [
    "### 8. Find the maximum element in a list\n",
    "**Return:** The largest number in the list\n",
    "**Example:** Input `[3, 7, 2, 9, 1]` → Output `9`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cecaea10",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find_max(lst: list[int]) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4dc758ea",
   "metadata": {},
   "source": [
    "### 9. Count occurrences of a specific element in a list\n",
    "**Return:** The number of times the element appears in the list\n",
    "**Example:** Input `([1, 2, 3, 2, 4, 2], 2)` → Output `3`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8395541f",
   "metadata": {},
   "outputs": [],
   "source": [
    "def count_occurrences(lst: list, element) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f483e3cd",
   "metadata": {},
   "source": [
    "### 10. Create a multiplication table for a given number\n",
    "**Return:** A list containing the first 10 multiples of the number\n",
    "**Example:** Input `3` → Output `[3, 6, 9, 12, 15, 18, 21, 24, 27, 30]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea0a0f0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def multiplication_table(n: int) -> list[int]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "659c7022",
   "metadata": {},
   "source": [
    "### 11. Find all prime numbers up to n using loops\n",
    "A prime number is a number greater than 1 that has no positive divisors other than 1 and itself.\n",
    "**Return:** A list of all prime numbers from 2 to n (inclusive)\n",
    "**Example:** Input `10` → Output `[2, 3, 5, 7]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "221e6353",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find_primes(n: int) -> list[int]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d435457",
   "metadata": {},
   "source": [
    "### 12. Find the second largest element in a list\n",
    "**Return:** The second largest unique number in the list. If there is no second largest, return `None`\n",
    "**Example:** Input `[10, 5, 8, 12, 3]` → Output `10`\n",
    "**Note:** For `[5, 5, 3]`, the answer is `3` (unique values are considered)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4ccff1c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "def second_largest(lst: list[int]) -> int:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db08829a",
   "metadata": {},
   "source": [
    "### 13. Flatten a nested list (one level deep)\n",
    "**Return:** A single flat list from a list of lists\n",
    "**Example:** Input `[[1, 2], [3, 4], [5]]` → Output `[1, 2, 3, 4, 5]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d870dd1c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def flatten_list(nested_lst: list[list]) -> list:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4cfa7b64",
   "metadata": {},
   "source": [
    "### 14. Find all pairs in a list that sum to a target value\n",
    "**Return:** A list of tuples, where each tuple contains two numbers from the list that sum to the target\n",
    "**Example:** Input `([1, 2, 3, 4, 5], 6)` → Output `[(1, 5), (2, 4)]`\n",
    "**Note:** Each pair should appear only once and should not use the same element twice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e9d5e891",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find_pairs_with_sum(lst: list[int], target: int) -> list[tuple]:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f577ebe9",
   "metadata": {},
   "source": [
    "### 15. Generate Pascal's Triangle up to n rows\n",
    "Pascal's Triangle: Each number is the sum of the two numbers directly above it.\n",
    "```\n",
    "Row 1:     1\n",
    "Row 2:    1 1\n",
    "Row 3:   1 2 1\n",
    "Row 4:  1 3 3 1\n",
    "Row 5: 1 4 6 4 1\n",
    "```\n",
    "**Return:** A list of lists, where each inner list represents a row of Pascal's Triangle\n",
    "**Example:** Input `5` → Output `[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bc9957fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "def generate_pascals_triangle(n: int) -> list[list[int]]:\n",
    "    pass"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
