{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "de55150d-5d65-406a-8d24-5e3777cdbc79",
   "metadata": {},
   "source": [
    "# Course Tooling"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c408e24",
   "metadata": {},
   "source": [
    "```{contents}\n",
    ":local:\n",
    ":depth: 2\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4b4e8ed",
   "metadata": {},
   "source": [
    "## Editing Tools\n",
    "\n",
    "For most programming languages, including Python, there are many tools you can use to write, run, and debug programs. Some of the code-editing development tools are full-featured integrated development environments (IDEs), some are lightweight code editors, while others are specialized development environment such as Jupyter and Google Colab.\n",
    "\n",
    "- Full IDEs like PyCharm, IntelliJ, and Visual Studio are comprehensive environments designed for full-scale software development: building complete applications, managing large codebases, and collaborative development. They're the standard choice for professional software engineering where you need structure, performance, and the ability to handle complex projects. Full IDEs have comprehensive tooling: debuggers, refactoring, testing frameworks, and project management. They're heavier but more powerful for large projects. [PyCharm ](https://www.jetbrains.com/pycharm/) is a popular IDE for both learners and professionals, [VS Code](https://code.visualstudio.com/) is a code editor turned full IDE through extensions. \n",
    "\n",
    "- Code editors like Visual Studio Code (**VS Code**), Sublime Text, and Notepad++ are lightweight tools for writing and editing code with features like syntax highlighting and basic autocomplete. They're fast to start up, use minimal resources, and have simpler interfaces. Over time, some editors (e.g., VS Code) have evolved and can function as full IDEs. VS Code has even become the industry standard for general software development. According to the [2025 Stack Overflow Developer Survey](https://survey.stackoverflow.co/2025/), approximately 76% of professional developers and 78% of people learning to code use VS Code, making it the most used and most desired editor for several years running. \n",
    "\n",
    "- Terminal-based editors like **nano** and **vim** in Unix-like (Unix/Linux/macOS) systems run directly in the command line with no graphical interface. Nano is beginner-friendly; vim has a steeper learning curve but is highly efficient once mastered. Both are available on virtually every Unix-like system and are useful when working over SSH or in environments without a GUI. In Windows, **Notepad** is a built-in plain-text editor that is minimal but sufficient for edits. When available, you can always use VS Code for your editing needs.\n",
    "\n",
    "- **Jupyter Notebook** is a specialized development tool. It's an interactive, cell-based environment primarily designed for data analysis, scientific computing, and exploration. You write code in individual cells that you can execute independently, and results (including visualizations and formatted text) appear immediately inline below the cell. Jupyter supports mixing code, markdown documentation, equations, and outputs in a single document, making it excellent for data science.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20bb6aa4",
   "metadata": {},
   "source": [
    "\n",
    "| Feature | Code Editor | Full IDE |\n",
    "|---------|----------------------|--------------------------------------|\n",
    "| Startup Speed | Fast; lightweight | Slower; heavy resource usage |\n",
    "| Language Support | General-purpose; supports features via plugins/extensions | Specialized; deep, native support for specific languages (e.g., C#, Java) |\n",
    "| Setup | Requires manual setup/extensions for tasks | Ready for complex projects immediately after installation |\n",
    "| Cost | Usually free | Often requires paid license for professional version |\n",
    "| Examples | <img src=\"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/vscode/vscode-original.svg\" height=\"16\"> <a href=\"https://code.visualstudio.com/\" style=\"text-decoration:none\">VS Code</a>, <img src=\"https://cdn.simpleicons.org/notepadplusplus?viewbox=auto&size=16\" height=\"16\"> <a href=\"https://notepad-plus-plus.org/\" style=\"text-decoration:none\">Notepad++</a>, <img src=\"https://cdn.simpleicons.org/vim\" height=\"16\"> <a href=\"https://www.vim.org/\" style=\"text-decoration:none\">Vim</a>, <img src=\"https://cdn.simpleicons.org/jupyter\" height=\"16\"> <a href=\"https://jupyter.org\">Jupyter</a>, <a href=\"https://www.nano-editor.org/\" style=\"text-decoration:none\">nano</a> | <img src=\"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/visualstudio/visualstudio-plain.svg\" height=\"16\"> <a href=\"https://visualstudio.microsoft.com/\" style=\"text-decoration:none\">Visual Studio</a>, <img src=\"https://cdn.simpleicons.org/intellijidea\" height=\"16\"> <a href=\"https://www.jetbrains.com/idea/\" style=\"text-decoration:none\">IntelliJ IDEA</a>, <img src=\"https://cdn.simpleicons.org/pycharm\" height=\"16\"> <a href=\"https://www.jetbrains.com/pycharm/\" style=\"text-decoration:none\">PyCharm</a> |\n",
    "\n",
    "   "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f293078",
   "metadata": {},
   "source": [
    "As you progress in learning coding and the technical aspects of information technology, you may find VS Code more useful when you mainly work on coding. Whereas when you need to deal with data flow, visualization, collaboration, and documentation, you may find Jupyter Notebook more preferred."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c42034f-682b-4008-8643-a5f082a1a649",
   "metadata": {},
   "source": [
    "## The File System\n",
    "\n",
    "Unix-like operating systems are file-based, meaning the design principle dictates that everything in the system is a file, and the files are organized as a tree-like file system structure following the [Filesystem Hierarchy Standard](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard). In the CLI (command line interface) terminal, a file **path** is then used to access a file or a directory/folder in the computer’s hierarchical file structure in the absence of a GUI. Windows systems also have a similar directory structure.\n",
    "\n",
    "The file system's tree-like directory structure begins with the **root** (represented by the `/` symbol and `C:\\\\` in Windows systems) directory, which contains several default first-level directories representing various functionalities as shown in the directory tree example below ({numref}`linux_directory_tree`). For example, the `bin` (binary) directory is the standard location contains compiled executable programs (i.e., \"binaries\"), and the `dev` (device) directory contains device files allowing software to communicate with hardware.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "89a1d083",
   "metadata": {
    "mystnb": {
     "figure": {
      "align": "center",
      "caption": "File system directory structure in Unix-like operating systems",
      "name": "linux_directory_tree"
     }
    },
    "tags": [
     "hide-input"
    ]
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA/kAAAHxCAYAAAA2iXxIAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjYsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvq6yFwwAAAAlwSFlzAAAPYQAAD2EBqD+naQAALIVJREFUeJzt3QeUZFWdP/A7MGRoppsMLfQss4DAsksSWGhGAT2IgENQFiUtQRAEV2HXxSUnEys5I0FREQkDIuACC0OjgCsZ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//df5YKK3tzc/vsMOO6RJkyal1157re937r777vTSSy+lCRMmVPI30Rz+4z/+I22//fZp3XXXTdddd10+ANl3333THXfc0Tc1KepnuPrqq/PtaacrRcDfdttt02qrrZauuuqqHNwiaL355psV/VU0qkceeST95je/SRdffHHeNsX+MepKiBOdsf2L4dMRqt544430mc98ZkA9itB/7rnn5oAV28s4IfXcc8+lyy+/PD8e283NN988bwtjPx4HwHGy6qSTTqrsb6bxRCjqvy2L/Wv9dgT2el2N+hnBPsJT1Lc111wz16n+4ndju/nzn/88Pf7443k/DXPru9/9bt6unXjiiemGG27IJ8xn1lkYx4PXXHNN3kdH/YuTnjQ2w/Ur9P777+eGEmduP/vZz+Yzuuecc04+o7v88svnS/2AZGb22GOPtN9+++XrMc8rDkjgo5x55pk5WP3TP/1Tvh09XBtvvHG+PmXKlByavv3tb+dRJmGLLbbIZ3HjgPib3/xmPhBeYIEFctiKk1Hh2muvzQcrq6yySoV/GY3uyCOPTOPHj08/+tGP8u2oS48++mg+kI3QH9vCd955Jz8WJwKi3s3oNWIkyU9+8pO++3bdddc8AgX6i7oUo92WWGKJXO/iYPa2227r254dfvjh6atf/Wp+7t/+7d/m+ydOnJi+/OUv99XPz3/+82mNNdbIYT7209Hb+t///d/58VNOOSXvx2N0ypgxY/reM06+x/YztpMQI+Lq+9iw6qqrDrgdogc1TqDfeeedab755ks777xzeuGFF/q2lXW77bZb7nmt22mnndKf//zn9LGPfWwY/hJKEyNF4hgvThyF+ki6GXn++efTM888kxZddNF8O07Y09j05FcoeqL6z7eP4fZxwDsn4oRA3corr5xeeeWVPHQaZiSGqD7xxBOps7Oz7776sOd6j3wM39pxxx3zwWtc6oHrwQcfzNfrwwQj2NfF9ThAgZmJHtIYqdS/bsVlgw026KtbsxK9rffdd1/64he/OOD+GMYaB8bQ3+qrr54DfojpIbG/jRFHEdLfeuutAQe0sf+M8BX1q67+u4svvnieVle/HvUwxIn5GOYf99Xr8/rrr5+H83d3dw/zX0szm1Vdq9tss80GHDPG8d6cHjdCXUxFuvnmm3PnTowm+aj8ECc56wGf5uCoqEL1M//9b0dIn5sdQ5h//vlzAxXymZlXX30193jOqO7VHw/rrLNO7oWqX66//vo8TLUuAn305Mc86BgyGBchn48So0Si7h188MED6lYMm+5ftz5KrLgfrxGjT2BO9o/1fWRss+pTjdra2gY8HuuU9J+GVJ9D3X8+dfysn/yM7eWVV145oD5/4hOfyI/Nbp2G2alrdf333fXrL7/88rCWlXLEtJCY8nH66afndSDa29vzVLkZiakkNBfD9Ss07VdExW0r6TOUYmGo6PGcUd3rf9B766239vUmzOiAOeZE77333rkn6/7778/z9uOMMMxMHJDGQev3vve9jxwSODuvYbEp5kV929Z/Ab36iagll1xytl8ntpcxEiUW25vRKAIYbP333fXrsV+HGRk9evR0U9liFFNdLKD37//+7/kS04NjTn4M3Y81cmKaybSvRXPxiVUohgxGz319A/3b3/52wPB7GGzR0xTzS7u6uvI85vqcrLfffjtfj3mCCy64YD7YjXlaHxW2YsXWGKYfIV8vPrMSQ09j3YZY1CeC0Uc9b9oDkf6PxdSRWPhsn3326bu/fhAzo5X4YUYBPIadxvz8GPIcol7G4rX1hdBmR8zTv+WWW/LvmC7C7IhQNaNt2+yK48T6vjuuxzYvFuiDGYmOw6gndTFdaWYjhuPYMNZ7iHVIYkSThfWan5BfceCKjXUsZharTj/00EN9i6zE3OgQBx39b8dQmrjA3DrooIPyontxoBtfYRaLRNXP2EbP1KGHHpoXc4wVpSNQxVDAqJ9xQNv/K1Mi2MdQrxiyGmeBYVaOP/74fAARPQIxvy8WKYttWxz0xteGhpgXHfUxvgEiehXqJ6bqjjvuuLTddtvlxdFiEarXX389LzgaQwynnYYCMxLz8+Mk0Xe+85201FJL5UXLTjjhhPw1UnPyDSGx747F/GIBqljMNALcww8/nG666aa8zYRpxYi3WDQ0OnRidFysBTEn4puUYt8ddfYb3/hG7nGd09dg5IjOmFhBP76J5u///u/Tt771rdyRU7f77rvn9cFimlGsxxRf57j22msL+IUQ8isUjSp6AGIRqR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hmy2WabpSOPPDItueSS+eTiBRdc0Pf4Nddck8aPH5/a2trSYostlrbccsv00EMPDfj92L4de+yx6Zlnnunb3sXJyxkNw//Vr36Vf6elpSWPbjrnnHPy4w888MCA7eXMhus//vjjafvtt89ljTLFdjbed2aOO+64/D5//OMfB+G/BTQSIR+AIXPwwQfnA9i33347XXXVVekb3/hG37DTGGq/xBJLVF1EgJm677770p133pl+/vOfpy9+8Ytp//33T/fee29+LMLxNttsk37605+miRMnpqWXXjp9+tOfztu7ECcHYnj9Pvvsk5Zffvl8PS5nn332DN8r5svPN9986Yorrkg//OEP04cffpjvX2211fLvXX311TMt5/PPP59PSPzlL39JF154Ybr00kvTcsstlx588MEZPv+ss85KP/jBD9INN9yQ1lprrUH4TwGNxHB9AIbMpptumq6//vr0k5/8JO255555Ab3onar3UEWvVRyMAjSid999Nwf8COkR6G+77bZ07rnn5h79/ovYffDBB2n99dfPPeO33npr2nbbbfvWDbnppptma6h9jBS46KKLprs/RkLF78YJ05mJkwK1Wi2/9+KLL57v22677XK5pvWzn/0sHXbYYem6665LG2200Rz+R4BmoCcfgCGz99575+GlX/rSl/Iiem+99VZ66qmnqi4WwGwZN25cDvj9T1w+8sgj+Xpsy2Ia0rLLLptGjx7dt4DoK6+8MlfvFa81t+644458EqIe8Ovmn3/+AbfjJEWcXP3yl7+cRx0AZRLyARgycfAb4gC4tbU1X3/jjTcqLhXA7BkzZsx0t19++eXcQx7z3x977LF05plnpnvuuafvK0Pff//9uXqvFVdcca7L2dPTk4fnz0oM+49RBjG66tFHH53r9wMam+H6AAyZl156qe+gd8qUKfn6MsssM9u/H/NTw3vvvTfT58RIgRim+lHPAZgbU6dOne52zL2Pb/eIHv2urq48Fz50d3fP03vFydC5FSdRX3zxxVk+74ADDsjz8Ts7O/NaAb/97W/7trNAObRqAIZMzC+NAB5zQN955528anQsuje76r3/9R6yuX0OwNx48skn82J2dRGKY6G6+uJ6iyyySN9jsfjejMQQ+piqNJQ233zzvIje66+/PuD+aefkx6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oOktu+yy6a677soXYGQS8gGASn3ve99LkydPToccckjVRYGmt+CCC6aNN944X4CRScgHmsITTzyR1l133bToooumnXfeOfX29ub733777XTwwQfnnotFFlkkfepTn0oPPvjgdEMkP//5z6fFF1889xTuscce6dVXX53pe1177bVpvvnmy+/1u9/9Lt/33nvvpW9961tplVVWSQsvvHD+ueeee+b3h0Y1O/X2nnvuSVtssUVabLHF0tJLL50mTJiQHn/88ele64c//GFqa2tLY8eOTTfddNOAx2677ba04YYb5vdob2/PU2A+/PDDAc8566yzcm/9QgstlNZee+30y1/+cgj/chga55xzTlpttdXy/mbllVdO++yzz4DHo+1sv/32ackll8ztJdrTM888M+A5zz33XNpqq61ym9t0003Ts88+O+DxO++8c0B7OvHEE6crx/nnn9/XntZaa6103XXXDdFfDDSlGjDiPfXUU7XYHMTPRrPKKqvksi255JK1MWPG5Otx2XvvvfPju+22W749//zz5+fE9dbW1torr7ySH3/33Xdrq666ar5/scUWqy200EL5emdnZ997HH300fm+/fffv/bwww/XFl988fx61113Xd9zjj/++PycUaNG1drb22sLLrhgvv3yyy/XGlEjf6ala6T//azq7QMPPFBbeOGF833x2NJLL52vX3zxxfnx2267Ld9eYokl8vPiZ9xeccUVa++9915+zqOPPtr3utH24r3i+pFHHtlXjgsvvLCv7ba1tfWV6ZZbbhlQ3v5tsZE00mc6EjXK/7/eHqKexvXLLrustsMOO/Q9/txzz+U29IlPfKJ2xRVX5H3IV77yldq111474O+I/dr5559fu/rqq2vLLbdcbZdddul7jWeffTbvq7bZZpvaDTfcUDvppJPy/ui0007re078XrzOoYceWrvppptqe+yxR37OvffeO12Z+7fnRtEonyeUTMgHmiLkxwHPhx9+WLv00kvz7UUXXbT24IMP5qAQwT2CRoSOLbbYIj9++OGH598/77zz8u0111yz9vrrr9eef/75fFAV9/3mN78ZECx23nnn2tixY/P1CCX9xfvH/fH+Id4rDuLeeOONWiNq5M+0dI30v59Vvd1pp53y41tuuWWtt7c33xdB4Xe/+92AUBOXaG8vvPBCbfTo0fn2k08+mZ+z66675tsRNMKtt97ad1Ktp6en9sEHH9RWWmmlfN9FF12Un3PUUUfl25tsssmA8gr5NPL///vf/34+2TwzEbqXWmqpvK/p7/333x/wd/Q/ARZtYdlll+27fdxxx+WTaW+++Wbfffvss09t3LhxfbdjPxdtti72jXEye999952uTEI+jEyG6wNNYe+9986rBH/pS1/KQxjfeuutdM0118SJyjzU+OMf/3gaPXp02n///fuGIIf6qvwxRDmG66+wwgppxx13HPCcuiuvvDI99dRTaaONNppuCGYMhwwnnXRSHnYcqxd/4QtfyMMtoVHNqt7ecccd+efRRx+dllhiiXx9vfXWS5tsssmA1/nYxz6W1llnnbT88svnRfLCK6+8MqCNHXTQQflnvT2++eab6ZFHHsnvGcOT4/Vjqkz/5/7hD3+Yblg/NHJ7mjp1avra176Wh9S/++67Ax6P9rTNNtvkfU1/888//4DbMRS/Lob8R1uqt4P7778/74NiulhdTEOLNStef/31vufEfXWxb4zb99133yD/xUCzEvKBphBz7kME+foK3BH2QwSPuvr1559/Pv984YUXZvmc/mJ+Y4T/mGPc35FHHpm/5ivmVsYBXsxLjnn+EWSgUc2q3vb09PQFjY/SP3BEGwz1UDKrNlZ/POb718NOtOdY9yLWDHj55ZcH9W+GoRIBPk6WTZo0KW2++eZpqaWWSkcccUTf49Ge6ifBPkr9hFqINhFtqd6eXnvttTyXv7/6Pi8e+6jn1B8HEPKBpvDSSy/ln++//36aMmVKvh698uHFF1/se179+oorrjjbz6nbcsst02WXXZavf/Ob3xzQwxgHZRdffHFesO/GG2/MPTGx0NF55503RH8xzLtZ1dt6eJh24a85Mas2Vn88eis/+OCDvvYc7WuBBRZIyyyzTN/vRfAPEf6hER144IHp4YcfznV8v/32y4vi1RdojfbUvx3MjZaWlr6Tb3X1fV4s5vdRz6k/DiDkA03hoosuykPzf/azn6V33nknH+TEavsxTPE///M/02OPPZZPANTDS/2rg+o/f/zjH6c33ngjH4BdffXVAx6rGzduXF65f/31108PPPBAfs+6q666Kj300EO5R3PrrbfO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ANI7u7u6qi8Ag8VlWz2dQDp9lY/A5lMHnCENPyAdSS0tLam1tTZ2dnVUXhUEUn2l8tgwv7alM2lN1tKnyaE8wtEbVarXaEL8H0AR6enpSb29v1cVgEMUBVFtbW9XFGJG0p/JoT9XSpsqiPcHQEvIBAACgEBbeAwAAgEII+QAAAFAIIR8AAAAKIeQDAABAIYR8AAAAKISQDwAAAIUQ8gEAAKAQQj4AAAAUQsgHAACAQgj5AAAAUAghHwAAAAoh5AMAAEAhhHwAAAAohJAPAAAAhRDyAQAAoBBCPgAAABRCyAcAAIBCCPkAAABQCCEfAAAACiHkAwAAQCGEfAAAACiEkA8AAACFEPIBAACgEEI+AAAAFELIBwAAgEII+QAAAFAIIR8AAAAKIeQDAABAIYR8AAAAKISQDwAAAIUQ8gEAAKAQQj4AAAAUQsgHAACAQgj5AAAAUAghHwAAAAoh5AMAAEAhhHwAAAAohJAPAAAAhRDyAQAAoBBCPgAAABRCyAcAAIBCCPkAAABQCCEfAAAACiHkAwAAQCGEfAAAAEhl+H+ag6PGnJ9IPgAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 1000x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.patches as patches\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(10, 4.8))\n",
    "ax.set_xlim(-0.4, 9.0)\n",
    "ax.set_ylim(-0.1, 4.55)\n",
    "ax.axis('off')\n",
    "\n",
    "W, H   = 1.1, 0.46          # box width, height\n",
    "lw     = 0.9\n",
    "color  = 'black'\n",
    "FONT   = 'monospace'\n",
    "FS     = 10.5\n",
    "\n",
    "Y = [4.1, 2.9, 1.7, 0.5]    # row centre y-coords, top → bottom\n",
    "\n",
    "nodes = {                     # id: (cx, cy, label, bold)\n",
    "    'root':    (4.25, Y[0], '/',       False),\n",
    "    'bin':     (0.5,  Y[1], 'bin',     False),\n",
    "    'dev':     (2.0,  Y[1], 'dev',     False),\n",
    "    'etc':     (3.5,  Y[1], 'etc',     False),\n",
    "    'home':    (5.0,  Y[1], 'home',    False),\n",
    "    'tmp':     (6.5,  Y[1], 'tmp',     False),\n",
    "    'usr':     (8.0,  Y[1], 'usr',     False),\n",
    "    'bill':    (3.5,  Y[2], 'bill',    True),\n",
    "    'patrick': (6.5,  Y[2], 'patrick', False),\n",
    "    'books':   (2.5,  Y[3], 'books',   True),\n",
    "    'school1': (4.5,  Y[3], 'school',  True),\n",
    "    'school2': (6.5,  Y[3], 'school',  False),\n",
    "}\n",
    "\n",
    "tree = {                      # parent → ordered children\n",
    "    'root':    ['bin', 'dev', 'etc', 'home', 'tmp', 'usr'],\n",
    "    'home':    ['bill', 'patrick'],\n",
    "    'bill':    ['books', 'school1'],\n",
    "    'patrick': ['school2'],\n",
    "}\n",
    "\n",
    "BUS_Y = {k: (nodes[k][1] + nodes[v[0]][1]) / 2 for k, v in tree.items()}\n",
    "\n",
    "kw = dict(color=color, lw=lw, solid_capstyle='butt', zorder=1)\n",
    "\n",
    "# ── edges ──\n",
    "for parent, children in tree.items():\n",
    "    px, py, *_ = nodes[parent]\n",
    "    bus_y = BUS_Y[parent]\n",
    "    xs = [nodes[c][0] for c in children]\n",
    "\n",
    "    ax.plot([px, px], [py - H/2, bus_y], **kw)\n",
    "    ax.plot([min(xs), max(xs)], [bus_y, bus_y], **kw)\n",
    "    if not (min(xs) <= px <= max(xs)):\n",
    "        ax.plot([px, min(xs) if px < min(xs) else max(xs)], [bus_y, bus_y], **kw)\n",
    "\n",
    "    for c in children:\n",
    "        cx, cy, *_ = nodes[c]\n",
    "        ax.plot([cx, cx], [bus_y, cy + H/2], **kw)\n",
    "\n",
    "# ── nodes ──\n",
    "for nid, (cx, cy, label, bold) in nodes.items():\n",
    "    ax.add_patch(patches.Rectangle(\n",
    "        (cx - W/2, cy - H/2), W, H,\n",
    "        linewidth=0.9, edgecolor=color, facecolor='white', zorder=3))\n",
    "    ax.text(cx, cy, label, ha='center', va='center',\n",
    "            fontfamily=FONT, fontweight='bold' if bold else 'normal',\n",
    "            fontsize=FS, zorder=4)\n",
    "\n",
    "plt.tight_layout(pad=0.1)\n",
    "from pathlib import Path\n",
    "if Path('../../figures').is_dir():  # refresh the saved figure when building the book\n",
    "    fig.savefig('../../figures/linux_directory_tree.png', dpi=150, bbox_inches='tight')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac610c71",
   "metadata": {},
   "source": [
    "Another first-level directories requires your attention is the `home` (`Users` in Windows and macOS) directory, which contains the users' individual user home directories, specified as `/home/[username]` (`C:\\Users\\` in Windows). Note that when you log into the system in terminal, this `/home/[username]` user home directory is usually your default working directory where the user types commands in the command prompt to interact with the system.\n",
    "\n",
    "In the example above, *bill* and *patrick* are two users and their user home directories are `/home/bill/` and `/home/patrick/` respectively. When a user, for example, *bill* logs into the system, he will be in the `bill` user home directory and if he types a command `ls` and hit Enter, he will see that he has two folders in his user home directory: `books` and `school`.  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e60d34f",
   "metadata": {},
   "source": [
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> ls\n",
    "\n",
    "    Directory: C:\\Users\\[user]\n",
    "\n",
    "Mode                 LastWriteTime         Length Name\n",
    "----                 -------------         ------ ----\n",
    "...\n",
    "d-----          6/5/2026  12:40 AM                books\n",
    "d-----          6/5/2026   2:31 AM                school\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "```bash\n",
    "[user]@[computer]:~$ ls\n",
    "books school\n",
    "\n",
    "[user]@[computer]:~$ ls\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "422161dc",
   "metadata": {},
   "source": [
    "\n",
    "Similarly, in Windows, files and directories are organized in a hierarchical structure; except that drive letters such as `C:` and `D:` are used for separate file structure roots, while Linux uses a unified, hierarchical structure starting from a single **root** (`/`) for all drives and devices. In {numref}`windows11-directory-c-drive`, you see that, in File Explorer, if you click on `Local Disk (C:)` under `This PC`, there is a number of folders and files organized under the `C:` drive, you see a number of first-level directories just like under the root in Linux."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18951042-bf3f-4fb4-931f-52e8ffe3175a",
   "metadata": {},
   "source": [
    "```{figure} ../../figures/windows11-directory-c-drive.png\n",
    ":name: windows11-directory-c-drive\n",
    ":alt: windows11-directory-c-drive\n",
    ":width: 75%\n",
    ":align: center\n",
    "\n",
    "Windows 11 Directory C: Drive\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6fe19608-bd72-4a7f-9e40-fa360b7ca597",
   "metadata": {},
   "source": [
    "If you click to expand the `Users` folder, File Explorer will display the folders (usernames) contained within it. When you select to highlight a username, you will see all the files and directories of that user. In this example in {numref}`windows11-directory-user`, a folder called **`workspace`** is highlighted. \n",
    "\n",
    "Note that, in the CLI, this user home (`C:\\User\\[user]`) folder is the default location when a user logs in, just like in the Unix-like systems. "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ab89182-815e-4a69-90d1-eec0744a3156",
   "metadata": {},
   "source": [
    "```{figure} ../../figures/windows11-directory-user.png\n",
    ":name: windows11-directory-user\n",
    ":alt: windows11-directory-user\n",
    ":width: 75%\n",
    ":align: center\n",
    "\n",
    "Windows 11 Directory Hierarchy from C: Drive to User Home Directory\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c160bf1b-7338-454d-b4de-2a6afe3ff047",
   "metadata": {},
   "source": [
    "## Command Line Basics"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6bbcf6b6",
   "metadata": {},
   "source": [
    "Having some knowledge of using the **command-line interface** (**CLI**) is necessary when learning coding and information technology. A CLI is commonly associated with terms such as command prompt, terminal, command line, console, and shell, although these terms have different technical meanings. In a CLI, users interact with a computer system primarily by entering text commands rather than using a graphical user interface (GUI). This can provide greater speed, automation, and granular control. (For a discussion on terminology such as terminal, console, and shell, see [here](https://www.hanselman.com/blog/whats-the-difference-between-a-console-a-terminal-and-a-shell)).\n",
    "\n",
    "A CLI environment usually includes a terminal application, a system shell, and, when desired, a language REPL: \n",
    "| Term | Definition | Examples |\n",
    "|---|---|---|\n",
    "| **Terminal** | An application program that opens a command-line window and usually starts a default shell. It is called a \"terminal emulator\" because it emulates the locally-attached, text-based \"dumb terminals\" of early computing. | **`Terminal`** (macOS), **`Terminal`** (Windows), `GNOME Terminal` |\n",
    "| **Shell** | A command-line interface to the computer that interprets the user's commands and passes them to the operating system. | **`bash`**, `zsh`, **`PowerShell`** |\n",
    "| **REPL** | A Read–Eval–Print Loop is an interactive environment for evaluating code one expression at a time, in a specific programming language. Also called a \"language shell.\" | **Python shell** (the `>>>` prompt), `csharprepl` for C# |\n",
    "\n",
    "In summary, when you launch a terminal application, there is usually a default system shell, such as `PowerShell`, `bash`, or `zsh`, ready for you to enter commands at the command prompt. A shell can also serve as a scripting language, allowing you to write scripts in addition to entering individual commands.\n",
    "\n",
    ":::{admonition} macOS: Switching from `zsh` to `bash`\n",
    ":class: note\n",
    "\n",
    "If you are a macOS user, modern macOS uses `zsh` as the default shell but `bash` has its advantages. To control which shell to use, open Terminal and use the following commands.\n",
    "\n",
    "|   Action      | Command | Output |\n",
    "|---------------| --------| -----|\n",
    "| To check which shell is active | `echo $0` | either `zsh` or `bash` | \n",
    "| To start a `bash` session temporarily | `bash` | (bash command prompt) `[computer]:~ [user]$` |\n",
    "| To return to `zsh` | `exit` | (zsh pormpt) `[user]@[computer] ~ %` |\n",
    "| To make bash the default login shell | `chsh -s /bin/bash` | (Log out and back in, or reopen Terminal, for the change to take effect) |\n",
    ":::\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "70091598",
   "metadata": {},
   "source": [
    "When you open the CLI terminal application, you mainly use the keyboard, rather than a mouse, to issue text commands (you can still mostly use the mouse to highlight and copy/paste text). To start using the CLI, you start a **terminal session** first.\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "In Windows, you search for *PowerShell*, and you will see **Windows PowerShell** as an app. Click on it and you will see PowerShell window opening. You should see the shell in blue color with a blinking vertical bar at the command prompt line. That's where you type your commands.\n",
    "\n",
    "```powershell\n",
    "Windows PowerShell\n",
    "Copyright (C) Microsoft Corporation. All rights reserved.\n",
    "\n",
    "Loading personal and system profiles took 551ms.\n",
    "PS C:\\Users\\[user]>\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "For macOS/Linux, you search for **Terminal.app**. You then mouse-click on the application or press _Enter_ to open the terminal application and access the shell. If you have not customized your terminal, it may open as a small, plain window, and the default shell may be zsh. The command prompt may have a vertical block and that's where you type your commands.\n",
    "\n",
    "```bash\n",
    "Last login: Sat Sep  5 16:48:40 on ttys001\n",
    "\n",
    "[user]@[computer]:~$ \n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0412e0f2",
   "metadata": {},
   "source": [
    "### Pathname and Special Characters"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb0b7907",
   "metadata": {},
   "source": [
    "Before learning shell commands, it is useful to know the pathname characters that describe locations in the file system. These characters are supported by major shells such as Bash and PowerShell:\n",
    "\n",
    "| Symbol | Meaning | Example |\n",
    "|---|---|---|\n",
    "| **`/`** | The system root for Unix-like systems' file directory tree structure. Also used as a separator for building file paths. | `/Users/alice/data.csv` |\n",
    "| **`\\`** | The path separator for Windows paths, such as `C:\\Users\\[user]`, although Windows recognizes both forward slash (`/`) and backward slash (`\\`) for path separators. In many programming languages, it can also act as an escape character. | `C:\\Users\\alice\\data.csv` |\n",
    "| **`~`** | Represents the user's home directory. | `~/Documents/data.csv` |\n",
    "| **`..`** | The parent directory — relatively one level up from the current directory. | `../data.csv` |\n",
    "| **`.`** | Means the current directory. When placed at the beginning of a filename, it makes the file hidden. | `./data.csv`, `.gitignore` |\n",
    "| `\"My Folder\"` | Quotation marks are used around paths that contain spaces. | `cd \"My Folder\"` |\n",
    "| **`>`** | Redirects a command's output to a file, overwriting the file's existing contents. | `echo hi > out.txt` |\n",
    "| **`>>`** | Redirects a command's output to a file, appending to the end instead of overwriting. | `echo hi >> out.txt` |"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b1495e5",
   "metadata": {},
   "source": [
    "In this section, we are going to use two terminal commands: the `ls` (list) command to show the directories and files in the current directory; and `cd` (change directory) to change into certain locations in the file system directory structure. \n",
    "\n",
    "To `cd` into a directory, you need build directory/file pathnames. There are two kinds of pathnames that you can use to `cd` into the path locations: **absolute path** and **relative path**. \n",
    "\n",
    "| Type | Definition | Example |\n",
    "|---|---|---|\n",
    "| **Absolute path** | The full location of a file or directory, starting from the system root — unambiguous regardless of the current working directory. | `cd /Users/[user]/test_dir/` (Mac/Linux)<br>\n",
    "`cd C:\\Users\\[user]\\test_dir\\` (Windows) |\n",
    "| **Relative path** | A location described relative to the current working directory — depends on where the shell or program is currently running from. | `cd ..` into the user home directory from `test_dir` |\n",
    "\n",
    "When starting the terminal, you should be in the user home directory by default. That is, you should see your username at the command prompt line. If you are not, you can use the change directory (**`cd`**) command to switch directory into your user home directory.\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "You should be in your user home directory when logged in and may see your username. \n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]>\n",
    "```\n",
    "\n",
    "At anytime (including when you just log in), if you are not in your user home directory (e.g., you are in the `C:\\Windows\\System`), `cd` into your user home directory (`~`): \n",
    "\n",
    "```powershell\n",
    "PS C:\\Windows\\System> cd ~\n",
    "PS C:\\Users\\[user]>\n",
    "```\n",
    "\n",
    "You can move up one level in the shell by issuing the command `cd ..`, which means changing directory to the directory one level up. In the case here, you will be moving from your user home directory to the system's `home`/`Users` directory, where you can issue the `ls` command to see the individual user home directories. \n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> cd ..\n",
    "PS C:\\Users>ls\n",
    "\n",
    "    Directory: C:\\Users\n",
    "\n",
    "Mode                 LastWriteTime         Length Name\n",
    "----                 -------------         ------ ----\n",
    "d-r---         8/30/2025   5:52 PM                Public\n",
    "d----l         8/30/2025   4:23 PM                [user1]\n",
    "d-----          9/6/2026   8:00 PM                [user2]\n",
    "\n",
    "PS C:\\Users>\n",
    "```\n",
    "\n",
    "Or, you can build a path/pathname and change directory to the path location. For example, you may want change into your own Desktop folder, which is `/home/[user]/Desktop` if you start the path from the root (`/`).\n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> cd C:\\Users\\[user]\\Desktop\\\n",
    "PS C:\\Users\\[user]\\Desktop>\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "You should be in your user home directory when logged in and may see your computer name and username. \n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~$ \n",
    "```\n",
    "\n",
    "At anytime (including when you just log in), if you are not in your user home directory (e.g., you are in `[user]@[computer]:/Users$`, `cd` into your user home directory (`~`): \n",
    "\n",
    "```bash\n",
    "[user]@[computer]:/Users$ cd ~\n",
    "[user]@[computer]:~$ \n",
    "```\n",
    "\n",
    "You can move up one level in the shell by issuing the command `cd ..`, which means changing directory to the directory one level up. In the case here, you will be moving from your user home directory to the system's `home`/`Users` directory, where you can issue the `ls` command to see the individual user home directories. \n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~$ cd .. \n",
    "[user]@[computer]:/Users$ ls\n",
    "Guest        Shared       [user1] [user2]\n",
    "[user]@[computer]:/Users$ \n",
    "```\n",
    "\n",
    "Or, you can build a path/pathname and change directory to the path location. For example, you may want change into your own Desktop folder, which is `/home/[user]/Desktop` if you start the path from the root (`/`).\n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~$ cd /home/[user]/Desktop\n",
    "[user]@[computer]:~/Desktop$\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57dd62e4-e8f9-4ad8-9e7e-15bf26d41424",
   "metadata": {},
   "source": [
    "### Essential Commands\n",
    "\n",
    "After you know how to describe paths, the essential commands below help you navigate and manage files from the command line.\n",
    "\n",
    "| Group | Command | Name | What it does |\n",
    "|---|---|---|---|\n",
    "| Navigation | `ls` | list | Shows the files and directories in the current directory. |\n",
    "|  | `cd` *path* | change directory | Moves the shell to another directory in the file tree. |\n",
    "|  | `pwd` | print working directory | Shows the full path of the current directory. |\n",
    "| File operations | `mkdir` *foldername* | make directory | Creates a new empty directory. |\n",
    "|   | `touch` *filename* | — | Creates a new empty file or updates the timestamp of an existing file. |\n",
    "|   | `cp` *source_file destination* | copy | Copies a file from the source path to the destination path. |\n",
    "|   | `mv` *source destination* | move | Moves a file or directory. Also used to rename files, e.g. `mv old.txt new.txt`. |\n",
    "|   | `rm` *filename* | remove | Deletes a file. Use carefully — removed files may not go to the trash. |\n",
    "| Output | `echo` *text* | — | Prints text to the terminal, e.g. `echo hello` displays `hello`. |\n",
    "|  | `cat` *filename* | concatenate | Displays the contents of a text file in the terminal. |\n",
    "| Session control | `clear` | — | Clears the terminal screen so the prompt appears at the top again. |\n",
    "|   | `^C` / `Ctrl+C` | — | Interrupts or terminates a running command. |\n",
    "|   | `exit` | — | Exits the current shell session or closes the terminal. |"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6e633d9b",
   "metadata": {},
   "source": [
    "### Creating Directories and Files\n",
    "\n",
    "Suppose that you are in your user home directory and you would like to create a directory/folder called `test_dir` in your home diretory, you may use the `mkdir` command for that purpose and then use `ls` to make sure the directory is created. After that, you will change directory (`cd`) into the `test_dir` you just created, and create a file called test_file.txt with some content using a text editor. \n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> \n",
    "PS C:\\Users\\[user]> mkdir test_dir\n",
    "\n",
    "    Directory: C:\\Users\\[user]\n",
    "\n",
    "Mode                 LastWriteTime         Length Name\n",
    "----                 -------------         ------ ----\n",
    "d-----          9/6/2026  10:34 PM                test_dir\n",
    "\n",
    "PS C:\\Users\\[user]> ls\n",
    "d-----          9/8/2025  11:51 PM                .cache\n",
    "...\n",
    "d-----         9/11/2025  12:01 AM                .ssh\n",
    "...\n",
    "d-r---         8/30/2025   5:52 PM                Contacts\n",
    "d-r---         9/11/2025  12:35 AM                Desktop\n",
    "d-----         9/12/2025  10:27 AM                Documents\n",
    "d-r---        12/25/2025  10:42 PM                Downloads\n",
    "...\n",
    "d-----          9/6/2026  10:34 PM                test_dir\n",
    "...\n",
    "PS C:\\Users\\[user]> \n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "For macOS, instead of `ls`, let's use `ls -l` (`-l` option stands for long format).\n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~$ mkdir test_dir\n",
    "[user]@[computer]:~$ ls\n",
    "total 0\n",
    "...\n",
    "drwxr-xr-x   11 [user]  staff    352 Aug 22 06:57 Applications\n",
    "drwx------@  15 [user]  staff    480 Sep  5 13:26 Desktop\n",
    "drwx------@  15 [user]  staff    480 Sep  4 10:50 Documents\n",
    "drwx------@ 401 [user]  staff  12832 Sep  2 21:56 Downloads\n",
    "...\n",
    "drwxr-xr-x    2 [user]  staff     64 Sep  6 22:39 test_dir\n",
    "...\n",
    "[user]@[computer]:~$\n",
    "```\n",
    "````\n",
    "`````\n",
    "\n",
    "To create a file in the terminal, you may either use an editor or text stream redirection. Let us first change into the `test_dir` and then create a file `test_file.txt` there.\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "Change into `test_dir` then open the editor `Notepad` with an argument `test_file.txt` as the filename.\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> cd test_dir\n",
    "PS C:\\Users\\[user]\\test_dir> notepad test_file.txt\n",
    "```\n",
    "The Windows `Notepad` app will open. You edit the file there, say, e.g., type something like \"keanu reeves is my cousin\" and then from the menu `File` -> `Save` and exit Notepad.\n",
    "\n",
    "You can now `ls` in the test_dir directory and you will see that the file `test_file.txt` is there.\n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]\\test_dir> ls\n",
    "\n",
    "    Directory: C:\\Users\\[user]\\test_dir\n",
    "\n",
    "Mode                 LastWriteTime         Length Name\n",
    "----                 -------------         ------ ----\n",
    "-a----          9/7/2026   1:43 AM             25 test_file.txt\n",
    "\n",
    "PS C:\\Users\\[user]\\test_dir>\n",
    "```\n",
    "\n",
    "Now, to see the content of the file, you can use the `cat` (concatenate) command.\n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]\\test_dir> cat .\\test_file.txt\n",
    "keanu reeves is my cousin\n",
    "PS C:\\Users\\[user]\\test_dir>\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "Change into `test_dir` then open the editor `nano` with an argument `test_file.txt` as the filename.\n",
    "```powershell\n",
    "[user]@[computer]:~$ cd test_dir\n",
    "[user]@[computer]:~/test_dir> nano text_file.txt\n",
    "```\n",
    "The CLI editor `nano` app will open. You edit the file there, say, e.g., type something like \"keanu reeves is my cousin\" and do `Ctl-X` to exit and then `Y` (Yes) to save the modified buffer. Enter again to confirm that the filename: `File Name to Write: test_file.txt` and the nano editor will close.\n",
    "\n",
    "You can now `ls` in the test_dir directory and you will see that the file `test_file.txt` is there.\n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~/test_dir$ ls -l\n",
    "total 8\n",
    "-rw-r--r--  1 [user]  staff  26 Sep  7 01:56 test_file.txt\n",
    "[user]@[computer]:~/test_dir$\n",
    "```\n",
    "\n",
    "Now, to see the content of the file, you can use the `cat` (concatenate) command.\n",
    "\n",
    "```powershell\n",
    "[user]@[computer]:~/test_dir$ cat .\\test_file.txt\n",
    "keanu reeves is my cousin\n",
    "[user]@[computer]:~/test_dir$\n",
    "````\n",
    "`````"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a8f9dc04-b928-4c0a-bace-d3b166007886",
   "metadata": {},
   "source": [
    "## The Python Shell\n",
    "\n",
    "While shell languages such as bash and PowerShell communicate with operating systems, a programming language may have its own \"shell\" or **REPL** (Read-Eval-Print Loop), which serves as a command-line interactive environment for running code written in the programming language. This means that when you type code, the REPL interprets it and displays the results immediately. A REPL perfect for testing snippets, learning syntax, and exploring modules without creating files. Different languages have different REPLs, for example:\n",
    "\n",
    "| Language  | REPL   |\n",
    "|-----------|--------|\n",
    "| Python    | Python shell |\n",
    "| Java      | JShell   |\n",
    "| C#        | CSharpRepl |\n",
    "\n",
    "The Python interpreter features a built-in interactive shell (the **Python shell** or \"the interpreter\"), which is the standard Python REPL and is widely used for quick code test. To access the Python shell, you can start your terminal (PowerShell in Windows Terminal or Terminal in macOS) and type `py` for Windows or `python3` (or `python`) in macOS and hit the Enter/Return key. You will see the **primary prompt**, <span style=\"color: white; background:darkblue\">**>>>**</span>, where you input code for immediate evaluation by the Python interpreter.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "632eb1ff",
   "metadata": {},
   "source": [
    "After entering the Python shell, you can issue an expression for immediate value evaluation such as `1 + 1`.\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "After entering the Python shell by typing `py` and Return, enter `1 + 1`.\n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> py\n",
    "Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:07:00) \n",
    "Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n",
    ">>> 1 + 1\n",
    "2\n",
    ">>>\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "After entering the Python shell by typing `python3` and Enter, enter `1 + 1`, which will evaluate to 2.\n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~$ python3\n",
    "Python 3.12.12 (main, Oct  9 2025, 11:07:00) [Clang 17.0.0 (clang-1700.3.19.1)] on darwin\n",
    "Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n",
    ">>> 1 + 1\n",
    "2\n",
    ">>> \n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "666fab34-bc4b-4552-a1b2-b31e27357fc8",
   "metadata": {},
   "source": [
    "In the Python shell, you may start experiencing Python programming by printing \"hello, world\". You do that by typing `print(\"hello, world\")` at the Python shell:\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} Windows\n",
    "After entering the Python shell (`py`), type `print(\"hello, world\")` and Enter.\n",
    "\n",
    "```powershell\n",
    "PS C:\\Users\\[user]> py\n",
    "Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:07:00) \n",
    "Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n",
    ">>> print(\"hello, world\")\n",
    "hello, world\n",
    ">>>\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} macOS\n",
    "After entering the Python shell (`python3`), type `print(\"hello, world\")` and Return.\n",
    "\n",
    "```bash\n",
    "[user]@[computer]:~/workspace/dsm$ python3\n",
    "Python 3.13.7 (main, Aug 14 2025, 11:12:11) [Clang 17.0.0 (clang-1700.0.13.3)] on darwin\n",
    "Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n",
    ">>> print(\"hello, world\")\n",
    "hello, world\n",
    ">>> \n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv (3.13.13)",
   "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.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
