{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 01 - Introduction to Python"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Jupyter notebooks\n",
    "\n",
    "This is a space where text and code come together to form a coherent document. Throughout the course, we will make use of Jupyter notebooks for illustration purposes and for experimentation. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Objects and Types\n",
    "In a Python program, elements are 'objects'. Each object has a specific data-type.\n",
    "\n",
    "Python guesses the data-type from the object initialization. Let's create a variable `x` that stores the integer `5` and experiment with it."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.131307Z",
     "start_time": "2026-09-27T11:56:50.093901Z"
    }
   },
   "source": [
    "x = 5\n",
    "type(x)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "metadata": {},
     "execution_count": 1
    }
   ],
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.158349Z",
     "start_time": "2026-09-27T11:56:50.134800Z"
    }
   },
   "source": [
    "x = 3.14\n",
    "type(x)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "float"
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.198732Z",
     "start_time": "2026-09-27T11:56:50.172811Z"
    }
   },
   "source": [
    "x = True\n",
    "type(x)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "bool"
      ]
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.278604Z",
     "start_time": "2026-09-27T11:56:50.214624Z"
    }
   },
   "source": [
    "x = \"CSC243\"\n",
    "type(x)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "execution_count": 4
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are two main object types:\n",
    "\n",
    "1. Scalar, cannot be decomposed: `int`, `float`, `bool`, and `NoneType` (seen later)\n",
    "\n",
    "2. Non-Scalar, have internal structure: `string`, `list`, `tuple`, `dict` (last 3 seen later)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The int type\n",
    "The `int` type is used to represent integers and has unlimited precision (bounded by memory restrictions of course). Example integers include:\n",
    "- negative numbers such as: -5, -71, etc.\n",
    "- non-negative numbers such as: 0, 12, 93801, etc."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.320666Z",
     "start_time": "2026-09-27T11:56:50.285441Z"
    }
   },
   "source": [
    "n = 313131000849184902084082114801\n",
    "m = -n*n\n",
    "print(m)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "-98051023692812235870096431307055990841549671033408543269601\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The float type\n",
    "The `float` is used to represent real numbers, up to a certain precision (`float` stands for floating point number).\n",
    "\n",
    "Note here that scientific notation can be used to express floats: 2870 = 2.87 * 1000 = 2.87E3"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.397746Z",
     "start_time": "2026-09-27T11:56:50.328468Z"
    }
   },
   "source": [
    "first_number = 2.87E3\n",
    "print(first_number)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "2870.0\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.503849Z",
     "start_time": "2026-09-27T11:56:50.421635Z"
    }
   },
   "source": [
    "second_number = 5.0\n",
    "print(second_number)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "5.0\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.541742Z",
     "start_time": "2026-09-27T11:56:50.512344Z"
    }
   },
   "source": [
    "their_sum = first_number + second_number\n",
    "print(their_sum)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "2875.0\n"
     ]
    }
   ],
   "execution_count": 8
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.573447Z",
     "start_time": "2026-09-27T11:56:50.545227Z"
    }
   },
   "source": [
    "print(their_sum*2)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "5750.0\n"
     ]
    }
   ],
   "execution_count": 9
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The binary representation of floats uses 64 bits, hence 8 bytes of memory: 1 bit is for the sign, 52 bits are the significant part (a.k.a the mantissa), 11 remaining bits to represent the exponent."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The bool type\n",
    "Used to represent Boolean/logical values: `True` and `False`. In Python, `True` and `False` are keywords (i.e., cannot be used as variable names).\n",
    "\n",
    "Boolean values originate from logical tests, such as the below code:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.599752Z",
     "start_time": "2026-09-27T11:56:50.583847Z"
    }
   },
   "source": [
    "a = (8>3)\n",
    "print(a)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 10
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.652092Z",
     "start_time": "2026-09-27T11:56:50.613519Z"
    }
   },
   "source": [
    "b = (2>3)\n",
    "print(b)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "False\n"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.690745Z",
     "start_time": "2026-09-27T11:56:50.655271Z"
    }
   },
   "source": [
    "c = not b\n",
    "print(c)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Arithmetic Operators\n",
    "The arithmetic operators for the `int` and `float` types include the following: Addition (`+`), Subtraction (`-`), Multiplication (`*`), Division(`/`), Power(`**`)."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.725022Z",
     "start_time": "2026-09-27T11:56:50.702317Z"
    }
   },
   "source": [
    "x = 12.1\n",
    "y = 4"
   ],
   "outputs": [],
   "execution_count": 13
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.766465Z",
     "start_time": "2026-09-27T11:56:50.732049Z"
    }
   },
   "source": [
    "z = x + y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "16.1\n"
     ]
    }
   ],
   "execution_count": 14
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.808951Z",
     "start_time": "2026-09-27T11:56:50.779050Z"
    }
   },
   "source": [
    "z = x - y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "8.1\n"
     ]
    }
   ],
   "execution_count": 15
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.835548Z",
     "start_time": "2026-09-27T11:56:50.814299Z"
    }
   },
   "source": [
    "z = x*y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "48.4\n"
     ]
    }
   ],
   "execution_count": 16
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.866203Z",
     "start_time": "2026-09-27T11:56:50.843876Z"
    }
   },
   "source": [
    "z = x/y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "3.025\n"
     ]
    }
   ],
   "execution_count": 17
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.897251Z",
     "start_time": "2026-09-27T11:56:50.869981Z"
    }
   },
   "source": [
    "z = x**y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "21435.888099999996\n"
     ]
    }
   ],
   "execution_count": 18
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Except for division `/`, if both `x` and `y` are of type `int`, the result is an `int`.  In all other cases, the result is a `float`.\n",
    "\n",
    "All above are **binary** arithmetic operators: they take in **two** operands. There exists the **unary** operator minus `-`: `-x` is the negative of `x`.\n",
    "\n",
    "There are also operators specific to the `int` data-type: \n",
    "\n",
    "- integer division `//`: keeps the integer part of the division of `a//b`\n",
    "\n",
    "- modulo `%`: returns the remainder for the division of `a/b`. Note that it returns an integer which is at least `0` and at most `b-1`. The modulo operator `%` does NOT return the decimal part of said division.\n",
    "\n",
    "Let's try them out."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:50.917490Z",
     "start_time": "2026-09-27T11:56:50.899932Z"
    }
   },
   "source": [
    "x = 12 #x is set to an int"
   ],
   "outputs": [],
   "execution_count": 19
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.021716Z",
     "start_time": "2026-09-27T11:56:50.922945Z"
    }
   },
   "source": [
    "z = x//y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "3\n"
     ]
    }
   ],
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.129324Z",
     "start_time": "2026-09-27T11:56:51.082858Z"
    }
   },
   "source": [
    "y = 5\n",
    "z = x % y # x&y is the remainder of x/y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "2\n"
     ]
    }
   ],
   "execution_count": 21
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.180110Z",
     "start_time": "2026-09-27T11:56:51.140843Z"
    }
   },
   "source": [
    "y = 3 \n",
    "z = x % y \n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "0\n"
     ]
    }
   ],
   "execution_count": 22
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Relational Operators\n",
    "Relational operators are binary operators that evaluate the relationship between two inputs, and output a truth value (i.e., `bool`). For example, the `<` operator evalues if a number is less than another. The `==` operator checks if two operands are the same. The `!=` operator checks if two operands are different.\n",
    "\n",
    "Below are the possibilites."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.206776Z",
     "start_time": "2026-09-27T11:56:51.194820Z"
    }
   },
   "source": [
    "print(z == y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "False\n"
     ]
    }
   ],
   "execution_count": 23
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.234898Z",
     "start_time": "2026-09-27T11:56:51.219215Z"
    }
   },
   "source": [
    "print(z < y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 24
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.257863Z",
     "start_time": "2026-09-27T11:56:51.245108Z"
    }
   },
   "source": [
    "print(z <= y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 25
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.281541Z",
     "start_time": "2026-09-27T11:56:51.268507Z"
    }
   },
   "source": [
    "print(z > y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "False\n"
     ]
    }
   ],
   "execution_count": 26
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.318848Z",
     "start_time": "2026-09-27T11:56:51.294192Z"
    }
   },
   "source": [
    "print(z != y) #not equal check"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 27
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Logical (`bool`) Operators\n",
    "Logical operators accept booleans only as their inputs and -- like relational operators -- return a boolean. The general format is: `x` `operator` `y` --> `z`; where `x`, `y`, and `z` are all boolean."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.338753Z",
     "start_time": "2026-09-27T11:56:51.321900Z"
    }
   },
   "source": [
    "x = True\n",
    "y = False"
   ],
   "outputs": [],
   "execution_count": 28
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.369551Z",
     "start_time": "2026-09-27T11:56:51.341744Z"
    }
   },
   "source": [
    "z = x and y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "False\n"
     ]
    }
   ],
   "execution_count": 29
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.423181Z",
     "start_time": "2026-09-27T11:56:51.381643Z"
    }
   },
   "source": [
    "z = x or y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 30
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.463017Z",
     "start_time": "2026-09-27T11:56:51.431516Z"
    }
   },
   "source": [
    "z = not y\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "True\n"
     ]
    }
   ],
   "execution_count": 31
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Expressions\n",
    "An expression is made up of operators, values and/or variables. An expression can combine more than one operator to form something advanced.\n",
    "\n",
    "Examples:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.507873Z",
     "start_time": "2026-09-27T11:56:51.465259Z"
    }
   },
   "source": [
    "x = 1\n",
    "y = 2\n",
    "z = ((7//2 + 3%2)*2 + y)/2 - 0.5*(x+1)**2\n",
    "print(z)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "3.0\n"
     ]
    }
   ],
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.539423Z",
     "start_time": "2026-09-27T11:56:51.511833Z"
    }
   },
   "source": [
    "not ((x + 2>0) and (x+2) <= 10) or (x==50)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "metadata": {},
     "execution_count": 33
    }
   ],
   "execution_count": 33
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Order of precedance\n",
    "In Python, some operators take precedence over others (i.e., they get executed before others). \n",
    "\n",
    "In general, a good way to remember the precedence of operators is to memorize the PEMDAS acronym. PEMDAS stands for Parenthesis, Exponentiation, Multiplication, Division, Addition, Subtraction. Accordingly, precedence is in this order. \n",
    "\n",
    "In Python, PEMDAS is followed by 'Relational operators', `not`, `and`, and finally the `or` operator.\n",
    "\n",
    "Some examples below:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following expression:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.572496Z",
     "start_time": "2026-09-27T11:56:51.548280Z"
    }
   },
   "source": [
    "-2*3/5+4*5"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "18.8"
      ]
     },
     "metadata": {},
     "execution_count": 34
    }
   ],
   "execution_count": 34
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "is interpreted as:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.590212Z",
     "start_time": "2026-09-27T11:56:51.577880Z"
    }
   },
   "source": [
    "(((-2)*3)/5) +(4*5)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "18.8"
      ]
     },
     "metadata": {},
     "execution_count": 35
    }
   ],
   "execution_count": 35
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following expression:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.627485Z",
     "start_time": "2026-09-27T11:56:51.603295Z"
    }
   },
   "source": [
    "x>=1 and x<10 or x>=20 and x<20"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "metadata": {},
     "execution_count": 36
    }
   ],
   "execution_count": 36
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "is interpreted as:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.651873Z",
     "start_time": "2026-09-27T11:56:51.629879Z"
    }
   },
   "source": [
    "((x>=1) and ( x<10)) or ((x>=20) and(x<20))"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "metadata": {},
     "execution_count": 37
    }
   ],
   "execution_count": 37
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The `str` data-type\n",
    "A string is a sequence of characters delimited by either a singles quotations `'` or double quotations `\"`. For instance, the below are strings:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.690135Z",
     "start_time": "2026-09-27T11:56:51.662734Z"
    }
   },
   "source": [
    "first_string = 'Welcome to your first programming class:' #delimitation by ''\n",
    "print(first_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Welcome to your first programming class:\n"
     ]
    }
   ],
   "execution_count": 38
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.725222Z",
     "start_time": "2026-09-27T11:56:51.692725Z"
    }
   },
   "source": [
    "second_string =  \"CSC243\" #delimiation by \"\"\n",
    "print(second_string)\n",
    "type(second_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "CSC243\n"
     ]
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "metadata": {},
     "execution_count": 39
    }
   ],
   "execution_count": 39
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Concatenation and repetition\n",
    "Strings can be concatenated (put next to each other), repeated, and their length examined. Consider the following code snippets:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.768242Z",
     "start_time": "2026-09-27T11:56:51.729512Z"
    }
   },
   "source": [
    "my_string = first_string + second_string\n",
    "print(my_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Welcome to your first programming class:CSC243\n"
     ]
    }
   ],
   "execution_count": 40
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.797716Z",
     "start_time": "2026-09-27T11:56:51.770661Z"
    }
   },
   "source": [
    "my_string = first_string + \" \" + second_string\n",
    "print(my_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Welcome to your first programming class: CSC243\n"
     ]
    }
   ],
   "execution_count": 41
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.822890Z",
     "start_time": "2026-09-27T11:56:51.808185Z"
    }
   },
   "source": [
    "my_string = second_string*5\n",
    "print(my_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "CSC243CSC243CSC243CSC243CSC243\n"
     ]
    }
   ],
   "execution_count": 42
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.866634Z",
     "start_time": "2026-09-27T11:56:51.836633Z"
    }
   },
   "source": [
    "x = len(my_string)\n",
    "print(x)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "30\n"
     ]
    }
   ],
   "execution_count": 43
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Accessing the characters in a string (using `[] `)\n",
    "We can access a specific character in a string using the access operator `[]`. For instance, we can get the first characater by typing in:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.897983Z",
     "start_time": "2026-09-27T11:56:51.870858Z"
    }
   },
   "source": [
    "st = \"LAU\"\n",
    "\n",
    "first_character = st[0]\n",
    "middle_character = st[1]\n",
    "last_character = st[-1]\n",
    "\n",
    "print(first_character, middle_character, last_character)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "L A U\n"
     ]
    }
   ],
   "execution_count": 44
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Output to the console, using `print()`\n",
    "As we have already seen, to output to the console the contents of variables we make use of the built-in Python function `print()`. For example, we have in the below a variable called `y` with contents equal to the float 5.0."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.927735Z",
     "start_time": "2026-09-27T11:56:51.908801Z"
    }
   },
   "source": [
    "y = 5.0\n",
    "print(y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "5.0\n"
     ]
    }
   ],
   "execution_count": 45
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `print()` function takes as input a variable name as in the above, and outputs the value as a string. Alterntively, `print()` can take in as input a string, and output a string. For example"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:51.964594Z",
     "start_time": "2026-09-27T11:56:51.939449Z"
    }
   },
   "source": [
    "print(\"This string will be printed\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "This string will be printed\n"
     ]
    }
   ],
   "execution_count": 46
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note how the quotations in the string were not displayed; just the actual sequence of characters. If we want our string to contain quotations, we need to make use of the special backslash character `\\` and follow it with single or double quotations. Here, we have:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.012163Z",
     "start_time": "2026-09-27T11:56:51.967529Z"
    }
   },
   "source": [
    "string_with_quotations = \"\\\"This string contains double quotations\\\"\" \n",
    "print(string_with_quotations)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "\"This string contains double quotations\"\n"
     ]
    }
   ],
   "execution_count": 47
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.044852Z",
     "start_time": "2026-09-27T11:56:52.014857Z"
    }
   },
   "source": [
    "string_with_quotations = \"\\'This string contains single quotations\\'\" \n",
    "print(string_with_quotations)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "'This string contains single quotations'\n"
     ]
    }
   ],
   "execution_count": 48
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are other special characters, called escape sequences, that are especially useful for formatting a string to our taste. For example, if we want to go to a newline, we use the `\\n` escape sequence. To insert a tab, we use the `\\t` escape sequence.\n",
    "\n",
    "Some examples:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.074400Z",
     "start_time": "2026-09-27T11:56:52.047304Z"
    }
   },
   "source": [
    "my_string = \"This is line one.\\nThis is line two.\" #notice the effect of the space between \\n and This\n",
    "print(my_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "This is line one.\n",
      "This is line two.\n"
     ]
    }
   ],
   "execution_count": 49
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.123422Z",
     "start_time": "2026-09-27T11:56:52.089185Z"
    }
   },
   "source": [
    "my_string = \"This\\tsentence\\tis\\ton\\ta\\tsingle\\tline.\"\n",
    "print(my_string)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "This\tsentence\tis\ton\ta\tsingle\tline.\n"
     ]
    }
   ],
   "execution_count": 50
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The built-in `print()` function can also take multiples inputs. The result will be printed using the default seperator (a white-space ` `) and default line-ending character (a newline `\\n`). For example, if we have 3 variables with different contents:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.167775Z",
     "start_time": "2026-09-27T11:56:52.138563Z"
    }
   },
   "source": [
    "var1 = \"The speed is equal to\"\n",
    "var2 = 56.1\n",
    "var3 = \"meters per second.\"\n",
    "print(var1, var2, var3)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "The speed is equal to 56.1 meters per second.\n"
     ]
    }
   ],
   "execution_count": 51
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.211548Z",
     "start_time": "2026-09-27T11:56:52.182302Z"
    }
   },
   "source": [
    "x = 1.0\n",
    "y = 2.3\n",
    "print(\"The variable x =\", x, \"and y =\", 2.3)\n",
    "print(\"The variable x = \" + str(x) + \" and y = \" + str( 2.3))"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "The variable x = 1.0 and y = 2.3\n",
      "The variable x = 1.0 and y = 2.3\n"
     ]
    }
   ],
   "execution_count": 52
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice how `var2`, `x`, and `y` -- whose contents are `float` -- were converted to `str` and inserted in their proper order. \n",
    "\n",
    "Also, note how a space ` ` is separating the contents of `var1`, `var2`, and `var3`. We can change the default separator ` ` to **any other string** by specifying the separator parameter as in the below:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.246240Z",
     "start_time": "2026-09-27T11:56:52.223130Z"
    }
   },
   "source": [
    "var1 = \"Lebanese\"\n",
    "var2 = 'American'\n",
    "var3 = \"University\"\n",
    "print(var1, var2, var3)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Lebanese American University\n"
     ]
    }
   ],
   "execution_count": 53
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.277916Z",
     "start_time": "2026-09-27T11:56:52.248737Z"
    }
   },
   "source": [
    "print(var1, var2, var3, sep = \"\\t\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Lebanese\tAmerican\tUniversity\n"
     ]
    }
   ],
   "execution_count": 54
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.307891Z",
     "start_time": "2026-09-27T11:56:52.280585Z"
    }
   },
   "source": [
    "print(var1, var2, var3, sep = \"*****\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Lebanese*****American*****University\n"
     ]
    }
   ],
   "execution_count": 55
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.330601Z",
     "start_time": "2026-09-27T11:56:52.316416Z"
    }
   },
   "source": [
    "print(var1, var2, var3, sep = \"-.-.-.-\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Lebanese-.-.-.-American-.-.-.-University\n"
     ]
    }
   ],
   "execution_count": 56
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.355339Z",
     "start_time": "2026-09-27T11:56:52.341468Z"
    }
   },
   "source": [
    "print(var1, var2, var3, sep = \" | \")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Lebanese | American | University\n"
     ]
    }
   ],
   "execution_count": 57
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally, we can specify the `end` parameter for `print` as well. By default, it is set to `\\n` and consecutive prints will be each displayed on a new line."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.388563Z",
     "start_time": "2026-09-27T11:56:52.367988Z"
    }
   },
   "source": [
    "print(\"first\")\n",
    "print(\"second\")\n",
    "print(\"third\")\n",
    "print(\"fourth\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "first\n",
      "second\n",
      "third\n",
      "fourth\n"
     ]
    }
   ],
   "execution_count": 58
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.427167Z",
     "start_time": "2026-09-27T11:56:52.400259Z"
    }
   },
   "source": [
    "print(\"first\", end=\"\\t\")\n",
    "print(\"second\", end=\"\\n\")\n",
    "print(\"third\", end=\"\\t\")\n",
    "print(\"fourth\")\n",
    "print(\"fifth\", end=\"\")\n",
    "print(\"\\tsixth\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "first\tsecond\n",
      "third\tfourth\n",
      "fifth\tsixth\n"
     ]
    }
   ],
   "execution_count": 59
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data-type conversion (Casting)\n",
    "The `int()` function converts to an integer, whenever possible. The `float()` function converts to a decimal number, whenever possible. The `str()` function converts to a string. \n",
    "\n",
    "Examples:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.444498Z",
     "start_time": "2026-09-27T11:56:52.429819Z"
    }
   },
   "source": [
    "x = 15.5\n",
    "y = int(x)\n",
    "print(y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "15\n"
     ]
    }
   ],
   "execution_count": 60
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.488630Z",
     "start_time": "2026-09-27T11:56:52.458691Z"
    }
   },
   "source": [
    "x = \"97\"\n",
    "y = int(x)\n",
    "print(y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "97\n"
     ]
    }
   ],
   "execution_count": 61
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.528668Z",
     "start_time": "2026-09-27T11:56:52.490886Z"
    }
   },
   "source": [
    "x = \"-15.3\"\n",
    "y = float(x)\n",
    "print(y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "-15.3\n"
     ]
    }
   ],
   "execution_count": 62
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:56:52.547042Z",
     "start_time": "2026-09-27T11:56:52.531353Z"
    }
   },
   "source": [
    "x = 97.8\n",
    "y = str(x)\n",
    "print(y)\n",
    "print(y + y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "97.8\n",
      "97.897.8\n"
     ]
    }
   ],
   "execution_count": 63
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Input from the keyboard\n",
    "The built-in `input` function displays a message to the user, who will input something. Then, the input is stored in a variable as a string. For instance, "
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:01.224690Z",
     "start_time": "2026-09-27T11:56:52.560299Z"
    }
   },
   "source": [
    "height = input(\"Please enter your height (in cms): \")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Please enter your height (in cms): 175\n"
     ]
    }
   ],
   "execution_count": 64
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:01.253956Z",
     "start_time": "2026-09-27T11:57:01.237790Z"
    }
   },
   "source": [
    "print(height)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "175\n"
     ]
    }
   ],
   "execution_count": 65
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:01.304752Z",
     "start_time": "2026-09-27T11:57:01.255361Z"
    }
   },
   "source": [
    "type(height)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "metadata": {},
     "execution_count": 66
    }
   ],
   "execution_count": 66
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The variable `height` stores the value as a string. Hence, it must be converted to an integer using the `int()` function."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:01.342518Z",
     "start_time": "2026-09-27T11:57:01.306544Z"
    }
   },
   "source": [
    "converted_height = int(height)\n",
    "type(converted_height)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "metadata": {},
     "execution_count": 67
    }
   ],
   "execution_count": 67
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:01.360326Z",
     "start_time": "2026-09-27T11:57:01.344232Z"
    }
   },
   "source": [
    "height = int(height)"
   ],
   "outputs": [],
   "execution_count": 68
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:01.397424Z",
     "start_time": "2026-09-27T11:57:01.361609Z"
    }
   },
   "source": [
    "type(height)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "metadata": {},
     "execution_count": 69
    }
   ],
   "execution_count": 69
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alternatively, we could convert the input immediately and using a single line:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:05.119026Z",
     "start_time": "2026-09-27T11:57:01.407199Z"
    }
   },
   "source": [
    "height = int(input(\"Please enter your height (in cms): \"))"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Please enter your height (in cms): 175\n"
     ]
    }
   ],
   "execution_count": 70
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:05.137920Z",
     "start_time": "2026-09-27T11:57:05.125042Z"
    }
   },
   "source": [
    "type(height)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "metadata": {},
     "execution_count": 71
    }
   ],
   "execution_count": 71
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The conversion to integer is necessary here since we might need to perform calculations using the input value later."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Our first program: Swapping two values\n",
    "This first program will illustrate input from the keyboard, variables, escape characters, casting, and output."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:09.054289Z",
     "start_time": "2026-09-27T11:57:05.151095Z"
    }
   },
   "source": [
    "a = input(\"Enter the first integer: \")\n",
    "a = int(a)\n",
    "b = input(\"Enter the second integer: \")\n",
    "b = int(b)\n",
    "## perform swapping, need a temporary variable\n",
    "temp = a\n",
    "a = b\n",
    "b = temp\n",
    "print(\"\\n\")\n",
    "print(\"The first integer is now:\", a)\n",
    "print(\"The second integer is now:\", b)\n",
    "print(\"\\nThis concludes our first code.\")"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Enter the first integer: 3\n",
      "Enter the second integer: 7\n",
      "\n",
      "\n",
      "The first integer is now: 7\n",
      "The second integer is now: 3\n",
      "\n",
      "This concludes our first code.\n"
     ]
    }
   ],
   "execution_count": 72
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Importing modules\n",
    "Often times, there are functions that we might need to import from modules. Such examples include mathematical functions like `cos`, `sin`, `exp`, etc. Other examples include modules that allow for plotting.\n",
    "\n",
    "In the below code, we will examine the `math` module. First, we import it:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:09.081407Z",
     "start_time": "2026-09-27T11:57:09.066929Z"
    }
   },
   "source": [
    "import math"
   ],
   "outputs": [],
   "execution_count": 73
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, say we need to use square-root function `sqrt`. We must specify to Python that it is being retrieved from the `math` module by using the member access `.` operators; as in the below: "
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:10.887865Z",
     "start_time": "2026-09-27T11:57:09.092440Z"
    }
   },
   "source": [
    "x = float(input(\"Enter an integer: \"))\n",
    "y = math.sqrt(x)\n",
    "print(\"The square-root of\", x, \"is\", y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Enter an integer: 16\n",
      "The square-root of 16.0 is 4.0\n"
     ]
    }
   ],
   "execution_count": 74
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alternatively, we can import **just** the `sqrt` method by typing in:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:10.911564Z",
     "start_time": "2026-09-27T11:57:10.897945Z"
    }
   },
   "source": [
    "from math import sqrt"
   ],
   "outputs": [],
   "execution_count": 75
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we don't need to `math.` anymore to use it:"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:11.994001Z",
     "start_time": "2026-09-27T11:57:10.925534Z"
    }
   },
   "source": [
    "x = float(input(\"Enter an integer: \"))\n",
    "y = sqrt(x)\n",
    "print(\"The square-root of\", x,\"is\", y)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Enter an integer: 25\n",
      "The square-root of 25.0 is 5.0\n"
     ]
    }
   ],
   "execution_count": 76
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2026-09-27T11:57:12.014833Z",
     "start_time": "2026-09-27T11:57:12.003954Z"
    }
   },
   "source": [],
   "outputs": [],
   "execution_count": 77
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
