main a4a08e040f94 cached
110 files
56.5 MB
3.2M tokens
10 symbols
1 requests
Copy disabled (too large) Download .txt
Showing preview only (12,760K chars total). Download the full file to get everything.
Repository: hemansnation/Data-Analyst-Roadmap
Branch: main
Commit: a4a08e040f94
Files: 110
Total size: 56.5 MB

Directory structure:
gitextract_mu6uxmva/

├── July Cohort 2023/
│   └── 1_Python Programming/
│       ├── .ipynb_checkpoints/
│       │   ├── 01_Python Basics-checkpoint.ipynb
│       │   ├── 02_03_While Loop and List-checkpoint.ipynb
│       │   ├── 04_Strings and For loop-checkpoint.ipynb
│       │   └── 05_Dictionary Tuples and Set-checkpoint.ipynb
│       ├── 01_Python Basics.ipynb
│       ├── 02_03_While Loop and List.ipynb
│       ├── 04_Strings and For loop.ipynb
│       └── 05_Dictionary Tuples and Set.ipynb
├── March Cohort 2023/
│   ├── .ipynb_checkpoints/
│   │   ├── 0_Python Basics-checkpoint.ipynb
│   │   ├── 13_14_Object Orientation-checkpoint.ipynb
│   │   ├── 1_While Loops and Logic Building-checkpoint.ipynb
│   │   ├── 2_List and Strings-checkpoint.ipynb
│   │   ├── 3_For Loop Dictionary Tuple and Sets-checkpoint.ipynb
│   │   ├── 4_Functions-checkpoint.ipynb
│   │   └── 5_Modules and Packages-checkpoint.ipynb
│   ├── 0_Python Basics.ipynb
│   ├── 10_11_EDA Project/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 10_11_EDA Project-checkpoint.ipynb
│   │   ├── 10_11_EDA Project.ipynb
│   │   ├── titanic.csv
│   │   └── titanic_cleaned.csv
│   ├── 10_Matplotlib/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 10_Matplotlib-checkpoint.ipynb
│   │   └── 10_Matplotlib.ipynb
│   ├── 12_15_16_17_18_Statistics/
│   │   ├── .ipynb_checkpoints/
│   │   │   ├── 12_15_Statistics-checkpoint.ipynb
│   │   │   ├── 16_17_Statistics and Regression-checkpoint.ipynb
│   │   │   └── 18_Hypothesis Testing-checkpoint.ipynb
│   │   ├── 12_15_Statistics.ipynb
│   │   ├── 16_17_Statistics and Regression.ipynb
│   │   ├── 18_Hypothesis Testing.ipynb
│   │   ├── datasets/
│   │   │   ├── Birthweight_reduced_kg_R.csv
│   │   │   ├── CarPrice_Assignment.csv
│   │   │   ├── Crime_R.csv
│   │   │   ├── IPL2013.csv
│   │   │   ├── SP_500_1987.csv
│   │   │   ├── data_loan.csv
│   │   │   └── forbes.csv
│   │   ├── sample_submission.csv
│   │   ├── test.csv
│   │   └── train.csv
│   ├── 13_14_Object Orientation.ipynb
│   ├── 19_20_Machine Learning/
│   │   ├── .ipynb_checkpoints/
│   │   │   ├── 19_Machine Learning and Linear Regression with One variable-checkpoint.ipynb
│   │   │   └── 20_Logistic Regression-checkpoint.ipynb
│   │   ├── 19_Machine Learning and Linear Regression with One variable.ipynb
│   │   ├── 20_Logistic Regression.ipynb
│   │   ├── areas.csv
│   │   ├── homeprices.csv
│   │   ├── insurance_data.csv
│   │   └── spend.xlsx
│   ├── 1_While Loops and Logic Building.ipynb
│   ├── 21_EDA and Data Viz/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 21_EDA and Data Visualization-checkpoint.ipynb
│   │   ├── 21_EDA and Data Visualization.ipynb
│   │   └── itunes_data.csv
│   ├── 22_23_Time Series Forecasting/
│   │   ├── .ipynb_checkpoints/
│   │   │   ├── 22_Forecasting-checkpoint.ipynb
│   │   │   └── 23_ARIMA-checkpoint.ipynb
│   │   ├── 22_Forecasting.ipynb
│   │   ├── 23_ARIMA.ipynb
│   │   ├── store.xls
│   │   ├── vimana.csv
│   │   └── wsb.csv
│   ├── 24_SQL/
│   │   └── SQLqueriesQandA.sql
│   ├── 2_List and Strings.ipynb
│   ├── 3_For Loop Dictionary Tuple and Sets.ipynb
│   ├── 4_Functions.ipynb
│   ├── 5_Modules and Packages.ipynb
│   ├── 5_Modules-Packages/
│   │   ├── main.py
│   │   ├── rose.py
│   │   └── statsmeme/
│   │       ├── __init__.py
│   │       ├── descriptive.py
│   │       └── inferential.py
│   ├── 6_VirtualEnvironmentAndFlask/
│   │   ├── application.py
│   │   └── templates/
│   │       └── index.html
│   ├── 7_NumPy/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 7_NumPy-checkpoint.ipynb
│   │   └── 7_NumPy.ipynb
│   └── 8_9_Pandas/
│       ├── .ipynb_checkpoints/
│       │   └── 8_9_Pandas-checkpoint.ipynb
│       ├── 8_9_Pandas.ipynb
│       ├── Data Cleaning With Pandas/
│       │   ├── Data Cleaning with Python and Pandas_ Detecting Missing Values.html
│       │   └── Data Cleaning with Python and Pandas_ Detecting Missing Values_files/
│       │       ├── analytics.js.download
│       │       ├── comment-reply.min.js.download
│       │       ├── common.js.download
│       │       ├── css
│       │       ├── css(1)
│       │       ├── css(2)
│       │       ├── custom.js(1).download
│       │       ├── custom.js.download
│       │       ├── custom.min.js.download
│       │       ├── form.js.download
│       │       ├── frontend.min.js.download
│       │       ├── idle-timer.min.js(1).download
│       │       ├── idle-timer.min.js.download
│       │       ├── jquery-migrate.min.js.download
│       │       ├── jquery.js.download
│       │       ├── jquery.uniform.min.js.download
│       │       ├── linkid.js.download
│       │       ├── prism-js.min.js.download
│       │       ├── style(1).css
│       │       ├── style(2).css
│       │       ├── style(3).css
│       │       ├── style.css
│       │       ├── wp-embed.min.js.download
│       │       └── wp-emoji-release.min.js.download
│       ├── indore.csv
│       ├── nyc_weather.csv
│       ├── stock_data.csv
│       ├── stocks_weather.xlsx
│       ├── weather_by_cities.csv
│       ├── weather_data.csv
│       ├── weather_data.xlsx
│       ├── weather_data2.csv
│       ├── weather_datamissing.csv
│       └── weather_datamissing_regex.csv
└── README.md

================================================
FILE CONTENTS
================================================

================================================
FILE: July Cohort 2023/1_Python Programming/.ipynb_checkpoints/01_Python Basics-checkpoint.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5effdff7",
   "metadata": {},
   "source": [
    "# Python Basics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d04e5b22",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello User\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello User\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b0091bf1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "User\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\")\n",
    "print(\"User\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fb83814b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "User\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\\nUser\")    # \\n -> new line character"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "791c342a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\tUser\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\\tUser\")    # \\t -> horizontal tab - 8 spaces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fad4ea5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# binary language -> 101010111 -> bits\n",
    "\n",
    "0 -> low voltage, no-charge, false, off\n",
    "1 -> high voltage, charge, true, on"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1885e98",
   "metadata": {},
   "outputs": [],
   "source": [
    "bits > numbers > character > instructions > program > software"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbe99e7d",
   "metadata": {},
   "outputs": [],
   "source": [
    "source code ---------> Byte Code --------> output\n",
    "    .c       compile     .bak       run      .exe\n",
    "    .cpp                 .obj\n",
    "    .java                .javac\n",
    "    .py                  .pyc"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a713554",
   "metadata": {},
   "source": [
    "# Variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5c20abe8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "995009df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "45.13\n"
     ]
    }
   ],
   "source": [
    "b = 45.13\n",
    "\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "17194c9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "a = \"India\"\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9141a786",
   "metadata": {},
   "source": [
    "# Data Types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "6ba6bfd9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a)\n",
    "\n",
    "print(type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a6e1a232",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.65\n",
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "b = 10.65\n",
    "\n",
    "print(b)\n",
    "\n",
    "print(type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1298d5d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "colors\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "c = \"colors\"\n",
    "\n",
    "print(c)\n",
    "\n",
    "print(type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "47c38fa9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "colors\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "c = 'colors'\n",
    "\n",
    "print(c)\n",
    "\n",
    "print(type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0acb14e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "it's an apple\n"
     ]
    }
   ],
   "source": [
    "x = \"it's an apple\"\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fb2beb48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "it\"s an apple\n"
     ]
    }
   ],
   "source": [
    "x = 'it\"s an apple'\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "814feca5",
   "metadata": {},
   "source": [
    "# Input Function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "437ffd33",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "a = input()\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8c71996c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter Your Name: Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "a = input(\"Enter Your Name: \")\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "792f782d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter Your Name: Himanshu\n",
      "Hello! How are you? Himanshu\n"
     ]
    }
   ],
   "source": [
    "a = input(\"Enter Your Name: \")\n",
    "\n",
    "print(\"Hello! How are you?\", a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8ab7e6a7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello       Him\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello       Him\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84b26329",
   "metadata": {},
   "source": [
    "# Questions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "376a1bc0",
   "metadata": {},
   "outputs": [],
   "source": [
    "Your Name\n",
    "------8-------College/Company\n",
    "------------16-------------Country"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f60668a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "*\n",
    "**\n",
    "***"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c2fa48a",
   "metadata": {},
   "outputs": [],
   "source": [
    "--4--*\n",
    "*----8----*\n",
    "--4--*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2650f9ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "    *\n",
    "*       *\n",
    "    *"
   ]
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/.ipynb_checkpoints/02_03_While Loop and List-checkpoint.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "13c6ac1c",
   "metadata": {},
   "source": [
    "# While Loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0290b931",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "print(\"Himanshu\")\n",
    "print(\"Himanshu\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "aab5a9d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "print(i <= 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "be002b98",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "print(i >= 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "903683b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(i >= 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "76da14cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Himanshu\n",
      "Himanshu\n",
      "Himanshu\n",
      "Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 5:\n",
    "    print(\"Himanshu\")\n",
    "    i = i + 1           # i = 1, 2, 3, 4, 5, 6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "145ad944",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 5:\n",
    "    print(i)\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdad3efc",
   "metadata": {},
   "outputs": [],
   "source": [
    "1\n",
    "2\n",
    "3\n",
    "4\n",
    "5\n",
    "6\n",
    "7\n",
    "8\n",
    "9\n",
    "10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d7d2dfab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 10:\n",
    "    print(i)\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a103c74c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5df8d4f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\"\\n\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c89f0b40",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello+World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\"+\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8a0e5ca8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\" \")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bce809e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello @@@ World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\" @@@ \")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "54435a01",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello@World$"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\"@\")\n",
    "print(\"World\", end=\"$\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95e933ab",
   "metadata": {},
   "source": [
    "### print the following series of numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7a728f28",
   "metadata": {},
   "outputs": [],
   "source": [
    "1 2 3 4 5 6 7 8 9 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "35896fd2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  2  3  4  5  6  7  8  9  10  "
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 10:\n",
    "    print(i, end=\"  \")\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "284eda1a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a * a)\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1cabe31",
   "metadata": {},
   "outputs": [],
   "source": [
    "1  4  9  16  25  36  49  64  81  100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "32f564a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  4  9  16  25  36  49  64  81  100  "
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 10:\n",
    "    print(i*i, end=\"  \")\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "49b1b14e",
   "metadata": {},
   "source": [
    "**Write a program to enter 5 values from user and print them.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a1cd06ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your number: 10\n",
      "10\n",
      "Enter your number: 20\n",
      "20\n",
      "Enter your number: 30\n",
      "30\n",
      "Enter your number: 40\n",
      "40\n",
      "Enter your number: 50\n",
      "50\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 5:\n",
    "    a = input(\"Enter your number: \")\n",
    "    print(a)\n",
    "    i = i + 1\n",
    "    #   1 + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "a1b92062",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 / 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b1e0fc38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 % 2   # modulo - return the reminder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "7279d00f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "10 % 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7ba7e050",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "11 % 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "3c3ea69f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 // 2  # floor division"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "e378bbe4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "15 // 7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5947157a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "153 % 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "07a156bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "15)7(\n",
    "   7"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d490f9d3",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and print reverse of it.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7959c4e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "351"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "960cfd0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "153  % 10 = 3\n",
    "153 // 10 = 15\n",
    "\n",
    "15  % 10 = 5\n",
    "15 // 10 = 1\n",
    "\n",
    "1  % 10 = 1\n",
    "1  // 10 = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "3597feec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your number: 10\n",
      "10\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "n = input(\"Enter your number: \")\n",
    "\n",
    "print(n)\n",
    "\n",
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "71b967e4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your number: 10\n",
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter your number: \"))\n",
    "\n",
    "print(n)\n",
    "\n",
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "5759b2ec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "351"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    print(r, end=\"\")    # 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "adf5586f",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and print sum of its individual digits**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbd3db08",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "1 + 5 + 3\n",
    "\n",
    "9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d76dd47",
   "metadata": {},
   "outputs": [],
   "source": [
    "0 = s\n",
    "3 = s + 3 = s\n",
    "5 = s + 5 = s\n",
    "1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "52deeb6d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "Sum = 9\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10\n",
    "    s = s + r         # s = 0, 3, 8, 9\n",
    "    n = n // 10\n",
    "\n",
    "print(\"Sum =\", s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c2bb6d4f",
   "metadata": {},
   "source": [
    "# Day 3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f4cb0aee",
   "metadata": {},
   "source": [
    "**Write a program to reverse a number**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85d9cb69",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "351 -  this should be a whole number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f31986e9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "351\n",
      "702\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 3, 35, 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "print(s)\n",
    "print(s * 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "949c7e7d",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and check if it palindrome or not**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4fbfc3b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "121\n",
    "\n",
    "121\n",
    "\n",
    "153 = 351 - not a palindrome number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4855f13b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 121\n",
      "Not a Palindrome\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 3, 35, 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "if s == n:\n",
    "    print(\"Palindrome\")\n",
    "else:\n",
    "    print(\"Not a Palindrome\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "90712f12",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 1234321\n",
      "Palindrome\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "temp = n\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 3, 35, 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "if s == temp:\n",
    "    print(\"Palindrome\")\n",
    "else:\n",
    "    print(\"Not a Palindrome\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1a01ec1",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and check if it is armstrong or not**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "20722f78",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "cube(1) + cube(5) + cube(3)\n",
    "\n",
    "370\n",
    "\n",
    "371"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "50334900",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 371\n",
      "Armstrong\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "temp = n\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s + (r*r*r)     # s = 0, 27, 152, 153\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "if s == temp:\n",
    "    print(\"Armstrong\")\n",
    "else:\n",
    "    print(\"Not an Armstrong\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f93f4400",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and print its individual digits on seperate line**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ef97f05",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "1\n",
    "5\n",
    "3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "e3d62d35",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "3\n",
      "5\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    print(r)            # s = 0, 27, 152, 153\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a5bbc5c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "1\n",
      "5\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 27, 152, 153\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "while s > 0:\n",
    "    r = s % 10\n",
    "    print(r)\n",
    "    s = s // 10"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "decf806e",
   "metadata": {},
   "source": [
    "# List\n",
    "\n",
    "collection of different type of elements"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9b33c6ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 10   # int\n",
    "b = 20\n",
    "c = 30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "366b6a7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 'A', 'India', 10.6]\n",
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "l = [10, \"A\", \"India\", 10.6]\n",
    "\n",
    "print(l)\n",
    "\n",
    "print(type(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1af4f02d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "l = [10, \"A\", \"India\", 10.6]\n",
    "#    0    1      2       3\n",
    "\n",
    "print(l[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ced31696",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.6\n"
     ]
    }
   ],
   "source": [
    "print(l[3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0c0905a0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "print(l[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1fe65d17",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [16]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ml\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "print(l[5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c21b0555",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "l = [10, \"A\", \"India\", 10.6]\n",
    "#    0    1      2       3\n",
    "\n",
    "print(type(l[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e9319c1c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[200, 'A', 'India', 10.6]\n"
     ]
    }
   ],
   "source": [
    "l[0] = 200\n",
    "\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f8fe43a4",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list assignment index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [19]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m l[\u001b[38;5;241m5\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1000\u001b[39m\n",
      "\u001b[1;31mIndexError\u001b[0m: list assignment index out of range"
     ]
    }
   ],
   "source": [
    "l[5] = 1000"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2aec1fac",
   "metadata": {},
   "source": [
    "### negative index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d86147ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.6\n"
     ]
    }
   ],
   "source": [
    "#    -4  -3     -2      -1\n",
    "l = [10, \"A\", \"India\", 10.6]\n",
    "#    0    1      2       3\n",
    "\n",
    "print(l[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c3288372",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.6\n"
     ]
    }
   ],
   "source": [
    "print(l[3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "393bd2e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "print(l[0])\n",
    "\n",
    "print(l[-4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "07f8d2b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "print(l[-2])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18ef7bed",
   "metadata": {},
   "source": [
    "# List Slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "f556294d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "61499c7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[22, 33, 44, 10, 24, 36]\n"
     ]
    }
   ],
   "source": [
    "print(l[1:7])         # l[start : end]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "696ceede",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "9c790873",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 24, 36, 68, 99, 81]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[4:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "88f74cab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 81]\n"
     ]
    }
   ],
   "source": [
    "print(l[8:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "59a8810d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11]\n"
     ]
    }
   ],
   "source": [
    "print(l[0:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "da404e2d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[1:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "411185c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[8:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "f3427d62",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "8cb04435",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10]\n"
     ]
    }
   ],
   "source": [
    "print(l[:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "07b3d8c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[0:-4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "6b72269e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[33, 44, 10, 24, 36, 68, 99]\n"
     ]
    }
   ],
   "source": [
    "print(l[2:-2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "34eb2422",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[2:0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "ea9e9d22",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[0:0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "d4d6dc2c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[5:15])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "327f5a53",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [39]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ml\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m15\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "print(l[15])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "1654f679",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[22, 33, 44]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[1:4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "ef550430",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[4:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "64a79df5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[68, 99, 81]\n"
     ]
    }
   ],
   "source": [
    "print(l[-4:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "70fecd4e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[-1:-4])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2b17316",
   "metadata": {},
   "source": [
    "## steps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e9af568f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 33, 10, 36, 99, 100]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[0:11:2])   # l[start : end : steps]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "d0127e99",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 44, 36, 81]\n"
     ]
    }
   ],
   "source": [
    "print(l[0:11:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "75e4fefa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[::])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "3449b6af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[::1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "2e6345c0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100, 81, 99, 68, 36, 24, 10, 44, 33, 22, 11]\n"
     ]
    }
   ],
   "source": [
    "print(l[::-1])   # reverse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "f284f488",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[4:8:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "1f16a88d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 68, 36, 24]\n"
     ]
    }
   ],
   "source": [
    "print(l[8:4:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "11575dee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100, 99, 36, 10, 33, 11]\n"
     ]
    }
   ],
   "source": [
    "print(l[::-2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "1a639620",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "slice step cannot be zero",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [52]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ml\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mValueError\u001b[0m: slice step cannot be zero"
     ]
    }
   ],
   "source": [
    "print(l[::0])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20862888",
   "metadata": {},
   "source": [
    "## list functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "8aa952c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "source": [
    "l = [10,20,30,40,50]\n",
    "\n",
    "print(len(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "74856061",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(len(l) - 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "250b458e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "150\n"
     ]
    }
   ],
   "source": [
    "print(sum(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "7ea78614",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50\n"
     ]
    }
   ],
   "source": [
    "print(max(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "bad8aadc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "print(min(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "27a21618",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [58]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m l \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m10\u001b[39m,\u001b[38;5;241m20\u001b[39m,\u001b[38;5;241m30\u001b[39m]\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43msum\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ml\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "l = [\"A\", 10,20,30]\n",
    "\n",
    "print(sum(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "a176b651",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(len(l))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1ee80d7b",
   "metadata": {},
   "source": [
    "# List methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "e802bef5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help(print)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "5a500f31",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# help(list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "0538c1e8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40]\n"
     ]
    }
   ],
   "source": [
    "l = [10,20,30]\n",
    "\n",
    "l.append(40)\n",
    "\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "ed712c2b",
   "metadata": {},
   "outputs": [],
   "source": [
    "l.append(\"India\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "265b8be2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "ea15af1f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(l.index('India'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "c422ce83",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(l.index(10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "0e88a9f3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "e3042d8a",
   "metadata": {},
   "outputs": [],
   "source": [
    "l.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "02a28ba4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "7c861f47",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['India', 40, 30, 20, 10]\n"
     ]
    }
   ],
   "source": [
    "print(l[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "e1210f8f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ef9c13af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/.ipynb_checkpoints/04_Strings and For loop-checkpoint.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "89086545",
   "metadata": {},
   "source": [
    "# Strings\n",
    "\n",
    "set of characters\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "663dd2fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n"
     ]
    }
   ],
   "source": [
    "#       -1\n",
    "s = 'hello'\n",
    "#    01234\n",
    "\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d1f891e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "h\n"
     ]
    }
   ],
   "source": [
    "print(s[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "549cabfa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "o\n"
     ]
    }
   ],
   "source": [
    "print(s[4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e9b26f8e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "o\n"
     ]
    }
   ],
   "source": [
    "print(s[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bef31594",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "l\n"
     ]
    }
   ],
   "source": [
    "print(s[-2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "00f3823f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7326e7a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(s[0]))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4899cd30",
   "metadata": {},
   "source": [
    "# string slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "12c56ed2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "commu\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "#    0123456789\n",
    "\n",
    "print(s[0:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "781ea5cd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "noitacinummoc\n"
     ]
    }
   ],
   "source": [
    "print(s[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "90aa93d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "omm\n"
     ]
    }
   ],
   "source": [
    "print(s[1:4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5c24d8b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "#    0123456789\n",
    "\n",
    "print(s[4:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a8f6af2e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "s = ''\n",
    "\n",
    "print(type(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2d3570c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "noitacin\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "#    0123456789\n",
    "\n",
    "print(s[-1:-9:-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef70cbf4",
   "metadata": {},
   "source": [
    "# String Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f12266cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "\n",
    "print(len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "50320c72",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [15]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43msum\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "print(sum(s))   # s = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "55b002c3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "u\n"
     ]
    }
   ],
   "source": [
    "print(max(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7ccced34",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n"
     ]
    }
   ],
   "source": [
    "print(min(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8b30e14f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# ASCII\n",
    "\n",
    "'A' -> 65\n",
    "'B' -> 66\n",
    "'Z' -> 90\n",
    "\n",
    "'a' -> 97\n",
    "'z' -> 122\n",
    "\n",
    "' ' -> 32 -> space"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "afa17626",
   "metadata": {},
   "source": [
    "## string methods\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e3ef73fb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# help(str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "53f436a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'raj123' == 'RAJ123'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "9a9f840d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "raj123\n"
     ]
    }
   ],
   "source": [
    "s = 'RAJ123'\n",
    "\n",
    "print(s.casefold())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "4e6cd479",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INDIA\n"
     ]
    }
   ],
   "source": [
    "s = 'India'\n",
    "\n",
    "print(s.upper())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "76b04479",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "india\n"
     ]
    }
   ],
   "source": [
    "print(s.lower())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "2e8f43e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['This', 'is', 'an', 'apple']\n"
     ]
    }
   ],
   "source": [
    "# split\n",
    "\n",
    "s = 'This is an apple'\n",
    "\n",
    "print(s.split(\" \"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "94237ec7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['H', 'llo Us', 'r']\n"
     ]
    }
   ],
   "source": [
    "s = \"Hello User\"\n",
    "\n",
    "print(s.split(\"e\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "42a71402",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This+is+an+apple\n"
     ]
    }
   ],
   "source": [
    "# join\n",
    "\n",
    "l = ['This', 'is', 'an', 'apple']\n",
    "\n",
    "a = \"+\"\n",
    "\n",
    "print(a.join(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "6ef43d06",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is an apple\n"
     ]
    }
   ],
   "source": [
    "# join\n",
    "\n",
    "l = ['This', 'is', 'an', 'apple']\n",
    "\n",
    "a = \" \"\n",
    "\n",
    "print(a.join(l))\n",
    "#   \" \".join(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "dae0d39a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ThisisanApple\n"
     ]
    }
   ],
   "source": [
    "# remove all the spaces from the string\n",
    "\n",
    "s = \"This is an Apple\"\n",
    "\n",
    "l = s.split(\" \")\n",
    "\n",
    "x = \"\".join(l)\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e18c7bc",
   "metadata": {},
   "source": [
    "**Write a program to enter a string from user and print the biggest word from the para**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc9ffad3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "08b8681d",
   "metadata": {},
   "source": [
    "# range function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "cd95ff5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(0, 5)\n"
     ]
    }
   ],
   "source": [
    "n = range(5)   # this will create a series of numbers from 0 to 4\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "5faa24f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'range'>\n"
     ]
    }
   ],
   "source": [
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "b9b1b6fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4]\n"
     ]
    }
   ],
   "source": [
    "n = list(range(5))\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "00bf5fc9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 4, 5, 6, 7]\n"
     ]
    }
   ],
   "source": [
    "n = list(range(3,8))\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "85f51f76",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(range(20) == range(0,20))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "cf56e7cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[5, 7, 9, 11, 13, 15, 17, 19]\n"
     ]
    }
   ],
   "source": [
    "n = list(range(5,20,2))    # range(start, end, steps)\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a9e11b2",
   "metadata": {},
   "source": [
    "## for loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "eb461d52",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "l = [\"A\", \"B\", \"C\", \"D\"]\n",
    "\n",
    "print(\"Z\" in l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "f3d37b0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "B\n",
      "C\n",
      "D\n"
     ]
    }
   ],
   "source": [
    "l = [\"A\", \"B\", \"C\", \"D\"]\n",
    "#                    i\n",
    "\n",
    "#  \"B\" in l\n",
    "for i in l:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "15a3f0ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "Hi\n",
      "B\n",
      "Hi\n",
      "C\n",
      "Hi\n",
      "D\n",
      "Hi\n"
     ]
    }
   ],
   "source": [
    "l = [\"A\", \"B\", \"C\", \"D\"]\n",
    "#     i\n",
    "\n",
    "#  \"B\" in l\n",
    "for i in l:\n",
    "    print(i)\n",
    "    print(\"Hi\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "59f4f57f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "b\n",
      "c\n",
      "d\n"
     ]
    }
   ],
   "source": [
    "s = 'abcd'\n",
    "\n",
    "for i in s:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "be302d25",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AB\n",
      "ab\n"
     ]
    }
   ],
   "source": [
    "x = 'ab'\n",
    "\n",
    "print(x.upper())\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "b3a22f15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['ab', 'cd']\n"
     ]
    }
   ],
   "source": [
    "x = ['ab', 'cd']\n",
    "\n",
    "for i in x:\n",
    "    i.upper()        # 'ab'.upper() -> 'AB'\n",
    "    \n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "4e0873d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AB\n",
      "CD\n",
      "['ab', 'cd']\n"
     ]
    }
   ],
   "source": [
    "x = ['ab', 'cd']\n",
    "\n",
    "for i in x:\n",
    "    print(i.upper())        # 'ab'.upper() -> 'AB'\n",
    "    \n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "77e96be5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "b\n",
      "c\n",
      "d\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "for i in x:\n",
    "    print(i)\n",
    "    x.upper()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d6c07e4d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "#             i\n",
    "#         0,1,2,3,4\n",
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "bba46637",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in range(5,10):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "fdb6483c",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'str' object cannot be interpreted as an integer",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [48]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mabcd\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mrange\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[0;32m      4\u001b[0m     \u001b[38;5;28mprint\u001b[39m(i)\n",
      "\u001b[1;31mTypeError\u001b[0m: 'str' object cannot be interpreted as an integer"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "for i in range(x):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "dac1b7e1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "ce020a17",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'int' object has no attribute 'upper'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[1;32mIn [50]\u001b[0m, in \u001b[0;36m<cell line: 4>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;66;03m#          0,1,2,3\u001b[39;00m\n\u001b[0;32m      4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(x)):\n\u001b[1;32m----> 5\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[43mi\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupper\u001b[49m())\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'int' object has no attribute 'upper'"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    print(i.upper())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "e4b348f0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "abcd\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    x[i].upper()\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "e4afa49b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "B\n",
      "C\n",
      "D\n",
      "abcd\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    print(x[i].upper())\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "9d691550",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "a\n",
      "a\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#         0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    x = 'a'               # x = 'abcd', 'a', 'a'\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fe9971b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/.ipynb_checkpoints/05_Dictionary Tuples and Set-checkpoint.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "34a4e5e6",
   "metadata": {},
   "source": [
    "# Dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb73a69f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# { key : value }\n",
    "\n",
    "unordered data structures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9c5ff7b6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'ravi': 24, 'shyam': 21, 'roy': 41}\n"
     ]
    }
   ],
   "source": [
    "ages = {\"ravi\":24, \"shyam\": 21, \"roy\": 41}\n",
    "\n",
    "print(ages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fc51983d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "print(type(ages))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "45957197",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24\n"
     ]
    }
   ],
   "source": [
    "print(ages['ravi'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8587855f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "41\n"
     ]
    }
   ],
   "source": [
    "print(ages['roy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bcc42db7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[255, 0, 0]\n"
     ]
    }
   ],
   "source": [
    "color = {\n",
    "    \"red\": [255,0,0],\n",
    "    \"green\": [0,255,0],\n",
    "    \"blue\": [0,0,255]\n",
    "}\n",
    "print(color['red'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f28a6d43",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'yellow'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[1;32mIn [7]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mcolor\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43myellow\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mKeyError\u001b[0m: 'yellow'"
     ]
    }
   ],
   "source": [
    "print(color['yellow'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "98fd771e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "d = {}\n",
    "print(d)\n",
    "print(type(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "02b6f0ff",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unhashable type: 'list'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [9]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m d \u001b[38;5;241m=\u001b[39m {[\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m]:\u001b[38;5;241m10\u001b[39m, \u001b[38;5;241m2\u001b[39m:\u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m3\u001b[39m:\u001b[38;5;241m3\u001b[39m}\n\u001b[0;32m      2\u001b[0m \u001b[38;5;28mprint\u001b[39m(d)\n",
      "\u001b[1;31mTypeError\u001b[0m: unhashable type: 'list'"
     ]
    }
   ],
   "source": [
    "d = {[1,2]:10, 2:2, 3:3}\n",
    "print(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "080bd938",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100, 20]\n"
     ]
    }
   ],
   "source": [
    "# list are mutable objects\n",
    "\n",
    "l = [10,20]\n",
    "l[0] = 100\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0efe853a",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'str' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [11]\u001b[0m, in \u001b[0;36m<cell line: 4>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# strings are immutable objects\u001b[39;00m\n\u001b[0;32m      3\u001b[0m s \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mindore\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 4\u001b[0m s[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m      5\u001b[0m \u001b[38;5;28mprint\u001b[39m(s)\n",
      "\u001b[1;31mTypeError\u001b[0m: 'str' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "# strings are immutable objects\n",
    "\n",
    "s = 'indore'\n",
    "s[0] = \"A\"\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6de43fed",
   "metadata": {},
   "source": [
    "# Dictionary Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "da7184d8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "d = {1:11, 2:41, 13:9, 14:16}\n",
    "\n",
    "print(len(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2439c0d6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "30\n"
     ]
    }
   ],
   "source": [
    "print(sum(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "3842f621",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [14]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m a \u001b[38;5;241m=\u001b[39m {\u001b[38;5;241m1\u001b[39m:\u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m3\u001b[39m:\u001b[38;5;241m4\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhi\u001b[39m\u001b[38;5;124m\"\u001b[39m:\u001b[38;5;241m16\u001b[39m}\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43msum\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ma\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "a = {1:2, 3:4, \"hi\":16}\n",
    "\n",
    "print(sum(a))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72a7d21d",
   "metadata": {},
   "source": [
    "# Dictionary Methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "dda87168",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 'Apple', 'orange': [2, 3, 4], '2': '23'}\n"
     ]
    }
   ],
   "source": [
    "pair = {1:\"Apple\", \"orange\": [2,3,4], \"2\":\"23\"}\n",
    "\n",
    "print(pair)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "031cb949",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2, 3, 4]\n"
     ]
    }
   ],
   "source": [
    "# get\n",
    "# help(dict)\n",
    "\n",
    "print(pair.get(\"orange\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "cba8f060",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "print(pair.get(7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32604209",
   "metadata": {},
   "outputs": [],
   "source": [
    "None ==> NULL ==> nothing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d7d265af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Apple\n"
     ]
    }
   ],
   "source": [
    "print(pair.get(1,\"Element not found\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ff1c3065",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Element not found\n"
     ]
    }
   ],
   "source": [
    "print(pair.get(10,\"Element not found\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "a75186b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 'Apple', 'orange': [2, 3, 4], '2': '23'}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "# clear\n",
    "\n",
    "p = {1:\"Apple\", \"orange\": [2,3,4], \"2\":\"23\"}\n",
    "\n",
    "print(p)\n",
    "p.clear()\n",
    "print(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "d153a547",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys([1, 2, 3])\n"
     ]
    }
   ],
   "source": [
    "# keys\n",
    "\n",
    "r = {1:\"A\", 2:'Zara', 3:\"Maza\"}\n",
    "\n",
    "print(r.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b0c31ff7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3]\n"
     ]
    }
   ],
   "source": [
    "print(list(r.keys()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "0afa95ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_values(['A', 'Zara', 'Maza'])\n"
     ]
    }
   ],
   "source": [
    "# values\n",
    "\n",
    "r = {1:\"A\", 2:'Zara', 3:\"Maza\"}\n",
    "\n",
    "print(r.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "9c024e2a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['A', 'Zara', 'Maza']\n"
     ]
    }
   ],
   "source": [
    "print(list(r.values()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "4d0c19d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{3: 'Maza', 2: 'Zara'}\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "r = {3:\"A\", 2:'Zara', 3:\"Maza\"}\n",
    "\n",
    "print(r)\n",
    "\n",
    "print(len(r))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "104a3ab9",
   "metadata": {},
   "source": [
    "# Question\n",
    "\n",
    "print the following series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f5a1e63",
   "metadata": {},
   "outputs": [],
   "source": [
    "{1:1, 2:4, 3:9, 4:16, .........10:100}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "7c6a9d9a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 2, 3: 'Hi'}\n"
     ]
    }
   ],
   "source": [
    "a = {1:2}\n",
    "a[3] = \"Hi\"\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "e1ec63ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100}\n"
     ]
    }
   ],
   "source": [
    "d = {}\n",
    "\n",
    "for i in range(1,11):\n",
    "    d[i] = i * i\n",
    "\n",
    "print(d)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae9ad8ce",
   "metadata": {},
   "source": [
    "# Tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "926d2c80",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(4, 3, 5, 6)\n",
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "t = (4,3,5,6)\n",
    "#    0 1 2 3\n",
    "\n",
    "print(t)\n",
    "\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "0184a528",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(t[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "67632ef3",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [33]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m t[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m11\u001b[39m\n",
      "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "t[0] = 11  # tuple are immutable objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b6045c0f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('one', 'two', 'three')\n"
     ]
    }
   ],
   "source": [
    "t = \"one\", \"two\", \"three\"\n",
    "\n",
    "print(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "ffa2af8b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "2efc8510",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "t = (10)\n",
    "print(t)\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "da1bb799",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(10,)\n",
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "t = (10,)\n",
    "print(t)\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4cae5690",
   "metadata": {},
   "source": [
    "# Tuple unpacking"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "58a607f3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "n = (1,2,3)\n",
    "\n",
    "a,b,c = n\n",
    "\n",
    "print(a)\n",
    "print(b)\n",
    "print(c)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b276c6bf",
   "metadata": {},
   "source": [
    "# Tuple Slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "92e79ee4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(11, 22, 33, 44, 55, 66, 77, 88, 99, 100)\n"
     ]
    }
   ],
   "source": [
    "#                               -1\n",
    "t = (11,22,33,44,55,66,77,88,99,100)\n",
    "#    0  1  \n",
    "\n",
    "print(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "57630079",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(44, 55)\n"
     ]
    }
   ],
   "source": [
    "print(t[3:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "fec889a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(11, 22, 33, 44, 55, 66)\n"
     ]
    }
   ],
   "source": [
    "print(t[:6])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "503f8dba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(33, 44, 55, 66)\n"
     ]
    }
   ],
   "source": [
    "print(t[-8:-4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "a0ba748f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "()\n"
     ]
    }
   ],
   "source": [
    "print(t[-4:-8])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "fa4cc944",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(100, 99, 88, 77, 66, 55, 44, 33, 22, 11)\n"
     ]
    }
   ],
   "source": [
    "print(t[::-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b4af08a",
   "metadata": {},
   "source": [
    "# Tuple Methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "7bbdf0aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "# count\n",
    "\n",
    "t = (2,3,4,5,5,6,6,4,4,)\n",
    "\n",
    "print(t.count(4))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "ad80d733",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "# index\n",
    "\n",
    "t = (2,3,4,5,5,6,6,4,4,)\n",
    "\n",
    "print(t.index(4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "df41de26",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function index:\n",
      "\n",
      "index(value, start=0, stop=9223372036854775807, /) method of builtins.tuple instance\n",
      "    Return first index of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(t.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "86d6e3a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7\n"
     ]
    }
   ],
   "source": [
    "# index\n",
    "\n",
    "t = (2,3,4,5,5,6,6,4,4,)\n",
    "\n",
    "print(t.index(4, 5))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff55ace0",
   "metadata": {},
   "source": [
    "# Tuple functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "d2e05c64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "source": [
    "t = (2,3,4,5,6)\n",
    "\n",
    "print(len(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "2f71a91b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20\n"
     ]
    }
   ],
   "source": [
    "print(sum(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "f9c6d5a3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n"
     ]
    }
   ],
   "source": [
    "print(max(t))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23dad4a2",
   "metadata": {},
   "source": [
    "# Question"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1ee0321",
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove i from this tuple\n",
    "\n",
    "t = ('a', 'e','i', 'o', 'u')"
   ]
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/01_Python Basics.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5effdff7",
   "metadata": {},
   "source": [
    "# Python Basics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d04e5b22",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello User\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello User\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b0091bf1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "User\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\")\n",
    "print(\"User\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fb83814b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "User\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\\nUser\")    # \\n -> new line character"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "791c342a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\tUser\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\\tUser\")    # \\t -> horizontal tab - 8 spaces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fad4ea5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# binary language -> 101010111 -> bits\n",
    "\n",
    "0 -> low voltage, no-charge, false, off\n",
    "1 -> high voltage, charge, true, on"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1885e98",
   "metadata": {},
   "outputs": [],
   "source": [
    "bits > numbers > character > instructions > program > software"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbe99e7d",
   "metadata": {},
   "outputs": [],
   "source": [
    "source code ---------> Byte Code --------> output\n",
    "    .c       compile     .bak       run      .exe\n",
    "    .cpp                 .obj\n",
    "    .java                .javac\n",
    "    .py                  .pyc"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a713554",
   "metadata": {},
   "source": [
    "# Variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5c20abe8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "995009df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "45.13\n"
     ]
    }
   ],
   "source": [
    "b = 45.13\n",
    "\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "17194c9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "a = \"India\"\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9141a786",
   "metadata": {},
   "source": [
    "# Data Types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "6ba6bfd9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a)\n",
    "\n",
    "print(type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a6e1a232",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.65\n",
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "b = 10.65\n",
    "\n",
    "print(b)\n",
    "\n",
    "print(type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1298d5d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "colors\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "c = \"colors\"\n",
    "\n",
    "print(c)\n",
    "\n",
    "print(type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "47c38fa9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "colors\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "c = 'colors'\n",
    "\n",
    "print(c)\n",
    "\n",
    "print(type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0acb14e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "it's an apple\n"
     ]
    }
   ],
   "source": [
    "x = \"it's an apple\"\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fb2beb48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "it\"s an apple\n"
     ]
    }
   ],
   "source": [
    "x = 'it\"s an apple'\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "814feca5",
   "metadata": {},
   "source": [
    "# Input Function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "437ffd33",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "a = input()\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8c71996c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter Your Name: Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "a = input(\"Enter Your Name: \")\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "792f782d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter Your Name: Himanshu\n",
      "Hello! How are you? Himanshu\n"
     ]
    }
   ],
   "source": [
    "a = input(\"Enter Your Name: \")\n",
    "\n",
    "print(\"Hello! How are you?\", a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8ab7e6a7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello       Him\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello       Him\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84b26329",
   "metadata": {},
   "source": [
    "# Questions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "376a1bc0",
   "metadata": {},
   "outputs": [],
   "source": [
    "Your Name\n",
    "------8-------College/Company\n",
    "------------16-------------Country"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f60668a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "*\n",
    "**\n",
    "***"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c2fa48a",
   "metadata": {},
   "outputs": [],
   "source": [
    "--4--*\n",
    "*----8----*\n",
    "--4--*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2650f9ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "    *\n",
    "*       *\n",
    "    *"
   ]
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/02_03_While Loop and List.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "13c6ac1c",
   "metadata": {},
   "source": [
    "# While Loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0290b931",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "print(\"Himanshu\")\n",
    "print(\"Himanshu\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "aab5a9d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "print(i <= 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "be002b98",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "print(i >= 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "903683b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(i >= 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "76da14cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Himanshu\n",
      "Himanshu\n",
      "Himanshu\n",
      "Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 5:\n",
    "    print(\"Himanshu\")\n",
    "    i = i + 1           # i = 1, 2, 3, 4, 5, 6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "145ad944",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 5:\n",
    "    print(i)\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdad3efc",
   "metadata": {},
   "outputs": [],
   "source": [
    "1\n",
    "2\n",
    "3\n",
    "4\n",
    "5\n",
    "6\n",
    "7\n",
    "8\n",
    "9\n",
    "10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d7d2dfab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 10:\n",
    "    print(i)\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a103c74c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5df8d4f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\"\\n\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c89f0b40",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello+World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\"+\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8a0e5ca8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\" \")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bce809e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello @@@ World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\" @@@ \")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "54435a01",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello@World$"
     ]
    }
   ],
   "source": [
    "print(\"Hello\", end=\"@\")\n",
    "print(\"World\", end=\"$\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95e933ab",
   "metadata": {},
   "source": [
    "### print the following series of numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7a728f28",
   "metadata": {},
   "outputs": [],
   "source": [
    "1 2 3 4 5 6 7 8 9 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "35896fd2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  2  3  4  5  6  7  8  9  10  "
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 10:\n",
    "    print(i, end=\"  \")\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "284eda1a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a * a)\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1cabe31",
   "metadata": {},
   "outputs": [],
   "source": [
    "1  4  9  16  25  36  49  64  81  100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "32f564a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  4  9  16  25  36  49  64  81  100  "
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 10:\n",
    "    print(i*i, end=\"  \")\n",
    "    i = i + 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "49b1b14e",
   "metadata": {},
   "source": [
    "**Write a program to enter 5 values from user and print them.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a1cd06ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your number: 10\n",
      "10\n",
      "Enter your number: 20\n",
      "20\n",
      "Enter your number: 30\n",
      "30\n",
      "Enter your number: 40\n",
      "40\n",
      "Enter your number: 50\n",
      "50\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i <= 5:\n",
    "    a = input(\"Enter your number: \")\n",
    "    print(a)\n",
    "    i = i + 1\n",
    "    #   1 + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "a1b92062",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 / 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b1e0fc38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 % 2   # modulo - return the reminder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "7279d00f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "10 % 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7ba7e050",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "11 % 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "3c3ea69f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 // 2  # floor division"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "e378bbe4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "15 // 7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5947157a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "153 % 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "07a156bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "15)7(\n",
    "   7"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d490f9d3",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and print reverse of it.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7959c4e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "351"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "960cfd0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "153  % 10 = 3\n",
    "153 // 10 = 15\n",
    "\n",
    "15  % 10 = 5\n",
    "15 // 10 = 1\n",
    "\n",
    "1  % 10 = 1\n",
    "1  // 10 = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "3597feec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your number: 10\n",
      "10\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "n = input(\"Enter your number: \")\n",
    "\n",
    "print(n)\n",
    "\n",
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "71b967e4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your number: 10\n",
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter your number: \"))\n",
    "\n",
    "print(n)\n",
    "\n",
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "5759b2ec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "351"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    print(r, end=\"\")    # 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "adf5586f",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and print sum of its individual digits**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbd3db08",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "1 + 5 + 3\n",
    "\n",
    "9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d76dd47",
   "metadata": {},
   "outputs": [],
   "source": [
    "0 = s\n",
    "3 = s + 3 = s\n",
    "5 = s + 5 = s\n",
    "1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "52deeb6d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "Sum = 9\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10\n",
    "    s = s + r         # s = 0, 3, 8, 9\n",
    "    n = n // 10\n",
    "\n",
    "print(\"Sum =\", s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c2bb6d4f",
   "metadata": {},
   "source": [
    "# Day 3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f4cb0aee",
   "metadata": {},
   "source": [
    "**Write a program to reverse a number**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85d9cb69",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "351 -  this should be a whole number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f31986e9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "351\n",
      "702\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 3, 35, 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "print(s)\n",
    "print(s * 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "949c7e7d",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and check if it palindrome or not**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4fbfc3b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "121\n",
    "\n",
    "121\n",
    "\n",
    "153 = 351 - not a palindrome number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4855f13b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 121\n",
      "Not a Palindrome\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 3, 35, 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "if s == n:\n",
    "    print(\"Palindrome\")\n",
    "else:\n",
    "    print(\"Not a Palindrome\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "90712f12",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 1234321\n",
      "Palindrome\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "temp = n\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 3, 35, 351\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "if s == temp:\n",
    "    print(\"Palindrome\")\n",
    "else:\n",
    "    print(\"Not a Palindrome\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1a01ec1",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and check if it is armstrong or not**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "20722f78",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "cube(1) + cube(5) + cube(3)\n",
    "\n",
    "370\n",
    "\n",
    "371"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "50334900",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 371\n",
      "Armstrong\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "temp = n\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s + (r*r*r)     # s = 0, 27, 152, 153\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "if s == temp:\n",
    "    print(\"Armstrong\")\n",
    "else:\n",
    "    print(\"Not an Armstrong\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f93f4400",
   "metadata": {},
   "source": [
    "**Write a program to enter a number from user and print its individual digits on seperate line**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ef97f05",
   "metadata": {},
   "outputs": [],
   "source": [
    "153\n",
    "\n",
    "1\n",
    "5\n",
    "3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "e3d62d35",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "3\n",
      "5\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    print(r)            # s = 0, 27, 152, 153\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a5bbc5c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter a number: 153\n",
      "1\n",
      "5\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "n = int(input(\"Enter a number: \"))\n",
    "s = 0\n",
    "\n",
    "while n > 0:\n",
    "    r = n % 10          # r = 3, 5, 1\n",
    "    s = s*10 + r        # s = 0, 27, 152, 153\n",
    "    n = n // 10         # n = 153, 15, 1, 0\n",
    "\n",
    "while s > 0:\n",
    "    r = s % 10\n",
    "    print(r)\n",
    "    s = s // 10"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "decf806e",
   "metadata": {},
   "source": [
    "# List\n",
    "\n",
    "collection of different type of elements"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9b33c6ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 10   # int\n",
    "b = 20\n",
    "c = 30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "366b6a7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 'A', 'India', 10.6]\n",
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "l = [10, \"A\", \"India\", 10.6]\n",
    "\n",
    "print(l)\n",
    "\n",
    "print(type(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1af4f02d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "l = [10, \"A\", \"India\", 10.6]\n",
    "#    0    1      2       3\n",
    "\n",
    "print(l[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ced31696",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.6\n"
     ]
    }
   ],
   "source": [
    "print(l[3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0c0905a0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "print(l[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1fe65d17",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [16]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ml\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "print(l[5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c21b0555",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "l = [10, \"A\", \"India\", 10.6]\n",
    "#    0    1      2       3\n",
    "\n",
    "print(type(l[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e9319c1c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[200, 'A', 'India', 10.6]\n"
     ]
    }
   ],
   "source": [
    "l[0] = 200\n",
    "\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f8fe43a4",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list assignment index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [19]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m l[\u001b[38;5;241m5\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1000\u001b[39m\n",
      "\u001b[1;31mIndexError\u001b[0m: list assignment index out of range"
     ]
    }
   ],
   "source": [
    "l[5] = 1000"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2aec1fac",
   "metadata": {},
   "source": [
    "### negative index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d86147ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.6\n"
     ]
    }
   ],
   "source": [
    "#    -4  -3     -2      -1\n",
    "l = [10, \"A\", \"India\", 10.6]\n",
    "#    0    1      2       3\n",
    "\n",
    "print(l[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c3288372",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.6\n"
     ]
    }
   ],
   "source": [
    "print(l[3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "393bd2e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "print(l[0])\n",
    "\n",
    "print(l[-4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "07f8d2b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "print(l[-2])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18ef7bed",
   "metadata": {},
   "source": [
    "# List Slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "f556294d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "61499c7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[22, 33, 44, 10, 24, 36]\n"
     ]
    }
   ],
   "source": [
    "print(l[1:7])         # l[start : end]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "696ceede",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "9c790873",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 24, 36, 68, 99, 81]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[4:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "88f74cab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 81]\n"
     ]
    }
   ],
   "source": [
    "print(l[8:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "59a8810d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11]\n"
     ]
    }
   ],
   "source": [
    "print(l[0:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "da404e2d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[1:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "411185c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[8:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "f3427d62",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "8cb04435",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10]\n"
     ]
    }
   ],
   "source": [
    "print(l[:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "07b3d8c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[0:-4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "6b72269e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[33, 44, 10, 24, 36, 68, 99]\n"
     ]
    }
   ],
   "source": [
    "print(l[2:-2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "34eb2422",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[2:0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "ea9e9d22",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[0:0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "d4d6dc2c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[5:15])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "327f5a53",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [39]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ml\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m15\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "print(l[15])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "1654f679",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[22, 33, 44]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[1:4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "ef550430",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[4:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "64a79df5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[68, 99, 81]\n"
     ]
    }
   ],
   "source": [
    "print(l[-4:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "70fecd4e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(l[-1:-4])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2b17316",
   "metadata": {},
   "source": [
    "## steps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e9af568f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 33, 10, 36, 99, 100]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[0:11:2])   # l[start : end : steps]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "d0127e99",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 44, 36, 81]\n"
     ]
    }
   ],
   "source": [
    "print(l[0:11:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "75e4fefa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[::])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "3449b6af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 22, 33, 44, 10, 24, 36, 68, 99, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "print(l[::1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "2e6345c0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100, 81, 99, 68, 36, 24, 10, 44, 33, 22, 11]\n"
     ]
    }
   ],
   "source": [
    "print(l[::-1])   # reverse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "f284f488",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "#   -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1\n",
    "l = [11,22,33,44,10,24,36,68,99,81,100]\n",
    "#    0  1  2  3   4  5  6  7  8  9  10\n",
    "\n",
    "print(l[4:8:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "1f16a88d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 68, 36, 24]\n"
     ]
    }
   ],
   "source": [
    "print(l[8:4:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "11575dee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100, 99, 36, 10, 33, 11]\n"
     ]
    }
   ],
   "source": [
    "print(l[::-2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "1a639620",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "slice step cannot be zero",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [52]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ml\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mValueError\u001b[0m: slice step cannot be zero"
     ]
    }
   ],
   "source": [
    "print(l[::0])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20862888",
   "metadata": {},
   "source": [
    "## list functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "8aa952c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "source": [
    "l = [10,20,30,40,50]\n",
    "\n",
    "print(len(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "74856061",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(len(l) - 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "250b458e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "150\n"
     ]
    }
   ],
   "source": [
    "print(sum(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "7ea78614",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50\n"
     ]
    }
   ],
   "source": [
    "print(max(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "bad8aadc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "print(min(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "27a21618",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [58]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m l \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m10\u001b[39m,\u001b[38;5;241m20\u001b[39m,\u001b[38;5;241m30\u001b[39m]\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43msum\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ml\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "l = [\"A\", 10,20,30]\n",
    "\n",
    "print(sum(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "a176b651",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(len(l))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1ee80d7b",
   "metadata": {},
   "source": [
    "# List methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "e802bef5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help(print)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "5a500f31",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# help(list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "0538c1e8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40]\n"
     ]
    }
   ],
   "source": [
    "l = [10,20,30]\n",
    "\n",
    "l.append(40)\n",
    "\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "ed712c2b",
   "metadata": {},
   "outputs": [],
   "source": [
    "l.append(\"India\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "265b8be2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "ea15af1f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(l.index('India'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "c422ce83",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(l.index(10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "0e88a9f3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "e3042d8a",
   "metadata": {},
   "outputs": [],
   "source": [
    "l.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "02a28ba4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "7c861f47",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['India', 40, 30, 20, 10]\n"
     ]
    }
   ],
   "source": [
    "print(l[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "e1210f8f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 20, 30, 40, 'India']\n"
     ]
    }
   ],
   "source": [
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ef9c13af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/04_Strings and For loop.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "89086545",
   "metadata": {},
   "source": [
    "# Strings\n",
    "\n",
    "set of characters\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "663dd2fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n"
     ]
    }
   ],
   "source": [
    "#       -1\n",
    "s = 'hello'\n",
    "#    01234\n",
    "\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d1f891e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "h\n"
     ]
    }
   ],
   "source": [
    "print(s[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "549cabfa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "o\n"
     ]
    }
   ],
   "source": [
    "print(s[4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e9b26f8e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "o\n"
     ]
    }
   ],
   "source": [
    "print(s[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bef31594",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "l\n"
     ]
    }
   ],
   "source": [
    "print(s[-2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "00f3823f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7326e7a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(s[0]))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4899cd30",
   "metadata": {},
   "source": [
    "# string slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "12c56ed2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "commu\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "#    0123456789\n",
    "\n",
    "print(s[0:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "781ea5cd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "noitacinummoc\n"
     ]
    }
   ],
   "source": [
    "print(s[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "90aa93d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "omm\n"
     ]
    }
   ],
   "source": [
    "print(s[1:4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5c24d8b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "#    0123456789\n",
    "\n",
    "print(s[4:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a8f6af2e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "s = ''\n",
    "\n",
    "print(type(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2d3570c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "noitacin\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "#    0123456789\n",
    "\n",
    "print(s[-1:-9:-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef70cbf4",
   "metadata": {},
   "source": [
    "# String Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f12266cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n"
     ]
    }
   ],
   "source": [
    "s = 'communication'\n",
    "\n",
    "print(len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "50320c72",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [15]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43msum\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "print(sum(s))   # s = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "55b002c3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "u\n"
     ]
    }
   ],
   "source": [
    "print(max(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7ccced34",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n"
     ]
    }
   ],
   "source": [
    "print(min(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8b30e14f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# ASCII\n",
    "\n",
    "'A' -> 65\n",
    "'B' -> 66\n",
    "'Z' -> 90\n",
    "\n",
    "'a' -> 97\n",
    "'z' -> 122\n",
    "\n",
    "' ' -> 32 -> space"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "afa17626",
   "metadata": {},
   "source": [
    "## string methods\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e3ef73fb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# help(str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "53f436a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'raj123' == 'RAJ123'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "9a9f840d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "raj123\n"
     ]
    }
   ],
   "source": [
    "s = 'RAJ123'\n",
    "\n",
    "print(s.casefold())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "4e6cd479",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INDIA\n"
     ]
    }
   ],
   "source": [
    "s = 'India'\n",
    "\n",
    "print(s.upper())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "76b04479",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "india\n"
     ]
    }
   ],
   "source": [
    "print(s.lower())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "2e8f43e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['This', 'is', 'an', 'apple']\n"
     ]
    }
   ],
   "source": [
    "# split\n",
    "\n",
    "s = 'This is an apple'\n",
    "\n",
    "print(s.split(\" \"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "94237ec7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['H', 'llo Us', 'r']\n"
     ]
    }
   ],
   "source": [
    "s = \"Hello User\"\n",
    "\n",
    "print(s.split(\"e\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "42a71402",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This+is+an+apple\n"
     ]
    }
   ],
   "source": [
    "# join\n",
    "\n",
    "l = ['This', 'is', 'an', 'apple']\n",
    "\n",
    "a = \"+\"\n",
    "\n",
    "print(a.join(l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "6ef43d06",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is an apple\n"
     ]
    }
   ],
   "source": [
    "# join\n",
    "\n",
    "l = ['This', 'is', 'an', 'apple']\n",
    "\n",
    "a = \" \"\n",
    "\n",
    "print(a.join(l))\n",
    "#   \" \".join(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "dae0d39a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ThisisanApple\n"
     ]
    }
   ],
   "source": [
    "# remove all the spaces from the string\n",
    "\n",
    "s = \"This is an Apple\"\n",
    "\n",
    "l = s.split(\" \")\n",
    "\n",
    "x = \"\".join(l)\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e18c7bc",
   "metadata": {},
   "source": [
    "**Write a program to enter a string from user and print the biggest word from the para**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc9ffad3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "08b8681d",
   "metadata": {},
   "source": [
    "# range function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "cd95ff5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(0, 5)\n"
     ]
    }
   ],
   "source": [
    "n = range(5)   # this will create a series of numbers from 0 to 4\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "5faa24f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'range'>\n"
     ]
    }
   ],
   "source": [
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "b9b1b6fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4]\n"
     ]
    }
   ],
   "source": [
    "n = list(range(5))\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "00bf5fc9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 4, 5, 6, 7]\n"
     ]
    }
   ],
   "source": [
    "n = list(range(3,8))\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "85f51f76",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(range(20) == range(0,20))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "cf56e7cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[5, 7, 9, 11, 13, 15, 17, 19]\n"
     ]
    }
   ],
   "source": [
    "n = list(range(5,20,2))    # range(start, end, steps)\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a9e11b2",
   "metadata": {},
   "source": [
    "## for loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "eb461d52",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "l = [\"A\", \"B\", \"C\", \"D\"]\n",
    "\n",
    "print(\"Z\" in l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "f3d37b0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "B\n",
      "C\n",
      "D\n"
     ]
    }
   ],
   "source": [
    "l = [\"A\", \"B\", \"C\", \"D\"]\n",
    "#                    i\n",
    "\n",
    "#  \"B\" in l\n",
    "for i in l:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "15a3f0ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "Hi\n",
      "B\n",
      "Hi\n",
      "C\n",
      "Hi\n",
      "D\n",
      "Hi\n"
     ]
    }
   ],
   "source": [
    "l = [\"A\", \"B\", \"C\", \"D\"]\n",
    "#     i\n",
    "\n",
    "#  \"B\" in l\n",
    "for i in l:\n",
    "    print(i)\n",
    "    print(\"Hi\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "59f4f57f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "b\n",
      "c\n",
      "d\n"
     ]
    }
   ],
   "source": [
    "s = 'abcd'\n",
    "\n",
    "for i in s:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "be302d25",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AB\n",
      "ab\n"
     ]
    }
   ],
   "source": [
    "x = 'ab'\n",
    "\n",
    "print(x.upper())\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "b3a22f15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['ab', 'cd']\n"
     ]
    }
   ],
   "source": [
    "x = ['ab', 'cd']\n",
    "\n",
    "for i in x:\n",
    "    i.upper()        # 'ab'.upper() -> 'AB'\n",
    "    \n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "4e0873d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AB\n",
      "CD\n",
      "['ab', 'cd']\n"
     ]
    }
   ],
   "source": [
    "x = ['ab', 'cd']\n",
    "\n",
    "for i in x:\n",
    "    print(i.upper())        # 'ab'.upper() -> 'AB'\n",
    "    \n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "77e96be5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "b\n",
      "c\n",
      "d\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "for i in x:\n",
    "    print(i)\n",
    "    x.upper()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d6c07e4d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "#             i\n",
    "#         0,1,2,3,4\n",
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "bba46637",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in range(5,10):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "fdb6483c",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'str' object cannot be interpreted as an integer",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [48]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mabcd\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mrange\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[0;32m      4\u001b[0m     \u001b[38;5;28mprint\u001b[39m(i)\n",
      "\u001b[1;31mTypeError\u001b[0m: 'str' object cannot be interpreted as an integer"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "for i in range(x):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "dac1b7e1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "ce020a17",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'int' object has no attribute 'upper'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[1;32mIn [50]\u001b[0m, in \u001b[0;36m<cell line: 4>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;66;03m#          0,1,2,3\u001b[39;00m\n\u001b[0;32m      4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(x)):\n\u001b[1;32m----> 5\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[43mi\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupper\u001b[49m())\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'int' object has no attribute 'upper'"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    print(i.upper())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "e4b348f0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "abcd\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    x[i].upper()\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "e4afa49b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "B\n",
      "C\n",
      "D\n",
      "abcd\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#          0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    print(x[i].upper())\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "9d691550",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "a\n",
      "a\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "x = 'abcd'\n",
    "\n",
    "#         0,1,2,3\n",
    "for i in range(len(x)):\n",
    "    x = 'a'               # x = 'abcd', 'a', 'a'\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fe9971b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: July Cohort 2023/1_Python Programming/05_Dictionary Tuples and Set.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0d853ca0",
   "metadata": {},
   "source": [
    "# Dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "28ba2c85",
   "metadata": {},
   "outputs": [],
   "source": [
    "# { key : value }\n",
    "\n",
    "unordered data structures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "de03adfa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'ravi': 24, 'shyam': 21, 'roy': 41}\n"
     ]
    }
   ],
   "source": [
    "ages = {\"ravi\":24, \"shyam\": 21, \"roy\": 41}\n",
    "\n",
    "print(ages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1507411b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "print(type(ages))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3a6e0c6d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24\n"
     ]
    }
   ],
   "source": [
    "print(ages['ravi'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9c495fe7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "41\n"
     ]
    }
   ],
   "source": [
    "print(ages['roy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "dc9434fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[255, 0, 0]\n"
     ]
    }
   ],
   "source": [
    "color = {\n",
    "    \"red\": [255,0,0],\n",
    "    \"green\": [0,255,0],\n",
    "    \"blue\": [0,0,255]\n",
    "}\n",
    "print(color['red'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "28854643",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'yellow'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[1;32mIn [7]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mcolor\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43myellow\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m)\n",
      "\u001b[1;31mKeyError\u001b[0m: 'yellow'"
     ]
    }
   ],
   "source": [
    "print(color['yellow'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f12d89ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "d = {}\n",
    "print(d)\n",
    "print(type(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "0d0ceafe",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unhashable type: 'list'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [9]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m d \u001b[38;5;241m=\u001b[39m {[\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m]:\u001b[38;5;241m10\u001b[39m, \u001b[38;5;241m2\u001b[39m:\u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m3\u001b[39m:\u001b[38;5;241m3\u001b[39m}\n\u001b[0;32m      2\u001b[0m \u001b[38;5;28mprint\u001b[39m(d)\n",
      "\u001b[1;31mTypeError\u001b[0m: unhashable type: 'list'"
     ]
    }
   ],
   "source": [
    "d = {[1,2]:10, 2:2, 3:3}\n",
    "print(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8a6b2ca9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100, 20]\n"
     ]
    }
   ],
   "source": [
    "# list are mutable objects\n",
    "\n",
    "l = [10,20]\n",
    "l[0] = 100\n",
    "print(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "bc14edbb",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'str' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [11]\u001b[0m, in \u001b[0;36m<cell line: 4>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# strings are immutable objects\u001b[39;00m\n\u001b[0;32m      3\u001b[0m s \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mindore\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 4\u001b[0m s[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m      5\u001b[0m \u001b[38;5;28mprint\u001b[39m(s)\n",
      "\u001b[1;31mTypeError\u001b[0m: 'str' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "# strings are immutable objects\n",
    "\n",
    "s = 'indore'\n",
    "s[0] = \"A\"\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "498704a8",
   "metadata": {},
   "source": [
    "# Dictionary Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a88930aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "d = {1:11, 2:41, 13:9, 14:16}\n",
    "\n",
    "print(len(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "71aca243",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "30\n"
     ]
    }
   ],
   "source": [
    "print(sum(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a9c23606",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [14]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m a \u001b[38;5;241m=\u001b[39m {\u001b[38;5;241m1\u001b[39m:\u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m3\u001b[39m:\u001b[38;5;241m4\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhi\u001b[39m\u001b[38;5;124m\"\u001b[39m:\u001b[38;5;241m16\u001b[39m}\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43msum\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ma\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "a = {1:2, 3:4, \"hi\":16}\n",
    "\n",
    "print(sum(a))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6afd220b",
   "metadata": {},
   "source": [
    "# Dictionary Methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4d319b95",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 'Apple', 'orange': [2, 3, 4], '2': '23'}\n"
     ]
    }
   ],
   "source": [
    "pair = {1:\"Apple\", \"orange\": [2,3,4], \"2\":\"23\"}\n",
    "\n",
    "print(pair)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b53ea8e9",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2, 3, 4]\n"
     ]
    }
   ],
   "source": [
    "# get\n",
    "# help(dict)\n",
    "\n",
    "print(pair.get(\"orange\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e3b011f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "print(pair.get(7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "80c5249a",
   "metadata": {},
   "outputs": [],
   "source": [
    "None ==> NULL ==> nothing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "8ece5b51",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Apple\n"
     ]
    }
   ],
   "source": [
    "print(pair.get(1,\"Element not found\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "af462093",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Element not found\n"
     ]
    }
   ],
   "source": [
    "print(pair.get(10,\"Element not found\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "61e47d6e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 'Apple', 'orange': [2, 3, 4], '2': '23'}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "# clear\n",
    "\n",
    "p = {1:\"Apple\", \"orange\": [2,3,4], \"2\":\"23\"}\n",
    "\n",
    "print(p)\n",
    "p.clear()\n",
    "print(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "bcf864f7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys([1, 2, 3])\n"
     ]
    }
   ],
   "source": [
    "# keys\n",
    "\n",
    "r = {1:\"A\", 2:'Zara', 3:\"Maza\"}\n",
    "\n",
    "print(r.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "4d8f44be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3]\n"
     ]
    }
   ],
   "source": [
    "print(list(r.keys()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "13318e6e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_values(['A', 'Zara', 'Maza'])\n"
     ]
    }
   ],
   "source": [
    "# values\n",
    "\n",
    "r = {1:\"A\", 2:'Zara', 3:\"Maza\"}\n",
    "\n",
    "print(r.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "e29dc425",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['A', 'Zara', 'Maza']\n"
     ]
    }
   ],
   "source": [
    "print(list(r.values()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "4e7dbf29",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{3: 'Maza', 2: 'Zara'}\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "r = {3:\"A\", 2:'Zara', 3:\"Maza\"}\n",
    "\n",
    "print(r)\n",
    "\n",
    "print(len(r))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec79a1b8",
   "metadata": {},
   "source": [
    "# Question\n",
    "\n",
    "print the following series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e205896b",
   "metadata": {},
   "outputs": [],
   "source": [
    "{1:1, 2:4, 3:9, 4:16, .........10:100}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "5abc247e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 2, 3: 'Hi'}\n"
     ]
    }
   ],
   "source": [
    "a = {1:2}\n",
    "a[3] = \"Hi\"\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "7aea4934",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100}\n"
     ]
    }
   ],
   "source": [
    "d = {}\n",
    "\n",
    "for i in range(1,11):\n",
    "    d[i] = i * i\n",
    "\n",
    "print(d)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "323a152e",
   "metadata": {},
   "source": [
    "# Tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "5a6a2fc7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(4, 3, 5, 6)\n",
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "t = (4,3,5,6)\n",
    "#    0 1 2 3\n",
    "\n",
    "print(t)\n",
    "\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "d5b5852c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(t[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "519de1e2",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [33]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m t[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m11\u001b[39m\n",
      "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "t[0] = 11  # tuple are immutable objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "d44d0e73",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('one', 'two', 'three')\n"
     ]
    }
   ],
   "source": [
    "t = \"one\", \"two\", \"three\"\n",
    "\n",
    "print(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "85ca1c88",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "88548f84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "t = (10)\n",
    "print(t)\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "0605b55a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(10,)\n",
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "t = (10,)\n",
    "print(t)\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "954aa392",
   "metadata": {},
   "source": [
    "# Tuple unpacking"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "a77b3c9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "n = (1,2,3)\n",
    "\n",
    "a,b,c = n\n",
    "\n",
    "print(a)\n",
    "print(b)\n",
    "print(c)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bda16a06",
   "metadata": {},
   "source": [
    "# Tuple Slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "1c2a8096",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(11, 22, 33, 44, 55, 66, 77, 88, 99, 100)\n"
     ]
    }
   ],
   "source": [
    "#                               -1\n",
    "t = (11,22,33,44,55,66,77,88,99,100)\n",
    "#    0  1  \n",
    "\n",
    "print(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "14c17710",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(44, 55)\n"
     ]
    }
   ],
   "source": [
    "print(t[3:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "febf2d84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(11, 22, 33, 44, 55, 66)\n"
     ]
    }
   ],
   "source": [
    "print(t[:6])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "e98f6a1e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(33, 44, 55, 66)\n"
     ]
    }
   ],
   "source": [
    "print(t[-8:-4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c1de1350",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "()\n"
     ]
    }
   ],
   "source": [
    "print(t[-4:-8])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "3f3523ca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(100, 99, 88, 77, 66, 55, 44, 33, 22, 11)\n"
     ]
    }
   ],
   "source": [
    "print(t[::-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9119181e",
   "metadata": {},
   "source": [
    "# Tuple Methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "da140ca3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "# count\n",
    "\n",
    "t = (2,3,4,5,5,6,6,4,4,)\n",
    "\n",
    "print(t.count(4))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "c35b8ce9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "# index\n",
    "\n",
    "t = (2,3,4,5,5,6,6,4,4,)\n",
    "\n",
    "print(t.index(4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "1e8caefa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function index:\n",
      "\n",
      "index(value, start=0, stop=9223372036854775807, /) method of builtins.tuple instance\n",
      "    Return first index of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(t.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "15dafa64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7\n"
     ]
    }
   ],
   "source": [
    "# index\n",
    "\n",
    "t = (2,3,4,5,5,6,6,4,4,)\n",
    "\n",
    "print(t.index(4, 5))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9ef4027",
   "metadata": {},
   "source": [
    "# Tuple functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "22c1684e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "source": [
    "t = (2,3,4,5,6)\n",
    "\n",
    "print(len(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "9f1bfd43",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20\n"
     ]
    }
   ],
   "source": [
    "print(sum(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "89a4ca0e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n"
     ]
    }
   ],
   "source": [
    "print(max(t))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "505a27fe",
   "metadata": {},
   "source": [
    "# Question"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f36b7876",
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove i from this tuple\n",
    "\n",
    "t = ('a', 'e','i', 'o', 'u')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90775705",
   "metadata": {},
   "source": [
    "# Sets\n",
    "\n",
    "unordered and unindex\n",
    "\n",
    "sets are mutable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "7ee80027",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5, 6}\n",
      "<class 'set'>\n"
     ]
    }
   ],
   "source": [
    "n = {1,2,3,4,5,6,6,6}\n",
    "\n",
    "print(n)\n",
    "\n",
    "print(type(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "6fef6ded",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'set'>\n"
     ]
    }
   ],
   "source": [
    "s = set()\n",
    "\n",
    "print(type(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "a23d23ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{10, 'a', 'b'}\n"
     ]
    }
   ],
   "source": [
    "n = set(['a','b',10])\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "1a660809",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "s = ['a','b',10]\n",
    "\n",
    "print(10 in s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "6997ba95",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "a\n",
      "b\n"
     ]
    }
   ],
   "source": [
    "for i in n:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f38bc03",
   "metadata": {},
   "source": [
    "# Set operations\n",
    "\n",
    "#### union"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "cde829c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5, 6, 7, 8, 9}\n"
     ]
    }
   ],
   "source": [
    "f = {1,2,3,4,5,6}\n",
    "s = {4,5,6,7,8,9}\n",
    "\n",
    "print(f | s)   # union"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f9ef43c",
   "metadata": {},
   "source": [
    "#### intersection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "58b28ca7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{4, 5, 6}\n"
     ]
    }
   ],
   "source": [
    "f = {1,2,3,4,5,6}\n",
    "s = {4,5,6,7,8,9}\n",
    "\n",
    "print(f & s)   # intersection"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69c8e095",
   "metadata": {},
   "source": [
    "#### difference"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "81b857d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3}\n"
     ]
    }
   ],
   "source": [
    "f = {1,2,3,4,5,6}\n",
    "s = {4,5,6,7,8,9}\n",
    "\n",
    "print(f - s)   # difference"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "d9eaa143",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{8, 9, 7}\n"
     ]
    }
   ],
   "source": [
    "f = {1,2,3,4,5,6}\n",
    "s = {4,5,6,7,8,9}\n",
    "\n",
    "print(s - f)   # difference"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "17db78c6",
   "metadata": {},
   "source": [
    "#### symmetric"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "0200b5d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 7, 8, 9}\n"
     ]
    }
   ],
   "source": [
    "f = {1,2,3,4,5,6}\n",
    "s = {4,5,6,7,8,9}\n",
    "\n",
    "print(f ^ s)   # symmetric"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64ddb35d",
   "metadata": {},
   "source": [
    "# set functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "000b5af4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "21\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "s = {1,2,3,4,5,6}\n",
    "\n",
    "print(len(s))\n",
    "print(sum(s))\n",
    "print(max(s))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d07deba1",
   "metadata": {},
   "source": [
    "# set methods\n",
    "\n",
    "#### add"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "784b2205",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5, 6}\n",
      "{1, 2, 3, 4, 5, 6, -7}\n"
     ]
    }
   ],
   "source": [
    "n = {1,2,1,3,4,5,6}\n",
    "\n",
    "print(n)\n",
    "\n",
    "n.add(-7)\n",
    "\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e78cb535",
   "metadata": {},
   "source": [
    "#### clear"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "c948c4ff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5, 6, -7}\n",
      "set()\n"
     ]
    }
   ],
   "source": [
    "print(n)\n",
    "n.clear()\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "a5ac2b2e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 4, 5, 6}\n"
     ]
    }
   ],
   "source": [
    "s = {1,2,3,4,5,6}\n",
    "\n",
    "s.remove(3)\n",
    "s.remove(2)\n",
    "\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5fdb4232",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: March Cohort 2023/.ipynb_checkpoints/0_Python Basics-checkpoint.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1dd9932f",
   "metadata": {},
   "source": [
    "# Python Basics\n",
    "\n",
    "we are working on print function in python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3ca45a0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e2a86f94",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\")\n",
    "print(\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "07db254e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\n",
      "World\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\\nWorld\")  # \\n -> new line character"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "46c947b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello\tWorld\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello\\tWorld\")  # \\t -> horizontal tab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fd07c92b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 8 spaces - \\t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "960ceae0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# binary language -> 1010110\n",
    "\n",
    "0  ->  low voltage, no-charge\n",
    "\n",
    "1  ->  high voltage, charge\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10a75868",
   "metadata": {},
   "outputs": [],
   "source": [
    "bits > numbers >  character > instructions > program > software"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "459a661b",
   "metadata": {},
   "outputs": [],
   "source": [
    "compiler\n",
    "\n",
    "interpreter -> python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "991396e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "source code  ------->  Byte code  ----->   Output\n",
    "    .c      compile      .bak      Run       .exe\n",
    "    .cpp                 .obj\n",
    "    .java                .javac\n",
    "    .py                  .pyc"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9de76aa4",
   "metadata": {},
   "source": [
    "# Variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ca83f18c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3a7bac6d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "45.13\n"
     ]
    }
   ],
   "source": [
    "b = 45.13\n",
    "\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "124cb33b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "India\n"
     ]
    }
   ],
   "source": [
    "a = \"India\"\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "406d111f",
   "metadata": {},
   "source": [
    "# Data type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "707a85a0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(a)\n",
    "\n",
    "print(type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "bc9295ca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.65\n",
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "b = 10.65\n",
    "\n",
    "print(b)\n",
    "\n",
    "print(type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5632508a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Screen\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "c = \"Screen\"\n",
    "\n",
    "print(c)\n",
    "\n",
    "print(type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "644ec54c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "meet\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "d = 'meet'\n",
    "\n",
    "print(d)\n",
    "\n",
    "print(type(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "43f33389",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "it's an apple\n"
     ]
    }
   ],
   "source": [
    "x = \"it's an apple\"\n",
    "\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e04549b7",
   "metadata": {},
   "source": [
    "# Type Conversion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "321b1438",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.56\n",
      "<class 'float'>\n",
      "10\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "a = 10.56\n",
    "\n",
    "print(a)\n",
    "\n",
    "print(type(a))\n",
    "\n",
    "b = int(a)\n",
    "\n",
    "print(b)\n",
    "\n",
    "print(type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "873230fd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "<class 'str'>\n",
      "100.0\n",
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "a = \"100\"\n",
    "\n",
    "print(a)\n",
    "\n",
    "print(type(a))\n",
    "\n",
    "b = float(a)\n",
    "\n",
    "print(b)\n",
    "\n",
    "print(type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83db42ca",
   "metadata": {},
   "outputs": [],
   "source": [
    "int()\n",
    "float()\n",
    "str()\n",
    "bool()\n",
    "list()\n",
    "dict()\n",
    "tuple()\n",
    "set()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a54b3b8f",
   "metadata": {},
   "source": [
    "# Input function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "127dd9ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "a = input()\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6c872d87",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter Your Name: Himanshu\n",
      "Himanshu\n"
     ]
    }
   ],
   "source": [
    "a = input(\"Enter Your Name: \")\n",
    "\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f332e9d1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter Your Name: Himanshu\n",
      "Hello! How are you? Himanshu\n"
     ]
    }
   ],
   "source": [
    "a = input(\"Enter Your Name: \")\n",
    "\n",
    "print(\"Hello! How are you?\", a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "076ba3aa",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}


================================================
FILE: March Cohort 2023/.ipynb_checkpoints/13_14_Object Orientation-checkpoint.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f956ae23",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a8e19eec",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# help(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "02596f25",
   "metadata": {},
   "outputs": [],
   "source": [
    "int a = 10;   # 2 bytes - 16 bits\n",
    "\n",
    "struct car{\n",
    "    int cust_id;  # 2 bytes\n",
    "    char name[10];# 10 bytes\n",
    "    float price;  # 4 bytes\n",
    "}\n",
    "\n",
    "struct car c1;\n",
    "       int a;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73d30a38",
   "metadata": {},
   "outputs": [],
   "source": [
    "bit>numbers>characters>instructions>function(program)>class>modules>package>library>framework>software"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ae18de9",
   "metadata": {},
   "source": [
    "# Object Orientation\n",
    "\n",
    "7 properties of OOP\n",
    "\n",
    "1. Class\n",
    "        Updated version of structures (struct -- C programming)\n",
    "        collection of variables and methods\n",
    "        class is a blueprint.\n",
    "2. Object\n",
    "        Run time or real time entity.\n",
    "        hash code/virtual code - ID(python)\n",
    "        \n",
    "3. Abstraction and Encapsulation\n",
    "        Abstraction - showing only essential features without showing any background details.\n",
    "        Encapsulation - wrapping up of data in a single unit.\n",
    "        \n",
    "4. Inheritance\n",
    "        Acquiring properties of one class into another.\n",
    "        code reusability\n",
    "        - single level\n",
    "        - multi level\n",
    "        - heirarchical\n",
    "        - multiple\n",
    "        - hybride\n",
    "        \n",
    "5. Polymorphism\n",
    "        same name multiple functionalities\n",
    "        - method overloading\n",
    "        - method overriding\n",
    "        \n",
    "6. Dynamic Memory Allocation\n",
    "        run time memory allocation\n",
    "        \n",
    "7. Message Passing\n",
    "        Communication between objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d69e271e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2207057668688\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "print(id(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "cb563
Download .txt
gitextract_mu6uxmva/

├── July Cohort 2023/
│   └── 1_Python Programming/
│       ├── .ipynb_checkpoints/
│       │   ├── 01_Python Basics-checkpoint.ipynb
│       │   ├── 02_03_While Loop and List-checkpoint.ipynb
│       │   ├── 04_Strings and For loop-checkpoint.ipynb
│       │   └── 05_Dictionary Tuples and Set-checkpoint.ipynb
│       ├── 01_Python Basics.ipynb
│       ├── 02_03_While Loop and List.ipynb
│       ├── 04_Strings and For loop.ipynb
│       └── 05_Dictionary Tuples and Set.ipynb
├── March Cohort 2023/
│   ├── .ipynb_checkpoints/
│   │   ├── 0_Python Basics-checkpoint.ipynb
│   │   ├── 13_14_Object Orientation-checkpoint.ipynb
│   │   ├── 1_While Loops and Logic Building-checkpoint.ipynb
│   │   ├── 2_List and Strings-checkpoint.ipynb
│   │   ├── 3_For Loop Dictionary Tuple and Sets-checkpoint.ipynb
│   │   ├── 4_Functions-checkpoint.ipynb
│   │   └── 5_Modules and Packages-checkpoint.ipynb
│   ├── 0_Python Basics.ipynb
│   ├── 10_11_EDA Project/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 10_11_EDA Project-checkpoint.ipynb
│   │   ├── 10_11_EDA Project.ipynb
│   │   ├── titanic.csv
│   │   └── titanic_cleaned.csv
│   ├── 10_Matplotlib/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 10_Matplotlib-checkpoint.ipynb
│   │   └── 10_Matplotlib.ipynb
│   ├── 12_15_16_17_18_Statistics/
│   │   ├── .ipynb_checkpoints/
│   │   │   ├── 12_15_Statistics-checkpoint.ipynb
│   │   │   ├── 16_17_Statistics and Regression-checkpoint.ipynb
│   │   │   └── 18_Hypothesis Testing-checkpoint.ipynb
│   │   ├── 12_15_Statistics.ipynb
│   │   ├── 16_17_Statistics and Regression.ipynb
│   │   ├── 18_Hypothesis Testing.ipynb
│   │   ├── datasets/
│   │   │   ├── Birthweight_reduced_kg_R.csv
│   │   │   ├── CarPrice_Assignment.csv
│   │   │   ├── Crime_R.csv
│   │   │   ├── IPL2013.csv
│   │   │   ├── SP_500_1987.csv
│   │   │   ├── data_loan.csv
│   │   │   └── forbes.csv
│   │   ├── sample_submission.csv
│   │   ├── test.csv
│   │   └── train.csv
│   ├── 13_14_Object Orientation.ipynb
│   ├── 19_20_Machine Learning/
│   │   ├── .ipynb_checkpoints/
│   │   │   ├── 19_Machine Learning and Linear Regression with One variable-checkpoint.ipynb
│   │   │   └── 20_Logistic Regression-checkpoint.ipynb
│   │   ├── 19_Machine Learning and Linear Regression with One variable.ipynb
│   │   ├── 20_Logistic Regression.ipynb
│   │   ├── areas.csv
│   │   ├── homeprices.csv
│   │   ├── insurance_data.csv
│   │   └── spend.xlsx
│   ├── 1_While Loops and Logic Building.ipynb
│   ├── 21_EDA and Data Viz/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 21_EDA and Data Visualization-checkpoint.ipynb
│   │   ├── 21_EDA and Data Visualization.ipynb
│   │   └── itunes_data.csv
│   ├── 22_23_Time Series Forecasting/
│   │   ├── .ipynb_checkpoints/
│   │   │   ├── 22_Forecasting-checkpoint.ipynb
│   │   │   └── 23_ARIMA-checkpoint.ipynb
│   │   ├── 22_Forecasting.ipynb
│   │   ├── 23_ARIMA.ipynb
│   │   ├── store.xls
│   │   ├── vimana.csv
│   │   └── wsb.csv
│   ├── 24_SQL/
│   │   └── SQLqueriesQandA.sql
│   ├── 2_List and Strings.ipynb
│   ├── 3_For Loop Dictionary Tuple and Sets.ipynb
│   ├── 4_Functions.ipynb
│   ├── 5_Modules and Packages.ipynb
│   ├── 5_Modules-Packages/
│   │   ├── main.py
│   │   ├── rose.py
│   │   └── statsmeme/
│   │       ├── __init__.py
│   │       ├── descriptive.py
│   │       └── inferential.py
│   ├── 6_VirtualEnvironmentAndFlask/
│   │   ├── application.py
│   │   └── templates/
│   │       └── index.html
│   ├── 7_NumPy/
│   │   ├── .ipynb_checkpoints/
│   │   │   └── 7_NumPy-checkpoint.ipynb
│   │   └── 7_NumPy.ipynb
│   └── 8_9_Pandas/
│       ├── .ipynb_checkpoints/
│       │   └── 8_9_Pandas-checkpoint.ipynb
│       ├── 8_9_Pandas.ipynb
│       ├── Data Cleaning With Pandas/
│       │   ├── Data Cleaning with Python and Pandas_ Detecting Missing Values.html
│       │   └── Data Cleaning with Python and Pandas_ Detecting Missing Values_files/
│       │       ├── analytics.js.download
│       │       ├── comment-reply.min.js.download
│       │       ├── common.js.download
│       │       ├── css
│       │       ├── css(1)
│       │       ├── css(2)
│       │       ├── custom.js(1).download
│       │       ├── custom.js.download
│       │       ├── custom.min.js.download
│       │       ├── form.js.download
│       │       ├── frontend.min.js.download
│       │       ├── idle-timer.min.js(1).download
│       │       ├── idle-timer.min.js.download
│       │       ├── jquery-migrate.min.js.download
│       │       ├── jquery.js.download
│       │       ├── jquery.uniform.min.js.download
│       │       ├── linkid.js.download
│       │       ├── prism-js.min.js.download
│       │       ├── style(1).css
│       │       ├── style(2).css
│       │       ├── style(3).css
│       │       ├── style.css
│       │       ├── wp-embed.min.js.download
│       │       └── wp-emoji-release.min.js.download
│       ├── indore.csv
│       ├── nyc_weather.csv
│       ├── stock_data.csv
│       ├── stocks_weather.xlsx
│       ├── weather_by_cities.csv
│       ├── weather_data.csv
│       ├── weather_data.xlsx
│       ├── weather_data2.csv
│       ├── weather_datamissing.csv
│       └── weather_datamissing_regex.csv
└── README.md
Download .txt
SYMBOL INDEX (10 symbols across 5 files)

FILE: March Cohort 2023/24_SQL/SQLqueriesQandA.sql
  type Bonus (line 29) | CREATE TABLE Bonus (
  type Title (line 47) | CREATE TABLE Title (

FILE: March Cohort 2023/5_Modules-Packages/rose.py
  function color (line 3) | def color():
  function flower (line 6) | def flower():

FILE: March Cohort 2023/5_Modules-Packages/statsmeme/descriptive.py
  function mean (line 1) | def mean(l):
  function mode (line 6) | def mode():

FILE: March Cohort 2023/5_Modules-Packages/statsmeme/inferential.py
  function models (line 1) | def models():

FILE: March Cohort 2023/6_VirtualEnvironmentAndFlask/application.py
  function hello (line 25) | def hello():
  function home (line 29) | def home():
  function profile (line 34) | def profile():
Copy disabled (too large) Download .json
Condensed preview — 110 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (13,379K chars).
[
  {
    "path": "July Cohort 2023/1_Python Programming/.ipynb_checkpoints/01_Python Basics-checkpoint.ipynb",
    "chars": 8117,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"5effdff7\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Python Basic"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/.ipynb_checkpoints/02_03_While Loop and List-checkpoint.ipynb",
    "chars": 40288,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"13c6ac1c\",\n   \"metadata\": {},\n   \"source\": [\n    \"# While Loop\"\n"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/.ipynb_checkpoints/04_Strings and For loop-checkpoint.ipynb",
    "chars": 20524,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"89086545\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Strings\\n\",\n"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/.ipynb_checkpoints/05_Dictionary Tuples and Set-checkpoint.ipynb",
    "chars": 21460,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"34a4e5e6\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Dictionary\"\n"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/01_Python Basics.ipynb",
    "chars": 8117,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"5effdff7\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Python Basic"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/02_03_While Loop and List.ipynb",
    "chars": 40288,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"13c6ac1c\",\n   \"metadata\": {},\n   \"source\": [\n    \"# While Loop\"\n"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/04_Strings and For loop.ipynb",
    "chars": 20524,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"89086545\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Strings\\n\",\n"
  },
  {
    "path": "July Cohort 2023/1_Python Programming/05_Dictionary Tuples and Set.ipynb",
    "chars": 27458,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"0d853ca0\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Dictionary\"\n"
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/0_Python Basics-checkpoint.ipynb",
    "chars": 8494,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"1dd9932f\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Python Basic"
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/13_14_Object Orientation-checkpoint.ipynb",
    "chars": 24313,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"id\": \"f956ae23\",\n   \"metadata\": {},\n   \"outputs\":"
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/1_While Loops and Logic Building-checkpoint.ipynb",
    "chars": 16031,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"dfbc28de\",\n   \"metadata\": {},\n   \"source\": [\n    \"# While Loop\"\n"
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/2_List and Strings-checkpoint.ipynb",
    "chars": 56513,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"f18f8832\",\n   \"metadata\": {},\n   \"source\": [\n    \"# List\\n\",\n   "
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/3_For Loop Dictionary Tuple and Sets-checkpoint.ipynb",
    "chars": 40635,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"958dd5a9\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Range functi"
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/4_Functions-checkpoint.ipynb",
    "chars": 27546,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"a98c255e\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Functions\"\n "
  },
  {
    "path": "March Cohort 2023/.ipynb_checkpoints/5_Modules and Packages-checkpoint.ipynb",
    "chars": 11019,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"507b0a7e\",\n   \"metadata\": {},\n   \"source\": [\n    \"# OS\\n\",\n    \""
  },
  {
    "path": "March Cohort 2023/0_Python Basics.ipynb",
    "chars": 8494,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"1dd9932f\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Python Basic"
  },
  {
    "path": "March Cohort 2023/10_11_EDA Project/.ipynb_checkpoints/10_11_EDA Project-checkpoint.ipynb",
    "chars": 121477,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"373ae802\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Titanic Surv"
  },
  {
    "path": "March Cohort 2023/10_11_EDA Project/10_11_EDA Project.ipynb",
    "chars": 121477,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"373ae802\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Titanic Surv"
  },
  {
    "path": "March Cohort 2023/10_11_EDA Project/titanic.csv",
    "chars": 60305,
    "preview": "PassengerId,Survived,Pclass,Name,Gender,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked\n1,0,3,\"Braund, Mr. Owen Harris\",male,"
  },
  {
    "path": "March Cohort 2023/10_11_EDA Project/titanic_cleaned.csv",
    "chars": 45537,
    "preview": "Survived,Pclass,Age,Fare,male,C,Q,S,SibSp_0,SibSp_1,SibSp_2,SibSp_3,SibSp_4,SibSp_5,SibSp_8,Parch_0,Parch_1,Parch_2,Parc"
  },
  {
    "path": "March Cohort 2023/10_Matplotlib/.ipynb_checkpoints/10_Matplotlib-checkpoint.ipynb",
    "chars": 72,
    "preview": "{\n \"cells\": [],\n \"metadata\": {},\n \"nbformat\": 4,\n \"nbformat_minor\": 5\n}\n"
  },
  {
    "path": "March Cohort 2023/10_Matplotlib/10_Matplotlib.ipynb",
    "chars": 340703,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"d32aa7c4\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Matplotlib B"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/.ipynb_checkpoints/12_15_Statistics-checkpoint.ipynb",
    "chars": 297860,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"df89b0c5\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Statistics\\n"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/.ipynb_checkpoints/16_17_Statistics and Regression-checkpoint.ipynb",
    "chars": 344689,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"103790af\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Multiple Lin"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/.ipynb_checkpoints/18_Hypothesis Testing-checkpoint.ipynb",
    "chars": 14313,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"c585a495\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Hypothesis T"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/12_15_Statistics.ipynb",
    "chars": 297860,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"df89b0c5\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Statistics\\n"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/16_17_Statistics and Regression.ipynb",
    "chars": 344689,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"103790af\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Multiple Lin"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/18_Hypothesis Testing.ipynb",
    "chars": 14313,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"c585a495\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Hypothesis T"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/Birthweight_reduced_kg_R.csv",
    "chars": 2182,
    "preview": "ID,Length,Birthweight,Headcirc,Gestation,smoker,mage,mnocig,mheight,mppwt,fage,fedyrs,fnocig,fheight,lowbwt,mage35\n1360"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/CarPrice_Assignment.csv",
    "chars": 26511,
    "preview": "car_ID,symboling,CarName,fueltype,aspiration,doornumber,carbody,drivewheel,enginelocation,wheelbase,carlength,carwidth,c"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/Crime_R.csv",
    "chars": 4831,
    "preview": "CrimeRate,Youth,Southern,Education,ExpenditureYear0,LabourForce,Males,MoreMales,StateSize,YouthUnemployment,MatureUnemp"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/IPL2013.csv",
    "chars": 15531,
    "preview": "Sl.NO.,PLAYER NAME,AGE,COUNTRY,TEAM,PLAYING ROLE,T-RUNS,T-WKTS,ODI-RUNS-S,ODI-SR-B,ODI-WKTS,ODI-SR-BL,CAPTAINCY EXP,RUNS"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/SP_500_1987.csv",
    "chars": 15482,
    "preview": "Date,Open,High,Low,Close,AdjClose,Volume\n31-Dec-1986,243.37,244.03,241.28,242.17,242.17,\"13,92,00,000\"\n2-Jan-1987,242.17"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/data_loan.csv",
    "chars": 248774,
    "preview": "ID,Default,Loan_type,Gender,Age,Degree,Income,Credit_score,Loan_length,Signers,Citizenship\n1,0,Car ,Female,30,HS      ,1"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/datasets/forbes.csv",
    "chars": 150956,
    "preview": "Rank,Company,Country,Sales,Profits,Assets,Market Value,Sector,Industry\n1,ICBC,China,151.4,42,3473.2,229.8,Financials,Maj"
  },
  {
    "path": "March Cohort 2023/12_15_16_17_18_Statistics/sample_submission.csv",
    "chars": 3363144,
    "preview": "id,cost\n360336,99.615\n360337,99.615\n360338,99.615\n360339,99.615\n360340,99.615\n360341,99.615\n360342,99.615\n360343,99.615\n"
  },
  {
    "path": "March Cohort 2023/13_14_Object Orientation.ipynb",
    "chars": 24313,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"id\": \"f956ae23\",\n   \"metadata\": {},\n   \"outputs\":"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/.ipynb_checkpoints/19_Machine Learning and Linear Regression with One variable-checkpoint.ipynb",
    "chars": 61294,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"7242d236\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Machine Lear"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/.ipynb_checkpoints/20_Logistic Regression-checkpoint.ipynb",
    "chars": 75152,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"c71657c4\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Logistic Reg"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/19_Machine Learning and Linear Regression with One variable.ipynb",
    "chars": 61294,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"7242d236\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Machine Lear"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/20_Logistic Regression.ipynb",
    "chars": 75152,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"c71657c4\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Logistic Reg"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/areas.csv",
    "chars": 70,
    "preview": "area\n1000\n1500\n2300\n3540\n4120\n4560\n5490\n3460\n4750\n2300\n9000\n8600\n7100\n"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/homeprices.csv",
    "chars": 71,
    "preview": "area,price\n2600,550000\n3000,565000\n3200,610000\n3600,680000\n4000,725000\n"
  },
  {
    "path": "March Cohort 2023/19_20_Machine Learning/insurance_data.csv",
    "chars": 155,
    "preview": "age,bought_insurance\n22,0\n25,0\n47,1\n52,0\n46,1\n56,1\n55,0\n60,1\n62,1\n61,1\n18,0\n28,0\n27,0\n29,0\n49,1\n55,1\n25,1\n58,1\n19,0\n18,0"
  },
  {
    "path": "March Cohort 2023/1_While Loops and Logic Building.ipynb",
    "chars": 16031,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"dfbc28de\",\n   \"metadata\": {},\n   \"source\": [\n    \"# While Loop\"\n"
  },
  {
    "path": "March Cohort 2023/21_EDA and Data Viz/.ipynb_checkpoints/21_EDA and Data Visualization-checkpoint.ipynb",
    "chars": 1498766,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"343be340\",\n   \"metadata\": {},\n   \"source\": [\n    \"# EDA\"\n   ]\n  "
  },
  {
    "path": "March Cohort 2023/21_EDA and Data Viz/21_EDA and Data Visualization.ipynb",
    "chars": 1498766,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"343be340\",\n   \"metadata\": {},\n   \"source\": [\n    \"# EDA\"\n   ]\n  "
  },
  {
    "path": "March Cohort 2023/21_EDA and Data Viz/itunes_data.csv",
    "chars": 343699,
    "preview": "Track,Composer,Milliseconds,Bytes,UnitPrice,Genre,Album,Artist\nFor Those About To Rock (We Salute You),\"Angus Young, Mal"
  },
  {
    "path": "March Cohort 2023/22_23_Time Series Forecasting/.ipynb_checkpoints/22_Forecasting-checkpoint.ipynb",
    "chars": 168774,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"12c7b612\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Time series "
  },
  {
    "path": "March Cohort 2023/22_23_Time Series Forecasting/.ipynb_checkpoints/23_ARIMA-checkpoint.ipynb",
    "chars": 163019,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"5e5ca069\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Auto Regress"
  },
  {
    "path": "March Cohort 2023/22_23_Time Series Forecasting/22_Forecasting.ipynb",
    "chars": 168774,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"12c7b612\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Time series "
  },
  {
    "path": "March Cohort 2023/22_23_Time Series Forecasting/23_ARIMA.ipynb",
    "chars": 163019,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"5e5ca069\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Auto Regress"
  },
  {
    "path": "March Cohort 2023/22_23_Time Series Forecasting/vimana.csv",
    "chars": 262,
    "preview": "Month,demand\n1,457\n2,439\n3,404\n4,392\n5,403\n6,371\n7,382\n8,358\n9,594\n10,482\n11,574\n12,704\n13,486\n14,509\n15,537\n16,407\n17,5"
  },
  {
    "path": "March Cohort 2023/22_23_Time Series Forecasting/wsb.csv",
    "chars": 865,
    "preview": "Month,Sale Quantity,Promotion Expenses,Competition Promotion\r1,3002666,105,1\r2,4401553,145,0\r3,3205279,118,1\r4,4245349,1"
  },
  {
    "path": "March Cohort 2023/24_SQL/SQLqueriesQandA.sql",
    "chars": 7733,
    "preview": "-- DROP DATABASE ORG;\n\nCREATE DATABASE ORG;\nSHOW DATABASES;\nUSE ORG;\n\n-- drop table Worker;\n\nCREATE TABLE Worker (\n\tWORK"
  },
  {
    "path": "March Cohort 2023/2_List and Strings.ipynb",
    "chars": 56513,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"f18f8832\",\n   \"metadata\": {},\n   \"source\": [\n    \"# List\\n\",\n   "
  },
  {
    "path": "March Cohort 2023/3_For Loop Dictionary Tuple and Sets.ipynb",
    "chars": 40635,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"958dd5a9\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Range functi"
  },
  {
    "path": "March Cohort 2023/4_Functions.ipynb",
    "chars": 27546,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"a98c255e\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Functions\"\n "
  },
  {
    "path": "March Cohort 2023/5_Modules and Packages.ipynb",
    "chars": 11019,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"507b0a7e\",\n   \"metadata\": {},\n   \"source\": [\n    \"# OS\\n\",\n    \""
  },
  {
    "path": "March Cohort 2023/5_Modules-Packages/main.py",
    "chars": 241,
    "preview": "# import rose\n\n# print(rose.pie)\n\n# print(rose.color())\n\nfrom statsmeme import descriptive\n\nprint(descriptive.mode())\n\nf"
  },
  {
    "path": "March Cohort 2023/5_Modules-Packages/rose.py",
    "chars": 97,
    "preview": "pie = 3000\n\ndef color():\n    return \"red\"\n\ndef flower():\n    return \"color of the flower is blue\""
  },
  {
    "path": "March Cohort 2023/5_Modules-Packages/statsmeme/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "March Cohort 2023/5_Modules-Packages/statsmeme/descriptive.py",
    "chars": 122,
    "preview": "def mean(l):\n    m = sum(l)/len(l)\n    return  m\n\n\ndef mode():\n    return \"this is mode function from descriptive stats\""
  },
  {
    "path": "March Cohort 2023/5_Modules-Packages/statsmeme/inferential.py",
    "chars": 55,
    "preview": "def models():\n    return \"models from inferetial stats\""
  },
  {
    "path": "March Cohort 2023/6_VirtualEnvironmentAndFlask/application.py",
    "chars": 976,
    "preview": "from flask import Flask, render_template\nimport requests\nfrom bs4 import BeautifulSoup\n\napp = Flask(__name__)  # __main_"
  },
  {
    "path": "March Cohort 2023/6_VirtualEnvironmentAndFlask/templates/index.html",
    "chars": 300,
    "preview": "<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta n"
  },
  {
    "path": "March Cohort 2023/7_NumPy/.ipynb_checkpoints/7_NumPy-checkpoint.ipynb",
    "chars": 18020,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"26f54c18\",\n   \"metadata\": {},\n   \"source\": [\n    \"# NumPy\\n\",\n  "
  },
  {
    "path": "March Cohort 2023/7_NumPy/7_NumPy.ipynb",
    "chars": 18020,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"26f54c18\",\n   \"metadata\": {},\n   \"source\": [\n    \"# NumPy\\n\",\n  "
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/.ipynb_checkpoints/8_9_Pandas-checkpoint.ipynb",
    "chars": 225487,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"a6a858e0\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Pandas\"\n   ]"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/8_9_Pandas.ipynb",
    "chars": 225487,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"a6a858e0\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Pandas\"\n   ]"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values.html",
    "chars": 155384,
    "preview": "<!DOCTYPE html>\n<!-- saved from url=(0059)https://www.dataoptimal.com/data-cleaning-with-python-2018/ -->\n<html lang=\"en"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/analytics.js.download",
    "chars": 44130,
    "preview": "(function(){var k=this,l=function(a,b){a=a.split(\".\");var c=k;a[0]in c||\"undefined\"==typeof c.execScript||c.execScript(\""
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/comment-reply.min.js.download",
    "chars": 2234,
    "preview": "window.addComment=function(a){function b(){c(),g()}function c(a){if(t&&(m=j(r.cancelReplyId),n=j(r.commentFormId),m)){m."
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/common.js.download",
    "chars": 1360,
    "preview": "(function($){\n\t$(document).ready( function(){\n\t\tvar user_agent = navigator.userAgent;\n\t\tvar is_opera_edge;\n\t\tvar browser"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/css",
    "chars": 4750,
    "preview": "/* cyrillic-ext */\n@font-face {\n  font-family: 'Open Sans';\n  font-style: normal;\n  font-weight: 400;\n  src: local('Open"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/css(1)",
    "chars": 24443,
    "preview": "/* cyrillic-ext */\n@font-face {\n  font-family: 'Open Sans';\n  font-style: italic;\n  font-weight: 300;\n  src: local('Open"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/css(2)",
    "chars": 3068,
    "preview": "/* latin-ext */\n@font-face {\n  font-family: 'Karla';\n  font-style: italic;\n  font-weight: 400;\n  src: local('Karla Itali"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/custom.js(1).download",
    "chars": 26019,
    "preview": "(function($){\n\t$(document).ready(function() {\n\t\tvar $locked_containers = [];\n\n\t\t$( '.et_bloom_make_form_visible' ).remov"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/custom.js.download",
    "chars": 26371,
    "preview": "(function($){\n\t$(document).ready(function() {\n\t\tvar all_networks_opened = 0;\n\n\t\t// fix the \"on media\" wrapper inside the"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/custom.min.js.download",
    "chars": 264205,
    "preview": "/*! ET et_shortcodes_frontend.js */\n!function($){$.fn.et_shortcodes_switcher=function(options){options=$.extend({slides:"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/form.js.download",
    "chars": 700,
    "preview": "var ak_js = document.getElementById( \"ak_js\" );\n\nif ( ! ak_js ) {\n\tak_js = document.createElement( 'input' );\n\tak_js.set"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/frontend.min.js.download",
    "chars": 8363,
    "preview": ";var MonsterInsights=function(){var t=[],a='';this.setLastClicked=function(e,n,i){e=typeof e!=='undefined'?e:[];n=typeof"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/idle-timer.min.js(1).download",
    "chars": 2518,
    "preview": "/*! Idle Timer v1.0.1 2014-03-21 | https://github.com/thorst/jquery-idletimer | (c) 2014 Paul Irish | Licensed MIT */\n!f"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/idle-timer.min.js.download",
    "chars": 2518,
    "preview": "/*! Idle Timer v1.0.1 2014-03-21 | https://github.com/thorst/jquery-idletimer | (c) 2014 Paul Irish | Licensed MIT */\n!f"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/jquery-migrate.min.js.download",
    "chars": 10056,
    "preview": "/*! jQuery Migrate v1.4.1 | (c) jQuery Foundation and other contributors | jquery.org/license */\n\"undefined\"==typeof jQu"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/jquery.js.download",
    "chars": 97183,
    "preview": "/*! jQuery v1.12.4 | (c) jQuery Foundation | jquery.org/license */\n!function(a,b){\"object\"==typeof module&&\"object\"==typ"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/jquery.uniform.min.js.download",
    "chars": 8308,
    "preview": "(function(e,t){\"use strict\";function n(e){var t=Array.prototype.slice.call(arguments,1);return e.prop?e.prop.apply(e,t):"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/linkid.js.download",
    "chars": 1569,
    "preview": "(function(){var e=window,h=document,k=\"replace\";var m=function(a,c,d,b,g){c=encodeURIComponent(c)[k](/\\(/g,\"%28\")[k](/\\)"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/prism-js.min.js.download",
    "chars": 22424,
    "preview": "/* http://prismjs.com/download.html?themes=prism */\nvar _self=\"undefined\"!=typeof window?window:\"undefined\"!=typeof Work"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/style(1).css",
    "chars": 632481,
    "preview": "/*!\nTheme Name: Divi\nTheme URI: http://www.elegantthemes.com/gallery/divi/\nVersion: 3.21\nDescription: Smart. Flexible. B"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/style(2).css",
    "chars": 466,
    "preview": "/*\nTheme Name: Divi Child theme of Divi\nTheme URI: \nDescription: Child theme of Divi theme for the Divi theme\nAuthor: <a"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/style(3).css",
    "chars": 94428,
    "preview": "/*------------------------------------------------*/\n/*--------------------[RESET]---------------------*/\n/*------------"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/style.css",
    "chars": 116076,
    "preview": "/*------------------------------------------------*/\n/*-----------------[RESET]------------------------*/\n/*------------"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/wp-embed.min.js.download",
    "chars": 1403,
    "preview": "!function(a,b){\"use strict\";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf(\"MSIE 10\"),h=!!navi"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/Data Cleaning With Pandas/Data Cleaning with Python and Pandas_ Detecting Missing Values_files/wp-emoji-release.min.js.download",
    "chars": 12034,
    "preview": "// Source: wp-includes/js/twemoji.min.js\nvar twemoji=function(){\"use strict\";function a(a,b){return document.createTextN"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/indore.csv",
    "chars": 97,
    "preview": ",day,temperature,windspeed,event\n0,1/1/2023,32,6,Rain\n1,1/2/2023,35,7,Sunny\n2,1/3/2023,32,6,Snow\n"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/nyc_weather.csv",
    "chars": 1368,
    "preview": "EST,Temperature,DewPoint,Humidity,Sea Level PressureIn,VisibilityMiles,WindSpeedMPH,PrecipitationIn,CloudCover,Events,Wi"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/stock_data.csv",
    "chars": 178,
    "preview": "tickers,eps,revenue,price,people\nGOOGL,27.82,87,845,larry page\nWMT,4.61,484,65,n.a.\nMSFT,-1,85,64,bill gates\nRIL ,not av"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/weather_by_cities.csv",
    "chars": 367,
    "preview": "day,city,temperature,windspeed,event\n1/1/2017,new york,32,6,Rain\n1/2/2017,new york,36,7,Sunny\n1/3/2017,new york,28,12,Sn"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/weather_data.csv",
    "chars": 148,
    "preview": "day,temperature,windspeed,event\n1/1/2017,32,6,Rain\n1/2/2017,35,7,Sunny\n1/3/2017,28,2,Snow\n1/4/2017,24,7,Snow\n1/5/2017,32"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/weather_data2.csv",
    "chars": 191,
    "preview": "day,temperature,windspeed,event\n1/1/2017,32,6,Rain\n1/4/2017,,9,Sunny\n1/5/2017,28,,Snow\n1/6/2017,,7,\n1/7/2017,32,,Rain\n1/"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/weather_datamissing.csv",
    "chars": 179,
    "preview": "day,temperature,windspeed,event\n1/1/2017,32,6,Rain\n1/2/2017,-99999,7,Sunny\n1/3/2017,28,-99999,Snow\n1/4/2017,-99999,7,0\n1"
  },
  {
    "path": "March Cohort 2023/8_9_Pandas/weather_datamissing_regex.csv",
    "chars": 239,
    "preview": "day,temperature,windspeed,event,speed\n01-01-2017,32C,6,Rain,45kmph\n01-02-2017,-99999,7,Sunny,40km\n01-03-2017,28F,-99999,"
  },
  {
    "path": "README.md",
    "chars": 3614,
    "preview": "# Data-Analyst-Roadmap\nData-Analyst-Roadmap for Students and Professionals\n\n![](https://github.com/hemansnation/Data-Ana"
  }
]

// ... and 6 more files (download for full content)

About this extraction

This page contains the full source code of the hemansnation/Data-Analyst-Roadmap GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 110 files (56.5 MB), approximately 3.2M tokens, and a symbol index with 10 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!