{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "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[0mTraceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-b2533e01f223>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mMATH_CONST_VALUE\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m3.1415\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2.71828\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mMATH_CONST_VALUE\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2.7\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "MATH_CONST_VALUE=(3.1415,2.71828)\n",
    "MATH_CONST_VALUE[1]=2.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([3.14], [2.71828])\n"
     ]
    }
   ],
   "source": [
    "MATH_CONST_VALUE=([3.1415],[2.71828])\n",
    "MATH_CONST_VALUE[0][0]=3.14\n",
    "print MATH_CONST_VALUE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AACAAACAA\n"
     ]
    }
   ],
   "source": [
    "print \"AACBBBCAA\".replace(\"BBB\",\"AAA\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cmp(\"beiping\",\"beijing\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"China Beijing\".find(\"i\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bill Gates\n",
      "BILL GATES\n",
      "bill gates\n"
     ]
    }
   ],
   "source": [
    "name=\"Bill gates\"\n",
    "print name.title()\n",
    "print name.upper()\n",
    "print name.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "China,Beijing,Chaoyang\n",
      "China,Beijing,Chaoyang  \n",
      "  China,Beijing,Chaoyang\n"
     ]
    }
   ],
   "source": [
    "print \"  China,Beijing,Chaoyang  \".strip()\n",
    "print \"  China,Beijing,Chaoyang  \".lstrip()\n",
    "print \"  China,Beijing,Chaoyang  \".rstrip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['  China', 'Beijing', 'Chaoyang  ']"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"  China,Beijing,Chaoyang  \".split(\",\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['  Ch', 'na,Be', 'j', 'ng,Chaoyang  ']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"  China,Beijing,Chaoyang  \".split(\"i\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[99, 103, 98, 102, 123, 456]\n",
      "None\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "'150718'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0mTraceback (most recent call last)",
      "\u001b[1;32m<ipython-input-14-97871591f1e0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[0mk\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;32mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmydict\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m`\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m`\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[1;32mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmydict\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m`\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m`\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m: '150718'"
     ]
    }
   ],
   "source": [
    "mydict={}\n",
    "k=150717\n",
    "mydict[`k`]=[99,103,98,102,123,456]\n",
    "print(mydict[`k`])\n",
    "k=k+1\n",
    "print(mydict.get(`k`))\n",
    "print(mydict[`k`])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{106: ['Mark', '3465774'], 107: ['Lary', '8936274'], 101: ['tim', '0:444689-202,F:34587349'], 102: ['Yuri', '3424243'], 103: ['John', '0:3243141,H:8925738']}\n",
      "Keys:\n",
      "[106, 107, 101, 102, 103]\n",
      "Key-Value\n",
      "[(106, ['Mark', '3465774']), (107, ['Lary', '8936274']), (101, ['tim', '0:444689-202,F:34587349']), (102, ['Yuri', '3424243']), (103, ['John', '0:3243141,H:8925738'])]\n"
     ]
    }
   ],
   "source": [
    "my_empo_dict={101:['tim','0:444689-202,F:34587349'],102:['Yuri','3424243'],103:['John','0:3243141,H:8925738']}\n",
    "my_empo_dict[106]=['Mark','3465774']\n",
    "my_empo_dict.update({107:['Lary','8936274']})\n",
    "print my_empo_dict\n",
    "print\"Keys:\"\n",
    "print my_empo_dict.keys()\n",
    "print\"Key-Value\"\n",
    "print my_empo_dict.items()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "S = {123, 'sed', (10, 'cs'), 43}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set(['a', 'p', 'e', 'l'])\n",
      "set(['tiger', 'dog', 'human', 'cat'])\n"
     ]
    }
   ],
   "source": [
    "W = set(\"apple\")\n",
    "V = set(('dog','cat','tiger','human'))\n",
    "print W\n",
    "print V"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"BIT\" in {123, \"BIT\", \"ok\", \"test\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set(['test', 'BIT', 123, 'ok'])\n",
      "('BIT', 123, 'ok')\n"
     ]
    }
   ],
   "source": [
    "tup = (123,\"BIT\", \"ok\", \"test\", 123)\n",
    "print set(tup)\n",
    "newtup = tuple(set(tup)-{\"test\"})\n",
    "print newtup\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}