{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": "true"
   },
   "source": [
    "# Table of Contents\n",
    " <p><div class=\"lev1 toc-item\"><a href=\"#A-Section-for-TOC\" data-toc-modified-id=\"A-Section-for-TOC-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>A Section for TOC</a></div><div class=\"lev1 toc-item\"><a href=\"#Another-section\" data-toc-modified-id=\"Another-section-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>Another section</a></div><div class=\"lev1 toc-item\"><a href=\"#Yet-another-Section\" data-toc-modified-id=\"Yet-another-Section-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>Yet another Section</a></div><div class=\"lev2 toc-item\"><a href=\"#Sub-section\" data-toc-modified-id=\"Sub-section-31\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>Sub-section</a></div><div class=\"lev2 toc-item\"><a href=\"#An-would-you-like-another-sub-section?\" data-toc-modified-id=\"An-would-you-like-another-sub-section?-32\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>An would you like another sub-section?</a></div><div class=\"lev1 toc-item\"><a href=\"#How-is-you-code-feeling-today?\" data-toc-modified-id=\"How-is-you-code-feeling-today?-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>How is you code feeling today?</a></div><div class=\"lev1 toc-item\"><a href=\"#Do-you-get-the-gist-dictionary-comprehensions-all?\" data-toc-modified-id=\"Do-you-get-the-gist-dictionary-comprehensions-all?-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>Do you get the gist dictionary comprehensions all?</a></div><div class=\"lev1 toc-item\"><a href=\"#Would-you-like-some-math?\" data-toc-modified-id=\"Would-you-like-some-math?-6\"><span class=\"toc-item-num\">6&nbsp;&nbsp;</span>Would you like some math?</a></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# A Section for TOC"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Another section\n",
    "\n",
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tortor erat, faucibus in faucibus ut, mattis quis ligula. Vivamus ultricies non augue rhoncus placerat. Nulla eleifend, lacus eget fermentum tristique, nisi lectus aliquet risus, at vestibulum dolor mauris quis velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse elementum sapien turpis, in gravida felis iaculis vitae. Donec sodales, erat in rutrum sollicitudin, nisl nisl finibus eros, id blandit enim diam vitae ex. Aliquam et ligula id augue pretium fringilla. Donec turpis mi, pulvinar at velit et, pretium dapibus lorem. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Yet another Section\n",
    "Praesent aliquam ornare orci quis blandit. Donec pulvinar lacinia nulla at hendrerit. Morbi sed sem elementum, finibus tellus ac, vestibulum augue. In vestibulum tortor id augue molestie porta. In ut imperdiet dolor. Mauris sit amet condimentum ex, eu blandit quam. Suspendisse quis magna non ante sagittis bibendum. Etiam dictum justo et justo porta, at finibus purus aliquam. Nulla facilisi. In dolor mauris, mollis in blandit vitae, dictum non mauris. Aenean nec arcu vestibulum, maximus sem a, volutpat nisl. Vivamus dignissim ultricies justo. Praesent facilisis magna ac velit vestibulum tincidunt. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Sub-section\n",
    "Sed commodo ultrices risus, sed feugiat est luctus sed. Duis neque metus, fermentum tincidunt leo in, porttitor ullamcorper nisl. Ut efficitur nibh augue, ac hendrerit velit auctor ac. Aenean aliquet felis nec dui egestas, nec ornare turpis mollis. Nullam luctus viverra fermentum. Vivamus scelerisque nulla in erat rutrum, ac luctus nibh egestas. Donec fringilla augue cursus libero sagittis gravida. In hac habitasse platea dictumst. Morbi dignissim magna vitae justo fermentum, eu fermentum magna efficitur. Sed risus sem, elementum non faucibus at, venenatis ut sem. Nulla facilisi. In diam mauris, tincidunt et velit ac, imperdiet malesuada purus. Praesent hendrerit maximus sapien, eu accumsan magna venenatis eu. Suspendisse potenti. Praesent vitae viverra tellus, at lobortis orci. Quisque eget orci eu metus venenatis ultrices ac sit amet eros. \n",
    "\n",
    "\n",
    "*    Morbi eget elit non turpis faucibus condimentum at at felis.\n",
    "*    Cras dapibus mauris pharetra dictum pretium.\n",
    "*    Proin eget magna interdum dolor viverra auctor at eu augue.\n",
    "*    Quisque faucibus sem non turpis bibendum interdum.\n",
    "*    Donec fringilla elit at consectetur pulvinar.\n",
    "*    Maecenas vel massa eleifend, pretium tortor vitae, porttitor ligula.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## An would you like another sub-section?\n",
    "\n",
    "\n",
    "\n",
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nulla ligula, auctor non dui sed, lobortis mollis libero. Phasellus maximus quam eget libero blandit, non convallis odio vehicula. Phasellus leo sapien, congue vel sollicitudin vel, dapibus ut ipsum. Praesent et tellus nibh. Ut tristique at neque vitae viverra. Mauris quis justo sed metus luctus faucibus et non ex. Mauris suscipit, velit nec efficitur pulvinar, metus velit posuere augue, vitae scelerisque mi ex et dui.\n",
    "\n",
    "Fusce gravida dapibus posuere. Maecenas commodo maximus urna eu facilisis. Suspendisse ultricies bibendum mauris. Aenean accumsan vulputate dui, cursus ultrices turpis malesuada a. Pellentesque aliquet felis nisi, sed aliquet augue ornare at. Cras quis purus a urna accumsan bibendum. Maecenas at turpis est. \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# How is you code feeling today?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "code_folding": [
     5
    ],
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "count the examine scores from https://github.com/qiwsir/StarterLearningPython/blob/master/2code/20502.py\n",
    "\"\"\"\n",
    "from __future__ import division\n",
    "\n",
    "class Scorer: \n",
    "    def __init__(self):\n",
    "        pass\n",
    "    \n",
    "    def average_score(scores):\n",
    "        \"\"\"\n",
    "        count average score.\n",
    "        \"\"\"\n",
    "        score_values = scores.values()\n",
    "        sum_scores = sum(score_values)\n",
    "        average = sum_scores/len(score_values)\n",
    "        return average\n",
    "\n",
    "    def sorted_score(scores):\n",
    "        \"\"\"\n",
    "        count the list for max to min.\n",
    "        \"\"\"\n",
    "        score_lst = [(scores[k],k) for k in scores]\n",
    "        sort_lst = sorted(score_lst, reverse=True)\n",
    "        return [(i[1], i[0]) for i in sort_lst]\n",
    "\n",
    "    def max_score(scores):\n",
    "        \"\"\"\n",
    "        the max scroe and the person's name.\n",
    "        \"\"\"\n",
    "        lst = sorted_score(scores)\n",
    "        max_score = lst[0][1]\n",
    "        return [(i[0],i[1]) for i in lst if i[1]==max_score]\n",
    "\n",
    "    def min_score(scores):\n",
    "        \"\"\"\n",
    "        the min score and the person's name.\n",
    "        \"\"\"\n",
    "        lst = sorted_score(scores)\n",
    "        min_score = lst[len(lst)-1][1]\n",
    "        return [(i[0],i[1]) for i in lst if i[1]==min_score]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Do you get the gist dictionary comprehensions all?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# a dictionary comprehension example using lists\n",
    "\n",
    "list_keys = ['a', 'b', 'c']\n",
    "list_vals = [1, 2, 3]\n",
    "\n",
    "{a: b for a,b in zip(list_keys, list_vals)}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "hide_input": true
   },
   "source": [
    "# Would you like some math?\n",
    "\n",
    "You can use the normal `$` and `$$` to insert LaTeX math into your document to do pretty things like:\n",
    "\n",
    "$$\\boldsymbol{\\beta} = (\\beta_1,\\beta_2,\\dotsc,\\beta_n)$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But what if you want to do numbering of such pretty things?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\begin{equation}\n",
    "  \\label{eq:t}\n",
    "  \\begin{aligned}\n",
    "    f(x) &= x^2\\\\        \n",
    "    g(x) &= \\exp(x)\n",
    "  \\end{aligned}\n",
    "\\end{equation}\n",
    "\n",
    "\\begin{equation}\n",
    "\\left(\n",
    "    \\begin{array}{c}\n",
    "      n \\\\\n",
    "      r\n",
    "    \\end{array}\n",
    "  \\right) = \\frac{n!}{r!(n-r)!}\n",
    "\\end{equation}\n",
    "\n",
    "\\begin{equation}\n",
    "A_{m,n} =\n",
    "\\begin{pmatrix}\n",
    "  a_{1,1} & a_{1,2} & \\cdots & a_{1,n} \\\\\n",
    "  a_{2,1} & a_{2,2} & \\cdots & a_{2,n} \\\\\n",
    "  \\vdots  & \\vdots  & \\ddots & \\vdots  \\\\\n",
    "  a_{m,1} & a_{m,2} & \\cdots & a_{m,n} \n",
    " \\end{pmatrix}\n",
    "\\end{equation}"
   ]
  }
 ],
 "metadata": {
  "_draft": {
   "nbviewer_url": "https://gist.github.com/9b1ea86ff66d7ea623bda2c751de526a"
  },
  "anaconda-cloud": {},
  "gist": {
   "data": {
    "description": "example_document.ipynb",
    "public": true
   },
   "id": "9b1ea86ff66d7ea623bda2c751de526a"
  },
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "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.12"
  },
  "toc": {
   "nav_menu": {
    "height": "142px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": false,
   "threshold": 4,
   "toc_cell": true,
   "toc_position": {
    "height": "485px",
    "left": "1px",
    "right": "856.767px",
    "top": "103px",
    "width": "212px"
   },
   "toc_section_display": "none",
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
