├── laptop_prices.csv ├── TwitterScraperIssueResolved └── Using ChatGPT API Key.ipynb /laptop_prices.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexTheAnalyst/PythonCode/HEAD/laptop_prices.csv -------------------------------------------------------------------------------- /TwitterScraperIssueResolved: -------------------------------------------------------------------------------- 1 | Here is the GitHub link which helps walk you through how to solve the issue of returning 0 tweets: https://github.com/taspinar/twitterscraper/issues/296 2 | -------------------------------------------------------------------------------- /Using ChatGPT API Key.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "id": "a9fb228e", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import openai" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 4, 16 | "id": "42da5b36", 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "openai.api_key = \"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\"" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 5, 26 | "id": "0e598194", 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "def get_gpt_response(prompt, max_tokens=200):\n", 31 | " prompt = f\"Answer the following question: {prompt}\\nAnswer:\"\n", 32 | " response = openai.Completion.create(\n", 33 | " engine=\"davinci\",\n", 34 | " prompt=prompt,\n", 35 | " max_tokens=500,\n", 36 | " n=1,\n", 37 | " stop=\"\\n\", # Set a stop sequence here\n", 38 | " temperature=0.7,\n", 39 | " )\n", 40 | " return response.choices[0].text.strip()" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 37, 46 | "id": "7afbff87", 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "name": "stdout", 51 | "output_type": "stream", 52 | "text": [ 53 | "The key benefits of using renewable energy are that it is clean, green and sustainable. It does not pollute the environment or harm the ozone layer. Renewable energy is a cleaner alternative to fossil fuels and other non-renewable sources of energy. It also creates green jobs.\n" 54 | ] 55 | } 56 | ], 57 | "source": [ 58 | "prompt = \"What are the key benefits of using renewable energy?\"\n", 59 | "response = get_gpt_response(prompt)\n", 60 | "print(response)" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 7, 66 | "id": "4ed19c41", 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "name": "stdout", 71 | "output_type": "stream", 72 | "text": [ 73 | "Plotly has a great library for making nice visualizations. Visit Plotly  to learn more.\n" 74 | ] 75 | } 76 | ], 77 | "source": [ 78 | "prompt = \"What is a good Data Visualization Tools in Python?\"\n", 79 | "response = get_gpt_response(prompt)\n", 80 | "print(response)" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 2, 86 | "id": "ba1fc047", 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "ename": "SyntaxError", 91 | "evalue": "invalid syntax (2624315476.py, line 3)", 92 | "output_type": "error", 93 | "traceback": [ 94 | "\u001b[1;36m File \u001b[1;32m\"C:\\Users\\alexf\\AppData\\Local\\Temp\\ipykernel_83632\\2624315476.py\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m for num in my_list\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" 95 | ] 96 | } 97 | ], 98 | "source": [ 99 | "my_list = [1,2,3]\n", 100 | "\n", 101 | "for num in my_list\n", 102 | " num ** 2" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 9, 108 | "id": "a779ca2d", 109 | "metadata": {}, 110 | "outputs": [], 111 | "source": [ 112 | "my_list = [1,2,3]\n", 113 | "for num in my_list:\n", 114 | " num ** 2\n" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "id": "1d99d1fa", 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "my_list = [1,2,3]\n", 125 | "\n", 126 | "for num in my_list:\n", 127 | " num " 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": 10, 133 | "id": "eb141bc6", 134 | "metadata": {}, 135 | "outputs": [ 136 | { 137 | "name": "stdout", 138 | "output_type": "stream", 139 | "text": [ 140 | "1\n", 141 | "4\n", 142 | "9\n" 143 | ] 144 | } 145 | ], 146 | "source": [ 147 | "my_list = [1,2,3]\n", 148 | "\n", 149 | "square_list = [num**2 for num in my_list]\n", 150 | "\n", 151 | "for num in square_list:\n", 152 | " print(num)" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "id": "c9ec7118", 159 | "metadata": {}, 160 | "outputs": [], 161 | "source": [] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": null, 166 | "id": "ee67d29c", 167 | "metadata": {}, 168 | "outputs": [], 169 | "source": [] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": null, 174 | "id": "974356de", 175 | "metadata": {}, 176 | "outputs": [], 177 | "source": [] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "id": "a93ef74e", 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": null, 190 | "id": "b39d2451", 191 | "metadata": {}, 192 | "outputs": [], 193 | "source": [] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": null, 198 | "id": "153b051b", 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": null, 206 | "id": "fb22570b", 207 | "metadata": {}, 208 | "outputs": [], 209 | "source": [] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": null, 214 | "id": "7cc63179", 215 | "metadata": {}, 216 | "outputs": [], 217 | "source": [] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "id": "87fc7817", 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "id": "37cd0917", 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": null, 238 | "id": "e88bbfd4", 239 | "metadata": {}, 240 | "outputs": [], 241 | "source": [] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "execution_count": null, 246 | "id": "7a2ed332", 247 | "metadata": {}, 248 | "outputs": [], 249 | "source": [] 250 | } 251 | ], 252 | "metadata": { 253 | "kernelspec": { 254 | "display_name": "Python 3 (ipykernel)", 255 | "language": "python", 256 | "name": "python3" 257 | }, 258 | "language_info": { 259 | "codemirror_mode": { 260 | "name": "ipython", 261 | "version": 3 262 | }, 263 | "file_extension": ".py", 264 | "mimetype": "text/x-python", 265 | "name": "python", 266 | "nbconvert_exporter": "python", 267 | "pygments_lexer": "ipython3", 268 | "version": "3.9.13" 269 | } 270 | }, 271 | "nbformat": 4, 272 | "nbformat_minor": 5 273 | } 274 | --------------------------------------------------------------------------------