{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:43:45.359504Z",
     "start_time": "2019-03-21T05:43:45.343877Z"
    }
   },
   "outputs": [],
   "source": [
    "dict1 = {\"Name\": \"Akshay\", \"Place\": \"California\", \"Year\": 2020}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:43:48.752321Z",
     "start_time": "2019-03-21T05:43:48.736698Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Akshay\n"
     ]
    }
   ],
   "source": [
    "print(dict1[\"Name\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:43:51.452714Z",
     "start_time": "2019-03-21T05:43:51.437070Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name\n",
      "Place\n",
      "Year\n"
     ]
    }
   ],
   "source": [
    "for x in dict1:\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:43:54.136513Z",
     "start_time": "2019-03-21T05:43:54.105322Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Akshay\n",
      "California\n",
      "2020\n"
     ]
    }
   ],
   "source": [
    "for x in dict1:\n",
    "    print(dict1[x])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:43:57.269660Z",
     "start_time": "2019-03-21T05:43:57.254053Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Akshay\n",
      "California\n",
      "2020\n"
     ]
    }
   ],
   "source": [
    "for x in dict1.values():\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:43:59.929632Z",
     "start_time": "2019-03-21T05:43:59.913986Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name Akshay\n",
      "Place California\n",
      "Year 2020\n"
     ]
    }
   ],
   "source": [
    "for x, y in dict1.items():\n",
    "    print(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:02.960993Z",
     "start_time": "2019-03-21T05:44:02.945426Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "print(len(dict1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:05.497814Z",
     "start_time": "2019-03-21T05:44:05.466540Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict1.pop(\"Year\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:07.719224Z",
     "start_time": "2019-03-21T05:44:07.703599Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(dict1.popitem())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:10.459726Z",
     "start_time": "2019-03-21T05:44:10.444119Z"
    }
   },
   "outputs": [],
   "source": [
    "del dict1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:12.929123Z",
     "start_time": "2019-03-21T05:44:12.913501Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:16.951747Z",
     "start_time": "2019-03-21T05:44:16.936104Z"
    }
   },
   "outputs": [],
   "source": [
    "dict2 = {\"Name\": \"Akshay\", \"Place\": \"California\", \"Year\": 2020}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:19.624108Z",
     "start_time": "2019-03-21T05:44:19.608538Z"
    }
   },
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:22.208170Z",
     "start_time": "2019-03-21T05:44:22.192585Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "re.compile('ab*')\n"
     ]
    }
   ],
   "source": [
    "p = re.compile('ab*')\n",
    "print(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:24.223635Z",
     "start_time": "2019-03-21T05:44:24.192448Z"
    }
   },
   "outputs": [],
   "source": [
    "s = \"Akshay went to California\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:27.033547Z",
     "start_time": "2019-03-21T05:44:27.017983Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['A', 'a', 'a', 'a']\n"
     ]
    }
   ],
   "source": [
    "x = re.findall(\"a\", s, re.IGNORECASE)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:29.220900Z",
     "start_time": "2019-03-21T05:44:29.205281Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<re.Match object; span=(2, 6), match='shay'>\n"
     ]
    }
   ],
   "source": [
    "print(re.search('shay', s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:44.451728Z",
     "start_time": "2019-03-21T05:44:44.436164Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Aks']"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(\"Aks\", s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:46.921413Z",
     "start_time": "2019-03-21T05:44:46.905779Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['San', 'ay']"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.split(\"j\", \"Sanjay\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:44:49.288470Z",
     "start_time": "2019-03-21T05:44:49.257265Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Sajjay'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.sub(\"n\", \"j\", \"Sanjay\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-17T03:14:23.421880Z",
     "start_time": "2019-04-17T03:14:23.366635Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'magauthami'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import re\n",
    "re.sub(\"hesh\", \"gauthami\", \"mahesh\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[] indicates a set of characters, {} indicates repitition, \\d indicates digits"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:45:50.211033Z",
     "start_time": "2019-03-21T05:45:50.179786Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['T']"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = \"This is a different string. Fair review.\"\n",
    "x = re.findall(\"^T\", s)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:46:54.786020Z",
     "start_time": "2019-03-21T05:46:54.770377Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "x = re.findall(\"2\", s)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:46:59.189747Z",
     "start_time": "2019-03-21T05:46:59.174123Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = re.findall('[0-9]', s)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:47:02.424465Z",
     "start_time": "2019-03-21T05:47:02.393273Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "x = re.match(\"ai+\", s)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:47:04.896596Z",
     "start_time": "2019-03-21T05:47:04.880975Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['h',\n",
       " 'i',\n",
       " 'i',\n",
       " 'a',\n",
       " 'd',\n",
       " 'i',\n",
       " 'f',\n",
       " 'f',\n",
       " 'e',\n",
       " 'e',\n",
       " 'i',\n",
       " 'g',\n",
       " 'a',\n",
       " 'i',\n",
       " 'e',\n",
       " 'i',\n",
       " 'e']"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = re.findall(\"[a-m]\", s)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-21T05:53:07.969452Z",
     "start_time": "2019-03-21T05:53:07.938210Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = re.findall(\"^[a-z]\", s)\n",
    "x"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.6.7"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}