mirea-projects/Third term/Artificial intelligence systems and big data/1.ipynb

637 lines
90 KiB
Plaintext
Raw Permalink Normal View History

2024-09-23 23:22:33 +00:00
{
"cells": [
{
"cell_type": "markdown",
"id": "93d8c208-e950-4681-b4fe-1c78fc1b2a21",
"metadata": {},
"source": [
"# Рабочая тетрадь No 1"
]
},
{
"cell_type": "markdown",
"id": "362b66a9",
"metadata": {},
"source": [
"1.3 Задание"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b9a69252-6f4f-496f-bb22-6bbbed2cdcac",
"metadata": {},
"outputs": [],
"source": [
"x = 5 >= 2\n",
"A = {1,3,7,8}\n",
"B = {2,4,5,10,'apple'}\n",
"C = A & B\n",
"df = 'Антонова Антонина', 34, 'ж'\n",
"z = 'type'\n",
"D = [1, 'title', 2, 'content']"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "553ba58d-ca06-49fb-a652-cede2cc33559",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True | <class 'bool'> \n",
" {8, 1, 3, 7} | <class 'set'> \n",
" {2, 4, 5, 'apple', 10} | <class 'set'> \n",
" set() | <class 'set'> \n",
" ('Антонова Антонина', 34, 'ж') | <class 'tuple'> \n",
" type | <class 'str'> \n",
" [1, 'title', 2, 'content'] | <class 'list'>\n"
]
}
],
"source": [
"print(x, '|', type(x), '\\n', A, '|', type(A), '\\n', B, '|', type(B),\n",
" '\\n', C, '|', type(C), '\\n', df, '|', type(df), '\\n',\n",
" z, '|', type(z),'\\n', D, '|', type(D),)"
]
},
{
"cell_type": "markdown",
"id": "2ee18350-697a-4d9a-a22a-4362b7870a7f",
"metadata": {},
"source": [
"2.3 Задание"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "092547e5-a728-4b08-9640-8acc2537285c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"х принадлежит (5, +infinity)\n"
]
}
],
"source": [
"x = 10\n",
"\n",
"if x < -5:\n",
" print(\"x принадлежит (-infinity, -5)\")\n",
"elif x >= -5 and x <= 5:\n",
" print(\"x принадлежит [-5;5]\")\n",
"else:\n",
" print(\"х принадлежит (5, +infinity)\")"
]
},
{
"cell_type": "markdown",
"id": "b157c155-7cd1-485d-9dbd-63075743a3a3",
"metadata": {},
"source": [
"Задание 3.3.1"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "638e3938-cdbe-48b5-a089-f47a1b7317f5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n",
"7\n",
"4\n",
"1\n"
]
}
],
"source": [
"x = 10\n",
"while x > 0:\n",
" print(x)\n",
" x -= 3"
]
},
{
"cell_type": "markdown",
"id": "c64c1c7a-d9ec-491c-8b2f-4d0e3ac33d64",
"metadata": {},
"source": [
"Задание 3.3.2."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f6d05bd4-277e-4420-9368-3d3eb457e521",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Пол\n",
"Возраст\n",
"Группа крови\n"
]
}
],
"source": [
"list_of_human_characters = [\"Пол\", \"Возраст\", \"Группа крови\"]\n",
"\n",
"for character in list_of_human_characters:\n",
" print(character)"
]
},
{
"cell_type": "markdown",
"id": "f31280d8-374d-443e-8578-530748ea61aa",
"metadata": {},
"source": [
"Задание 3.3.3."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "0a5413ba-1e73-473a-9940-326b75d2cb68",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n"
]
}
],
"source": [
"list_of_numbers = range(2, 16)\n",
"\n",
"print(list(list_of_numbers))"
]
},
{
"cell_type": "markdown",
"id": "1a8bf4ca-ec68-4224-b3cb-a57e7bfda81b",
"metadata": {},
"source": [
"Задание 3.3.4."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "bc3e295f-1fa1-4822-96ec-87b128e97ec2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"105\n",
"80\n",
"55\n",
"30\n",
"5\n"
]
}
],
"source": [
"for i in range(105, 4, -25):\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"id": "c7cfb41f-d1dd-4e64-b524-6061eec4377a",
"metadata": {},
"source": [
"Задание 3.3.5."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "071fff6c-ef63-40ea-bb59-b3c740cdd667",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[8, 1, 6, 3, 4, 5, 2, 7, 0, 9]\n"
]
}
],
"source": [
"x = [0,1,2,3,4,5,6,7,8,9]\n",
"x[::2] = x[::2][::-1]\n",
"\n",
"print(x)"
]
},
{
"cell_type": "markdown",
"id": "0f07122f-4736-43ae-b784-9f809eb15867",
"metadata": {},
"source": [
"4.3.1 Задание"
]
},
{
"cell_type": "code",
"execution_count": 66,
"id": "c0d364bc-976e-4e92-b23c-f0612d4d116e",
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"from statistics import median\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "a0e5ad2a-4f64-4dd1-a23e-f094834a1883",
"metadata": {},
"outputs": [],
"source": [
"count = 1000\n",
"\n",
"x_values = np.concatenate([np.random.random(count)])\n",
"y_values = list(range(count))"
]
},
{
"cell_type": "code",
"execution_count": 68,
"id": "90791a47-6edf-4d72-9ffc-2a859a9b5b2f",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.48475484828462484\n",
"0.4998818822942002\n"
]
}
],
"source": [
"avg_value = sum(x_values) / len(x_values)\n",
"median_value = median(x_values)\n",
"\n",
"print(avg_value)\n",
"print(median_value)"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "892aab6d-5ce0-4d66-b45a-e4ba218aff39",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0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VlD7irViKE2VwoVL9SiL0a3nsEvgJRYWpaE/OHE6ak0UURJ8NCP1Bb24J22tHcCiVu+jwHCtUW5cY6MjbNFcqrXum3OfwtiJ2hkXPaHpSzUtSit2N4zxFaak7KViYnK6pSR9ema2hWwtNS3UXNunLe3cPIIjJ6dFGSPZYhmEtlcGnnvpfLJ1FmPFUJqqzZjKITQmqhhpZHiwrUbAB0pw+hIWuDVB7QnJHpBSXrjrVHK9kAW5b8cGMuMs1Vo337dTUVMTB3KjJzT9Pdtv9ZL/uJAKaKN1UNq1Qc6ir/1Hz7SVntfn9WIsIsWHbsCZv6Fr5qRdCGl7uSEVNDl8sL7YzM/d9r7CY+X+JhEmXFWx70A89t03sHLgqthYtaJ/0Z9+8cpcm6Um3QMSq1LipvX9LhTDMnuHgvHDS+ferJl7x6cwIyguK5MNwIee0PTHRkdIv51Bit9z2/o1bVqPL2WPu4ZUK6Y2pv15SlooEDZ/uWvmyFKw/dGS8aW+Q/d3VMWn2YRlp90999J58Xc5wVAkFhJ7oLrv6+I78wCuUkqbAOvMpXrU3EgsValG7P5OEsMKZcRJ595dMyFDtWw2AB96QugDDSFMTSgloG34BMCRk9NtufDb1q/Bcy+dx/TMLO47fAr3jk8tXh9AqUIkBROT0+hTisypDwlYLktBen+umMuMg/p+6macnplFrU+hZrE1Aq2bsOy0u1Qh5qKIay+3a6G+oDG0YgCTv/kzUb+TCGbqcBserGHVygFWCZAoRKHCQsncS60R1XyebhRs9YzQpzZGURfI4y++igWtvZq/EaRGMF1X60s
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(x_values, y_values)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "5320fef5-cf42-4dd4-a09c-2705a93864c2",
"metadata": {},
"source": [
"4.3.2 Задание"
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "d9b6bc90-8c75-4a0b-a3d9-739e12c1769b",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 71,
"id": "7dc99ddf-fcbe-4a91-9ee3-f102f5c525c7",
"metadata": {},
"outputs": [],
"source": [
"def function(x):\n",
" return (np.sqrt(1 + np.e ** np.sqrt(x) + np.cos(x ** 2)) / abs(1 - np.sin(x) ** 3)) + np.log(2 * x)"
]
},
{
"cell_type": "code",
"execution_count": 72,
"id": "d1bf7069-4c70-4ca5-852c-5c0481c9ee23",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAjr0lEQVR4nO3de3Bb53nn8e/Du0iClqgLIUuyJdkyKNtN65hrK3GbSHVTu2k29nQmO+q0HU02M5qdzaRup01it7OT2e566ky6bbK7bXfV3NQ2G9V1vLE3bZ26slmnru3EtnyVSFmWbJkSL7JuBCmJNzz7BwASoHhEEjggbr/PjAbAwSHw8iX1w+F73vM+5u6IiEhlqSl2A0REJHwKdxGRCqRwFxGpQAp3EZEKpHAXEalAdcVuAMCqVat848aNxW5GXkZHR2lpaSl2M0qG+iOb+mOG+iJbPv3x0ksvve/uq+d6riTCfePGjbz44ovFbkZeuru72b59e7GbUTLUH9nUHzPUF9ny6Q8zezfoOQ3LiIhUIIW7iEgFmjfczeybZjZkZm/M8dzvmpmb2aqMbQ+Y2REz6zWzu8JusIiIzG8hR+7fBu6evdHMNgAfA45nbLsR2AnclPqaPzOz2lBaKiIiCzZvuLv7M8CZOZ76E+ALQObiNPcA+9x9zN2PAUeA28JoqIiILFxOY+5m9knghLu/OuupdcB7GY/7UttERGQJLXoqpJk1A78P/OJcT8+xbc5lJ81sN7AboKOjg+7u7sU2paSMjIyU/fcQJ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i1wIuUBHkLZU4Q4duS+Owl1EFq1QBTqCxLQMwaIp3EVk0QpVoCNILBrh7VMjKtyxCAp3EVm0QhX
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"x = np.arange(1, 11, 1)\n",
"y = function(x)\n",
"\n",
"plt.grid()\n",
"plt.plot(x, y)\n",
"plt.scatter(x[:len(x)//2], y[:len(x)//2])\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "3abb52c1",
"metadata": {},
"source": [
"4.3.3 Задание"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "b4763e0b-af25-4f52-b6f0-6f8461eeb686",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from numpy import trapz"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "0e8d1e51-9c2c-495d-bb97-0462401e6c36",
"metadata": {},
"outputs": [],
"source": [
"def funtion2(x):\n",
" return abs(np.cos(x * np.e ** (np.cos(x) + np.log(x + 1))))"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "55b31fe0",
"metadata": {},
"outputs": [],
"source": [
"x = np.arange(0, 11, 1)\n",
"y = funtion2(x)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "898021c3-9fd5-4328-bbe1-d23c3cc004dc",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAlbUlEQVR4nO3de3Sc9X3n8fd3ZBvbmGAbg0KwwSR1SAATShRIk5KIpCcL3Z7Q7Ul3w3Z7yWnLchq6za57muye02036dnNbmoKbUhYJ01zaRJCwNjGGDvGIC4LBnyRdZcsyzdpRv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qtWKic6h70uwxWqSlM07qs+9NuBdlXtUNUk8Dhw76xrFLhMcrvOrAEGAXslz0GBnx/pDHWLxOTsKtOl/otVuQraexNMlmBpfKn1jk4RnyxdFC4r4JprgPxdpjqBO2Zd801gDxAFLgP+naq+Y6tBEbkfuB+gsrKSmpqaIkqGlSTZtjWYv8dOZuB7rRX8+Y9f48sfWVnwzmuJRKLo/6+gCvI9j6WU55vGuXV9lrveU/ium5WrYNvW8moL9U4Ib/TBj5+t4X1r3dsr3At1fbmv5b+9Ps2mNbn3rV4xTCKhrry2Cwn0uRJndpr+K6AW+BTwPuCgiLyiqhcMXavqDmAHQFVVlVZXVy+2XgB+sms/2+uD/dO8ZTBL6qoP8pmb3l3Q9TU1NRT7/xVUQb7nn711jrTWc2wgwrGBwucebNuaZnt9Id+W4fHHN+RCb8W7f4nqj17ncTXOannpFNDCE6f/5Wt666a1fOm
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.grid()\n",
"plt.plot(x, y)\n",
"plt.fill_between(x, y)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "7a18f9fa-0283-4c42-a7f4-9724ea606def",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6.748183214657723\n"
]
}
],
"source": [
"area = trapz(y)\n",
"print(area)"
]
},
{
"cell_type": "markdown",
"id": "984e6926",
"metadata": {},
"source": [
"4.3.4 Задание"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "c5227063-0e66-4e3d-a867-65b7a939ad2f",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from numpy import trapz"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "06b78197-20da-49e8-a625-059bfa571add",
"metadata": {},
"outputs": [],
"source": [
"apple_share = [132, 135, 145, 147, 124, 139, 149, 151, 141, 149, 148, 177]\n",
"google_share = [1727, 1783, 2000, 2242, 2360, 2427, 2597, 2750, 2794, 2761, 2901, 2934]\n",
"microsoft_share = [217, 239, 236, 242, 251, 247, 271, 284, 301, 289, 329, 330] "
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "afdf47d8",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEICAYAAACzliQjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAzmElEQVR4nO3deXxU9b3/8ddnJpOVbIgGJGwCWsEFIaBVgaDearUC6rVqXWirYnu91VrtT+1itWjVW/W6VZRbqVjBXSsVsUVtBFpQQaEKUUG2IDskZA+zfH5/nJNkEiaQZZIhM5/n4zGec77ne858vxN5z5nvnHNGVBVjjDGJwRPrBhhjjOk6FvrGGJNALPSNMSaBWOgbY0wCsdA3xpgEYqFvjDEJxELfGNNARH4iIqkiMkxEzo11e0z0WeibqBORDSJSIyKVYY9fR/k5BoqIikhSNPdr6AOUAG8A5TFui+kEYhdnmWgTkQ3ANar6Tic+x0BgPeBT1UBnPY8x8caO9E2XEpFnRORJEVkgIhUi8r6IDAhb/4iIlIhIuYgsF5GxYetyReRtEdkO/Ldb/FsR2Skic0Uky61XKCKbw7b7rvup4Bp3+fsistid94jICyLyvIjs9+8h0icKEXlORO4MW/6G2589IvKFiHy3WX/vDlseIiItHmmJyG0i8pX72qwWkQvC1h2w3W47h4TVv1tEnglb3iAiZ7nzPURke/3+mm8vIv3dT2vPtdRW0z1Z6JtYuByYBvQCVgCzw9Z9BIwAegJzgJdFJNVdNw3YCwwEat2yrUB/IAjc2fyJRMTnbre1hbY8DmQDV6lqqK0dEZEMYIHb1iOAy4AnRGR4W/fl+goY67bpLuA5EekT7XYDPwf8B1g/Ddjdjv2aQ5yFvomFeaq6UFXrgF8C3xSRfgCq+pyq7l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E9j20xwHum9iQzOROPtP4el531vVu3D/27/rqK1VvKo7rPYUdm8Zvzhx+wzsyZM+nZsyc1NTWMHj2aiy66iKqqKkaOHMmDDz7Ib3/7W+66666GoZuqqir+9a9/sXDhQn74wx/y2WefNdnfjTfeyE033cTpp5/Opk2bOPvss7vNOf/GxJPS2lL+tuFvzFs3jxU7VwAw8oiRXH7y5QzOGdwQ5lkpWW0K8UNFtw/9WHn00Ud5/fXXASgpKWHNmjV4PB4uueQSAK644gouvPDChvqXXXYZAOPGjaO8vJyysrIm+3vnnXdYvXp1w3J5eXm3OgXUmO6s2l9NUUkR89bP419f/4uABhiSM4QbR97IuYPO5cgeR8a6iVHT7UP/YEfknaGoqIh33nmHJUuWkJ6eTmFhYcSrg8M/njX/qNZ8ORQKsWTJEtLS0jqn0caYJgKhAEu3LmXeunm8u+ldagI15KXnceXwKzlv0Hkc0/OYg++kG+r2oR8Le/fuJTc3l/T0dD7//HOWLnXuOhEKhXjllVe49NJLmTNnDqeffnrDNi+++CITJkxg8eLFZGdnk52d3WSf3/rWt3j88cf5+c9/DsCKFSsYMWJEl/XJmESgqny26zPmrZ/H/PXz2VO7h8zkTM4ddC7nHXUeo/JGdcshm7aw0G+Hc845hyeffJITTjiBY445hlNOOQWAjIwMVq1axahRo8jOzubFF19s2CY3N5dTTz214Yvc5h599FGuv/56TjjhBAKBAOPGjePJJ5/ssj4ZE882lm9k3rp5zFs3j00Vm0j2JDO+33jOG3QeY/PHkuxNjnUTu4yFfjukpKQwf37k68qmTZvGtGnT9iu/6KKLuPfee5uUff/73+f73/8+AL169WryJmGM6ZhdNbt4e/3bzFs3j892f4YgjO49mmuOv4YzB5xJVnJWrJsYExb6xpg22xfcx/bq7Wyv2s626m3OtGoblf5KclJyWjx1sYevR6feAqTKX8V7m97
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"x = np.arange(1, 13, 1)\n",
"\n",
"plt.grid()\n",
"plt.plot(x, apple_share, label=\"apple\")\n",
"plt.plot(x, microsoft_share, label=\"microsoft\")\n",
"plt.plot(x, google_share, label=\"google\")\n",
"plt.title(\"График цен акций\")\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "2b385688",
"metadata": {},
"source": [
"4.3.5 Задание"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "0e1778ed",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Чтобы выйти из программы введите exit\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Введите (+, -, *, /, **, e, sin, cos): exit\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Программа завершена\n"
]
}
],
"source": [
"import math as m\n",
"\n",
"print(\"Чтобы выйти из программы введите exit\")\n",
"\n",
"while True:\n",
" user_input = input(\"Введите (+, -, *, /, **, e, sin, cos): \")\n",
" if user_input == \"exit\":\n",
" break \n",
" elif user_input in ['+', '-', '*', '/', '**', 'e', 'sin', 'cos']:\n",
" x = float(input(\"x = \"))\n",
" y = float(input(\"y = \"))\n",
" \n",
" if user_input == 'e':\n",
" print(\"e ** (x + y) = \", m.e**(x + y))\n",
" elif user_input == 'sin':\n",
" print(\"sin(x + y) =\", m.sin(x + y))\n",
" elif user_input == 'cos':\n",
" print(\"cos(x + y) =\", m.cos(x + y))\n",
" else:\n",
" formula = f\"{x} {user_input} {y}\"\n",
" print(formula, \"=\", eval(formula))\n",
" else:\n",
" print(\"Неверный знак операции!\")\n",
"\n",
"print(\"Программа завершена\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5fda3145",
"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.7"
},
"vscode": {
"interpreter": {
"hash": "c8e7b8a5fb18722c706c80178f617ac0f7a16c4b5a7c63b4b737eecf7a54cfec"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}