You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

459 lines
143 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>\n",
"___\n",
"# Matplotlib Exercises \n",
"Welcome to the exercises for reviewing matplotlib! Take your time with these, Matplotlib can be tricky to understand at first. These are relatively simple plots, but they can be hard if this is your first time with matplotlib, feel free to reference the solutions as you go along.\n",
"\n",
"Also don't worry if you find the matplotlib syntax frustrating, we actually won't be using it that often throughout the course, we will switch to using seaborn and pandas built-in visualization capabilities. But, those are built-off of matplotlib, which is why it is still important to get exposure to it!\n",
"\n",
"**NOTE: ALL THE COMMANDS FOR PLOTTING A FIGURE SHOULD ALL GO IN THE SAME CELL. SEPARATING THEM OUT INTO MULTIPLE CELLS MAY CAUSE NOTHING TO SHOW UP.**\n",
"\n",
"# Exercises\n",
"\n",
"**We will focus on two commons tasks, plotting a known relationship from an equation and plotting raw data points.**\n",
"\n",
"Follow the instructions to complete the tasks to recreate the plots using this data:\n",
"\n",
"----\n",
"----\n",
"\n",
"### Task One: Creating data from an equation\n",
"\n",
"It is important to be able to directly translate a real equation into a plot. Your first task actually is pure numpy, then we will explore how to plot it out with Matplotlib. The [world famous equation](https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence) from Einstein:\n",
"\n",
"$$E=mc^2$$\n",
"\n",
"\n",
"Use your knowledge of Numpy to create two arrays: E and m , where **m** is simply 11 evenly spaced values representing 0 grams to 10 grams. E should be the equivalent energy for the mass. You will need to figure out what to provide for **c** for the units m/s, a quick google search will easily give you the answer (we'll use the close approximation in our solutions).\n",
"\n",
"**NOTE: If this confuses you, then hop over to the solutions video for a guided walkthrough.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The array m should look like this: \n",
"\n",
"[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]\n"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The array E should look like this: \n",
"\n",
" [0.0e+00 9.0e+16 1.8e+17 2.7e+17 3.6e+17 4.5e+17 5.4e+17 6.3e+17 7.2e+17\n",
" 8.1e+17 9.0e+17]\n"
]
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Part Two: Plotting E=mc^2\n",
"\n",
"Now that we have the arrays E and m, we can plot this to see the relationship between Energy and Mass. \n",
"\n",
"**TASK: Import what you need from Matplotlib to plot out graphs:**"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**TASK: Recreate the plot shown below which maps out E=mc^2 using the arrays we created in the previous task. Note the labels, titles, color, and axis limits. You don't need to match perfectly, but you should attempt to re-create each major component.**"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"# DON\"T RUN THE CELL BELOW< THAT WILL ERASE THE PLOT!"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEWCAYAAABhffzLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd5zU1dXH8c8BlCqCA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jC76nTqFpZxDh2Z10Yf0T/VUA2qaWTWgFvDfNL+fiEjl+P576NcPWrWCl15KHteoUdis9f770KFDfPlVQNoKv7svBm4DFgBLgG/d/ZWScWZ2kZlNNrPJK6J2uImIxMEdhg8P8/g33wwbNmw5rmrV0FZ57lw47zyokju3TNM51VMfOAnYHWgM1DazriXj3H2ou3dw9w4Ns/zXIxHJc9Onh0ZpXbrA4sXJ4446KsQOGhROxcox6fwRdTQw391XuPsG4FngoDS+n4hI+axaFdostGsH77yTPG633WDECHj1Vdhnn/jyq2TpXNWzADjAzGoB64CjgMlpfD8RkbLZuBEefBAGDICvv04eV7069OkT5vxr1YovvzRJW+F394lmNgKYChQB04Ch6Xo/EZEymTAh7LqdMiU67qSTwpTOHnvEk1cM0rqO392vAa5J53uIiJTJ0qVh5D5sWHRcs2bhUJT/+Z948opR7tyGFhGpiA0bwsi9WbPool+nTuirM2NGXhZ9UK8eESkEr70G3bvDrFnRcWedFYp+48bx5JUhKvwikr+++gouuwyefTY6bt99Q2+dQw6JJ68M01SPiOSfdevg2mvDJqyool+/PtxzD0yeXDBFHzTiF5F84g7PPx921H75ZfI4M7joIvjnP6FBg9jSyxYq/CKSH2bPhh494JVfdYb5pYMOCtM67dvHk1cW0lSPiOS2776DK64Ih55EFf0dd4RHH4X33ivoog8a8YtIrnKHJ54IO2qXLEkeV61a6KN/1VVQt258+WUxFX4RyT3TpoVdt+PHR8f99rdhE1aLFvHklSM01SMiuePrr+Gvfw1976OKfpMmYTXPuHEq+lugEb+IZL+NG8PJVn//e+ikmUyNGqEdQ58+ULNmfPnlGBV+Eclu48eHlskffRQdd8opcPvtYbQvkTTVIyLZackSOPvssLEqqui3aBFW84wcqaKfIhV+EckuP/0Et94amqk9/njyuG22gdtug48/DjdxJWWa6hGR7DFuXNiENWdOdNw558BNN8FOO8WTV55R4ReRzJs/PzRTGzUqOq59+7Dr9iCd4loRmuoRkcxZuxauuSacXxtV9LffHv79b5g0SUW/EmjELyLxc4fnngvN1BYsSB5XpQr85S9w3XWw3Xbx5ZfnVPhFJF6zZoVDUV57LTrukEPCtM6++8aTVwHRVI+IxGPNGrj8cmjTJrro77RT6MHzzjsq+mmiEb+IpNemTfDYY9C3Lyxbljxuq63C1M/f/x6WakraqPCLSPpMmRKaqU2YEB13zDFwxx3QvHk8eRU4TfWISOVbuRIuvhg6dowu+rvvHk7MGjtWRT9GGvGLSOUpKoL77gu977/5JnlczZrQv384QKVGjfjyE0CFX0Qqy7vvhmZq06dHx516ami18JvfxJOX/IqmekSkYhYvhi5doHPn6KK/zz5hNc8zz6joZ5gKv4iUz/r1cPPNYW5++PDkcXXrwuDBocPmUUfFl58kpakeESm7l14KzdTmzYuOO++80Exthx1iSUtSo8IvIqn7/POw1n706Oi4Dh3CrtsDDognLykTTfWISOnWrg0rdVq2jC76DRrA/ffDxIkq+llMI34RSc4dRowIrRYWLkweV6UKXHopDBwI9evHl5+Uiwq/iGzZJ5+EXbdvvhkd17lzmNZp0yaevKTCNNU
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Part Three (BONUS)\n",
"\n",
"**Can you figure out how to plot this on a logarthimic scale on the y axis? Place a grid along the y axis ticks as well. We didn't show this in the videos, but you should be able to figure this out by referencing Google, StackOverflow, Matplotlib Docs, or even our \"Additional Matplotlib Commands\" notebook. The plot we show here only required two more lines of code for the changes.**"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"# DONT RUN THE CELL BELOW! THAT WILL ERASE THE PLOT!"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAEWCAYAAACe8xtsAAAABHNCSVQICAgIfAhkiAAAAA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5jE++CB8ScHTwogiktyqVeEhvjvvhNdeS/99XbvCBRfAkCHQvn109UnWaGFEEWkcd5g1KwTGmDHhSfB0bLFFmPy+8EI49FDdXlsCFB4iAl99BQ88ACNHwpw56b+vR49wlnHmmWqmVGIUHiKlyh1mzAhnGY88kv5yIVtuGW6vvfBC6NVLZxklSuEhUmo+/xzuuy+Exrvvpv++nj3DWcbgwdCmTXT1SUFQeIiUAnd48UX4xz9Cv4x0V7HdaqsQFhdcAPvvH22NUlAUHiLFbPNmeOIJuOGGMBGert69Q2Ccfjq0bh1dfVKwFB4ixWj9+nBp6sYb4cMP03vPNtvAWWeFh/n23jva+qTgKTxEisnXX4dLUyNGwJIl6b2nT59wlnHKKdCyZbT1SdFQeIgUg2XL4JZb4Pbbw2239dluu7BUyPnnQ7dukZcnxUfhIVLI5s+Hm26CUaPCpar6lJfDFVfASSeFB/tEGkjhIVKI3nwT/vSn8HxGRUX9+/ftC0OHwuGH67kMyQqFh0ihcIcXXgh3Tk2eXP/+TZqEJUN++cvwjIZIFik8RPJdRQU8+WQ403j11fr3b94czj03XJ7abbfo65OSpPAQyVcbNoT1pm68Ed5/v/7927SBiy+Gn/wEdtgh+vqkpBVFeKifhxSTsjVr2GHCBDo/+ihbrFhR7/4bttmGT087jcX9+7O5dWuYOzd8iURI/TxE8sVnn8Ff/wq33QZffFH//rv
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"---\n",
"---\n",
"\n",
"## Task Two: Creating plots from data points\n",
"\n",
"In finance, the yield curve is a curve showing several yields to maturity or interest rates across different contract lengths (2 month, 2 year, 20 year, etc. ...) for a similar debt contract. The curve shows the relation between the (level of the) interest rate (or cost of borrowing) and the time to maturity, known as the \"term\", of the debt for a given borrower in a given currency.\n",
"\n",
"The U.S. dollar interest rates paid on U.S. Treasury securities for various maturities are closely watched by many traders, and are commonly plotted on a graph such as the one on the right, which is informally called \"the yield curve\".\n",
"\n",
"**For this exercise, we will give you the data for the yield curves at two separate points in time. Then we will ask you to create some plots from this data.**\n",
"\n",
"## Part One: Yield Curve Data\n",
"\n",
"**We've obtained some yeild curve data for you from the [US Treasury Dept.](https://www.treasury.gov/resource-center/data-chart-center/interest-rates/pages/textview.aspx?data=yield). The data shows the interest paid for a US Treasury bond for a certain contract length. The labels list shows the corresponding contract length per index position.**\n",
"\n",
"**TASK: Run the cell below to create the lists for plotting.**"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"labels = ['1 Mo','3 Mo','6 Mo','1 Yr','2 Yr','3 Yr','5 Yr','7 Yr','10 Yr','20 Yr','30 Yr']\n",
"\n",
"july16_2007 =[4.75,4.98,5.08,5.01,4.89,4.89,4.95,4.99,5.05,5.21,5.14]\n",
"july16_2020 = [0.12,0.11,0.13,0.14,0.16,0.17,0.28,0.46,0.62,1.09,1.31]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**TASK: Figure out how to plot both curves on the same Figure. Add a legend to show which curve corresponds to a certain year.**"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"# DONT RUN THE CELL BELOW! IT WILL ERASE THE PLOT!"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcsAAAE/CAYAAAApAehIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de3xU9Z3/8dc39ysJIQkEEuR+v4MXxHoBUdlaL23XhYe12l3XR9u1F9u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NdOKKcrV8OpQ0Nru52h18zm90YOVjTT1sk9cIjAGhmelMTwrNWzIDQ/ZNaFj+WA/Ma9ItJz3NsuBzFrL3o/d4dXySnZU1GEtlORl8OkFY1g2fSSLNbw6JKWnJDN5ZC6TR3Y9tY+1lvqz7Vii/09kNBgMORkpCdvzFRmsBl1Ytrb72XKohk3lp9hUXsnxOuc0NXNL87jv2iksm17MjJJh+i9bwjLGkJelWc0i0tWgCMvqxlZe3VvJpvJK/rC/iiafn4zUJK6YVMRXlk5i6bRiiiM47YuIiEg4AzIsrbXsO+XMdtxUfor3jznDqyOHpXPz/DFcO72YyycWanhVRESiYsCEpa89wNuHndmrr5SfCp4FfPaYPL62bDLXTh/JzNEaXhURkehL6LCsafKxea9zaLnX952msbWd9JQkrphUyJevdoZX+/PknyIiMjQldFj+8JV9PPXWEYpz0/nU3BKWTRvJkkmF2v9LRET6VUKH5V2Xj+OzC0uZNTpPZ54QEZG4SeiwnFCUE+8SRERE0IEcRUREPCgsRUREPCgsRUREPCgsRUREPCgsRUREPCgsRUREPCg
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**TASK: The legend in the plot above looks a little strange in the middle of the curves. While it is not blocking anything, it would be nicer if it were *outside* the plot. Figure out how to move the legend outside the main Figure plot.**"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"# DONT RUN THE CELL BELOW! IT WILL ERASE THE PLOT!"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAj4AAAE/CAYAAABGhsmUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmU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PdY3EeBjqau/y6g+H65z5OmWnddI/hFWSm67lc7O1rGiK5k5NYYx/nGts7ewNQn17iSrqWvpNap2enqAZWT09QwkR2zPk9VmdbesZWhrQU9Pa2W/CeF8xUeZcaOkNLzEBjzjqCTUJsQR9uA9DXROfq4JPTVOHfwjrtD4or1Vrp1cJMc4Q1vK5U7S0KFtZKQxhuUFHt1fH6lrP6yU6VN2sliHOuRIJjJEmJcZqUmJMwMAyqc/h0j3LU+KiCfHACBB8Jr7x378/BGut9lX5h7DKqrW7slHWSlPT4nXroum6fu4UXcUQlivFRUdp9pQUzZ6S0m+5tVZn27plFfz/EASDkVFyfHTE9kgBQKSbcMGno9urPxyu19ay09paVq0TjW2SpJLcNP3V8jm6fm625k1N5X+/CMgYo7REjs4DgIlqQgSfuuYO/XZftbaWVev9gzVq6fQqPsaja2dl6S+XzdKyomxlp3IVXwAA3G5cBh9rrQ6cdo7a2Vp2Wp8cd4awpqTGaeXC6Vo+N1tXz8xkCAsAAPQzboJPZ7dPHx5xjsJ6t+y0KhucIazLpqfpe9fP1vK5U1Q8jSEsAAAwuIgOPvUtndq2z7k8xI4DtWru6FZctEfXzsrUd69zhrBy0hjCAgAAIxPRwedn7x7QP/++QtkpcVpRMlXXF03
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**TASK: While the plot above clearly shows how rates fell from 2007 to 2020, putting these on the same plot makes it difficult to discern the rate differences within the same year. Use .suplots() to create the plot figure below, which shows each year's yield curve.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
"# DONT RUN THE CELL BELOW! IT WILL ERASE THE PLOT!"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBOR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lu0iO6+IQXEtmTYunov7tSe8QZinsXlFZRIiIiIiNeBYQTE3v7Cc9Rk5/OOmYZzfp53XIX0jr7CYecnpvLAolZ2ZecS2asJtY+KZNDyO5o1DqzhAybCIiIhINcsrLObWF1eQvDuLp28cysX923sdUrlKfI7PNu1nxsJUvt55mMiIcG48qzO3julKhxZNvA6vVigZFhEREalG+UUlfHfmCpalZPKX64dw+aCOXodUKavTspmxMIUP1+/DgMsGdmDquAT6d2rhdWg1SsmwiIiISDXJLyrh9leSWbjtIH+cOIirh8R6HVKVpR3OY+aSnbz59W5yC0sYldCaaWfHc07PtoSFBd9kOyXDIiIiItWgsNjHXa8m89nmA/z+2oFMHB7ndUhn5Eh+EW9+vZt/Lt7J3px8urVpxtRxCVw9pBMRDYNnEQ8lwyIiIiJnqKjEx92vr+TjDfv59VX9uWlkF69DqjZFJT4+WLeX6QtTWJ9xhNbNGnHzqC7cPLILrZs39jq8M6ZkWEREROQMFJf4+OGs1by3di+/vLwvt42J9zqkGuGcY1nKYWYsTOGzzQdoHB7GNUNjmTI2nu5tm3sd3mnTohsiIiIip6nE53hg7lreW7uXh8f3DtpEGPyLeIzq1ppR3Vqz/cAxXliUyryV6bzx9W7O792WqeMSGJkQHVSLeGhkWEREROQkfD7HQ/PXMjspnfsv7Mnd5/XwOqRad+hYwTeLeBzOLaR/pyimjUvgkgEdaFhPFvFQmYSIiIhIFTnneOTt9by6bDf3nNedH1/Yy+uQPJVfVMJbqzKYsTCFHQd
"text/plain": [
"<Figure size 864x576 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**BONUS CHALLENGE TASK: Try to recreate the plot below that uses twin axes. While this plot may actually be more confusing than helpful, its a good exercise in Matplotlib control.**"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [],
"source": [
"# CODE HERE"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [],
"source": [
"# DONT RUN THE CELL BELOW! IT ERASES THE PLOT!"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([0. , 0.2, 0.4, 0.6, 0.8, 1. , 1.2, 1.4]),\n",
" <a list of 8 Text yticklabel objects>)"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAxUAAAHiCAYAAACeFeGCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdeZzVc/vH8dfVqpCkFKGyFHKHZMmWJRIllL1Syq4IP25uwo3bdtu3slQqe0WKiqiIQnJbohKFFlkqbdNUM5/fH9cZJTPTmZlz5nuW9/Px6HGW+Z7vuSaZ+V7n87muy0IIiIiIiIiIlFaFqAMQEREREZH0pqRCRERERETKREmFiIiIiIiUiZIKEREREREpEyUVIiIiIiJSJkoqRERERESkTJRUiIgkiJkNMrPbUyCOo8xsfoLOda6ZvRXnscV+/2YWzGz3RMQlIiKpRUmFiMhmmNlEM+uZxPNXMbNhZjYvduF9VCHHNDez98xspZktNrMrNvpaqS/WzewOM3tnk+cam9lyM/tHCOG5EMLxpTl3KWJpE/seV5jZr2Y2ycxOLo/3FhGRslFSISKSGiYDnYGfN/2CmdUGxgL9ge2A3YG4Vg/i8G+gnpldEHsvA54C7g8hfJmg99gsM+sEvAIMBnYC6gJ9gfalOJeZmX6/iYiUI/3QFRGJk5l1M7PJmzxX6CqBmX1lZu03elzZzH4zs/02PTaEsDaE8GAIYTKQV8hbXwWMi60a5IYQVoQQvomd973YMZ/HVjHO3Og9rzazX8xskZl1L+x7CiHkAucDd5lZfeBCYFvgjsK+ZzPb08zeNrMlZjbLzM4o4q8LM/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light"
},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"-----"
]
}
],
"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.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}