{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8d521b16",
   "metadata": {},
   "source": [
    "# Part 2: Python Core Syntax - Quick Review for Experienced Developers\n",
    "\n",
    "This document provides a fast-paced review of Python's core syntax for developers already familiar with programming concepts.\n",
    "\n",
    "---\n",
    "\n",
    "### 1. Variables and Basic Data Types\n",
    "\n",
    "- **Dynamic Typing**: No explicit type declaration needed.\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "89b56008",
   "metadata": {},
   "outputs": [],
   "source": [
    "my_string = \"hello\" # str\n",
    "  my_int = 100       # int\n",
    "  my_float = 3.14    # float\n",
    "  my_bool = True     # bool"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d5a03e34",
   "metadata": {},
   "source": [
    "\n",
    "- **F-strings (Formatted String Literals)**: Convenient way to embed expressions inside string literals.\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0ff80ddc",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = \"World\"\n",
    "  print(f\"Hello, {name}!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf46f29f",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "---\n",
    "\n",
    "### 2. Core Data Structures\n",
    "\n",
    "A brief overview of Python's built-in data structures.\n",
    "\n",
    "| Structure | Syntax | Mutable? | Ordered? | Use Case |\n",
    "| :--- | :--- | :---: | :---: | :--- |\n",
    "| **List** | `[1, 2, 3]` | Yes | Yes | General-purpose, ordered collection. |\n",
    "| **Tuple** | `(1, 2, 3)` | No | Yes | Immutable data, function return values, dictionary keys. |\n",
    "| **Dictionary**| `{'a': 1}` | Yes | Yes (3.7+) | Key-value storage. |\n",
    "| **Set** | `{1, 2, 3}` | Yes | No | Uniqueness, mathematical set operations. |\n",
    "\n",
    "---\n",
    "\n",
    "### 3. \"Pythonic\" Idioms\n",
    "\n",
    "- **List Comprehension**: Create lists concisely.\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "583fe509",
   "metadata": {},
   "outputs": [],
   "source": [
    "# squares of even numbers from 0 to 9\n",
    "  squares = [x**2 for x in range(10) if x % 2 == 0]\n",
    "  # [0, 4, 16, 36, 64]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7253cc6b",
   "metadata": {},
   "source": [
    "\n",
    "- **Dictionary/Set Comprehension**:\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60273815",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Dictionary\n",
    "  # {k: v for k, v in some_iterable}\n",
    "  # Set\n",
    "  # {x for x in another_iterable}"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8672f3c5",
   "metadata": {},
   "source": [
    "\n",
    "- **Unpacking**:\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1a7dae9f",
   "metadata": {},
   "outputs": [],
   "source": [
    "a, b, *remaining = [1, 2, 3, 4, 5]\n",
    "  # a=1, b=2, remaining=[3, 4, 5]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "822e90e6",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "---\n",
    "\n",
    "### 4. Control Flow\n",
    "\n",
    "- **Indentation**: Python uses indentation (typically 4 spaces) to define code blocks. There are no curly braces `{}`.\n",
    "- **`if/elif/else`**:\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b344beb4",
   "metadata": {},
   "outputs": [],
   "source": [
    "if score >= 90:\n",
    "      grade = \"A\"\n",
    "  elif score >= 80:\n",
    "      grade = \"B\"\n",
    "  else:\n",
    "      grade = \"F\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5bafa701",
   "metadata": {},
   "source": [
    "\n",
    "- **`for` loop**: Iterates over any sequence.\n",
    "  - Use `enumerate()` to get both index and value.\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8f115d44",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i, item in enumerate(['a', 'b', 'c']):\n",
    "      print(i, item)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a658ec5",
   "metadata": {},
   "source": [
    "\n",
    "- **`while` loop**:\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f0ff841a",
   "metadata": {},
   "outputs": [],
   "source": [
    "count = 5\n",
    "  while count > 0:\n",
    "      count -= 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b30a2dc0",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "---\n",
    "\n",
    "### 5. Functions\n",
    "\n",
    "- **Definition**: Use the `def` keyword.\n",
    "- **Type Hinting** (Optional but recommended):\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0860f49b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet(name: str) -> str:\n",
    "      return f\"Hello, {name}\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68066ae0",
   "metadata": {},
   "source": [
    "\n",
    "- **Multiple Return Values**: Returns a tuple.\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7912ff2a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_point():\n",
    "      return 10, 20\n",
    "\n",
    "  x, y = get_point() # x=10, y=20"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a5ab49f",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "---\n",
    "This covers the fundamental syntax. For a deeper dive, refer to the main [part_2_python_core_syntax.md](./part_2_python_core_syntax.md) document. "
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}
