├── Data ├── fmi.jpg ├── fmi-logo-eng.png └── gene_expression.csv ├── 09_ID3_Classification_&_regression_trees_boosting.pdf ├── requirements.txt ├── README.md └── 00_python_into.ipynb /Data/fmi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aleksis99/Artificial-Intelligence/HEAD/Data/fmi.jpg -------------------------------------------------------------------------------- /Data/fmi-logo-eng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aleksis99/Artificial-Intelligence/HEAD/Data/fmi-logo-eng.png -------------------------------------------------------------------------------- /09_ID3_Classification_&_regression_trees_boosting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aleksis99/Artificial-Intelligence/HEAD/09_ID3_Classification_&_regression_trees_boosting.pdf -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | asttokens==2.4.1 2 | click==8.1.7 3 | colorama==0.4.6 4 | comm==0.2.2 5 | contourpy==1.3.0 6 | cycler==0.12.1 7 | debugpy==1.6.7 8 | decorator==5.1.1 9 | exceptiongroup==1.2.2 10 | executing==2.1.0 11 | fonttools==4.54.1 12 | importlib_metadata==8.5.0 13 | ipykernel==6.29.5 14 | ipython==8.28.0 15 | ipywidgets==8.1.5 16 | jedi==0.19.1 17 | joblib==1.4.2 18 | jupyter_client==8.6.3 19 | jupyter_core==5.7.2 20 | jupyterlab_widgets==3.0.13 21 | kiwisolver==1.4.7 22 | matplotlib==3.9.2 23 | matplotlib-inline==0.1.7 24 | nest_asyncio==1.6.0 25 | networkx==3.3 26 | nltk==3.9.1 27 | numpy==2.1.2 28 | packaging==24.1 29 | pandas==2.2.3 30 | parso==0.8.4 31 | pickleshare==0.7.5 32 | pillow==10.4.0 33 | pip==24.2 34 | platformdirs==4.3.6 35 | prompt_toolkit==3.0.48 36 | psutil==5.9.0 37 | pure_eval==0.2.3 38 | Pygments==2.18.0 39 | pyparsing==3.1.4 40 | python-dateutil==2.9.0 41 | pytz==2024.2 42 | pywin32==305.1 43 | pyzmq==25.1.2 44 | regex==2024.9.11 45 | scikit-learn==1.5.2 46 | scipy==1.14.1 47 | seaborn==0.13.2 48 | setuptools==75.1.0 49 | six==1.16.0 50 | stack-data==0.6.2 51 | threadpoolctl==3.5.0 52 | tornado==6.4.1 53 | tqdm==4.66.5 54 | traitlets==5.14.3 55 | typing_extensions==4.12.2 56 | tzdata==2024.2 57 | wcwidth==0.2.13 58 | wheel==0.44.0 59 | widgetsnbextension==4.0.13 60 | zipp==3.20.2 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Artificial Intelligence 2 | ## Repository with examples for the "Artificial Intelligence" course given by me @ Faculty of Mathematics and Informatics, Sofia University 3 | 4 | ## Exercises' Topics 5 | 6 | - Problem Solving and Search 7 | - Uninformed _(Blind)_ Search 8 | - Informed _(Heuristic)_ Search 9 | - Constraint Satisfaction Problems 10 | - Genetic Algorithms 11 | - Games 12 | - Machine Learning 13 | - _k_ - Nearest Neighbors 14 | - Naïve Bayes Classifier 15 | - Decision Tree 16 | - _k_ Means 17 | - Neural Networks 18 | 19 | ## Environment 20 | 21 | The course python version is 12. 22 | In the requirements.txt file you will find all the necessary libraries to run the notebooks. 23 | You can install them with pip. 24 | 25 | pip install requirements.txt 26 | 27 | [Conda](https://docs.conda.io/projects/conda/en/latest/index.html#) is recommended for managing you environment. 28 | 29 | 1. To create an environment: 30 | ``` 31 | conda create --name python=3.12 32 | ``` 33 | Replace ```` with the name of your environment. 34 | 35 | 2. When conda asks you to proceed, type ``y``: 36 | 37 | ``proceed ([y]/n)?`` 38 | 39 | This creates the myenv environment in ``/envs/``. No 40 | packages will be installed in this environment. 41 | 42 | 3. Then you need to activate your environment : 43 | ``` 44 | conda activate 45 | ``` 46 | 4. Then you can install the necessary libraries : 47 | ``` 48 | pip install -r requirements.txt 49 | ``` 50 | -------------------------------------------------------------------------------- /Data/gene_expression.csv: -------------------------------------------------------------------------------- 1 | Gene One,Gene Two,Cancer Present 2 | 4.3,3.9,1 3 | 2.5,6.3,0 4 | 5.7,3.9,1 5 | 6.1,6.2,0 6 | 7.4,3.4,1 7 | 3.4,7.5,0 8 | 3.1,6.8,0 9 | 6.3,4.9,1 10 | 5.5,8.6,0 11 | 7.7,3.5,1 12 | 6.6,2.9,1 13 | 6.6,4.5,0 14 | 5.4,7.2,0 15 | 5.2,5.7,1 16 | 8.3,5.4,1 17 | 4.2,9.3,0 18 | 3.0,7.7,0 19 | 4.9,6.8,0 20 | 8.5,5.6,1 21 | 7.2,4.2,1 22 | 6.6,3.7,0 23 | 6.3,7.7,0 24 | 3.3,7.5,0 25 | 5.4,2.9,1 26 | 3.4,5.3,0 27 | 9.3,6.4,1 28 | 7.8,3.5,1 29 | 2.4,5.6,0 30 | 6.4,6.4,0 31 | 2.5,5.0,0 32 | 3.6,6.9,0 33 | 4.6,5.4,1 34 | 3.3,6.5,0 35 | 9.7,4.8,1 36 | 5.0,5.3,0 37 | 5.7,7.2,0 38 | 6.8,3.2,1 39 | 5.9,7.2,0 40 | 5.0,5.3,0 41 | 2.5,4.8,0 42 | 6.2,6.5,0 43 | 6.7,6.1,0 44 | 6.1,7.7,0 45 | 4.6,7.3,0 46 | 5.4,5.1,1 47 | 4.8,6.5,1 48 | 7.8,2.3,1 49 | 7.2,3.9,0 50 | 8.3,4.1,1 51 | 5.0,4.6,1 52 | 3.5,7.8,0 53 | 6.1,2.5,1 54 | 6.9,6.0,0 55 | 6.5,2.5,1 56 | 6.2,6.8,0 57 | 9.3,6.6,1 58 | 2.7,6.2,0 59 | 3.9,7.7,0 60 | 8.4,3.4,1 61 | 3.7,8.6,0 62 | 5.0,8.4,0 63 | 3.9,8.8,0 64 | 4.1,7.1,0 65 | 6.2,5.1,0 66 | 7.1,4.7,0 67 | 2.6,6.3,0 68 | 3.3,6.2,0 69 | 1.8,5.0,0 70 | 4.1,4.0,1 71 | 6.3,7.7,0 72 | 4.7,4.7,1 73 | 8.9,6.6,1 74 | 8.6,3.8,1 75 | 5.2,4.1,1 76 | 5.4,5.5,0 77 | 5.0,8.8,0 78 | 7.6,3.2,1 79 | 9.1,6.1,1 80 | 6.7,3.4,1 81 | 6.7,2.3,1 82 | 4.7,3.8,1 83 | 4.5,4.1,1 84 | 4.2,8.6,0 85 | 4.8,2.4,1 86 | 5.7,3.4,1 87 | 6.1,5.6,0 88 | 7.2,3.8,1 89 | 4.0,4.3,0 90 | 7.3,2.9,1 91 | 8.4,6.2,1 92 | 6.4,7.2,0 93 | 2.8,5.1,0 94 | 6.7,3.8,1 95 | 2.9,7.0,0 96 | 5.0,3.6,1 97 | 5.6,7.4,0 98 | 8.4,4.7,1 99 | 6.3,2.1,1 100 | 6.4,6.9,0 101 | 4.4,5.1,1 102 | 6.5,3.7,1 103 | 7.5,6.1,0 104 | 4.6,6.1,0 105 | 4.3,5.5,1 106 | 2.7,7.8,0 107 | 4.1,8.2,0 108 | 5.6,3.3,1 109 | 5.2,6.5,0 110 | 8.2,4.2,0 111 | 3.7,6.8,1 112 | 9.0,6.2,1 113 | 6.3,6.7,0 114 | 8.6,6.3,1 115 | 6.8,2.4,1 116 | 6.3,7.6,0 117 | 6.2,3.1,1 118 | 5.9,5.4,0 119 | 5.8,5.7,0 120 | 3.2,6.7,0 121 | 5.4,4.5,1 122 | 9.4,7.0,1 123 | 2.4,6.6,0 124 | 4.7,9.1,0 125 | 4.8,4.2,1 126 | 2.6,6.6,0 127 | 6.5,3.5,1 128 | 5.7,4.0,1 129 | 3.9,6.9,0 130 | 4.0,8.5,0 131 | 4.1,6.1,0 132 | 7.7,4.6,1 133 | 2.2,5.7,0 134 | 4.8,4.8,1 135 | 4.4,4.3,1 136 | 4.3,8.5,0 137 | 6.0,6.8,0 138 | 5.6,5.3,0 139 | 4.6,4.0,1 140 | 3.4,6.8,0 141 | 7.1,4.0,1 142 | 7.5,2.5,1 143 | 2.4,6.5,0 144 | 7.3,3.4,1 145 | 9.1,4.6,1 146 | 7.6,3.7,1 147 | 4.5,8.5,0 148 | 5.9,2.3,1 149 | 7.4,1.8,1 150 | 5.3,4.6,1 151 | 6.6,6.9,0 152 | 4.7,2.9,1 153 | 9.0,6.5,1 154 | 4.1,7.5,0 155 | 5.8,5.0,1 156 | 6.3,6.6,0 157 | 5.1,4.1,1 158 | 7.0,5.9,0 159 | 8.8,4.7,1 160 | 4.6,5.9,1 161 | 8.7,4.5,1 162 | 4.4,5.1,1 163 | 5.2,3.6,1 164 | 5.9,6.5,0 165 | 5.7,7.2,0 166 | 4.6,3.9,1 167 | 2.8,4.9,0 168 | 7.7,4.7,0 169 | 6.8,3.9,1 170 | 6.7,3.9,1 171 | 5.6,6.8,0 172 | 8.4,5.6,1 173 | 7.2,5.4,1 174 | 4.2,7.3,1 175 | 4.7,8.2,0 176 | 9.0,5.1,1 177 | 3.2,6.3,0 178 | 6.8,2.6,1 179 | 4.8,5.9,1 180 | 5.1,7.5,0 181 | 4.9,4.4,1 182 | 6.0,7.7,0 183 | 7.7,4.3,1 184 | 4.5,4.7,1 185 | 8.7,5.4,1 186 | 6.9,5.2,0 187 | 6.9,5.0,0 188 | 7.2,5.4,0 189 | 6.0,2.8,1 190 | 2.3,4.8,0 191 | 4.9,5.8,1 192 | 4.5,7.2,0 193 | 2.9,6.8,0 194 | 4.5,3.0,1 195 | 6.3,6.6,0 196 | 3.8,6.3,0 197 | 8.9,5.3,1 198 | 6.3,8.3,0 199 | 7.9,4.1,1 200 | 4.8,7.8,0 201 | 5.5,6.8,0 202 | 2.6,6.0,0 203 | 5.7,3.9,1 204 | 6.5,6.4,0 205 | 7.9,4.2,1 206 | 5.8,5.0,1 207 | 3.7,5.8,0 208 | 6.6,4.7,1 209 | 5.9,3.6,1 210 | 5.7,8.6,0 211 | 5.9,2.3,1 212 | 6.0,3.5,1 213 | 5.3,5.2,1 214 | 2.7,6.4,0 215 | 6.2,4.5,1 216 | 4.5,7.4,0 217 | 6.8,5.3,0 218 | 5.8,4.8,0 219 | 5.8,6.6,0 220 | 5.5,3.7,1 221 | 6.7,2.9,1 222 | 2.7,6.1,0 223 | 3.9,5.9,1 224 | 5.6,6.5,0 225 | 8.6,7.0,1 226 | 2.7,5.7,0 227 | 4.5,7.6,0 228 | 6.1,5.7,0 229 | 6.5,4.8,1 230 | 3.7,7.1,0 231 | 5.8,5.3,0 232 | 3.0,4.9,0 233 | 4.8,3.7,1 234 | 8.2,4.3,1 235 | 7.0,5.4,0 236 | 5.5,7.5,0 237 | 3.4,7.5,0 238 | 5.5,7.9,0 239 | 4.3,4.1,1 240 | 8.5,3.4,1 241 | 4.3,8.5,0 242 | 7.8,3.8,1 243 | 4.7,6.1,0 244 | 5.5,3.7,1 245 | 5.9,4.0,1 246 | 6.1,4.9,0 247 | 6.2,6.9,0 248 | 3.0,7.1,0 249 | 4.2,8.8,0 250 | 3.7,7.8,0 251 | 7.0,3.4,1 252 | 3.9,5.5,0 253 | 3.3,5.7,0 254 | 6.7,6.2,0 255 | 3.5,6.3,0 256 | 8.1,3.2,1 257 | 8.8,6.5,1 258 | 4.5,3.0,1 259 | 8.1,4.4,1 260 | 6.4,3.1,1 261 | 6.1,4.0,1 262 | 4.9,6.2,1 263 | 4.8,5.9,1 264 | 6.1,5.1,0 265 | 3.7,5.8,0 266 | 5.3,7.3,0 267 | 5.6,2.3,1 268 | 7.7,4.4,1 269 | 7.8,5.1,1 270 | 8.5,5.8,1 271 | 5.4,7.2,0 272 | 5.7,3.4,1 273 | 3.8,5.4,0 274 | 7.9,3.7,1 275 | 5.4,7.0,0 276 | 2.8,7.4,0 277 | 3.7,6.8,0 278 | 9.2,5.0,1 279 | 2.6,8.2,0 280 | 4.1,8.6,0 281 | 6.1,4.9,0 282 | 4.4,5.2,1 283 | 4.0,6.8,0 284 | 5.1,7.3,0 285 | 3.5,6.3,0 286 | 3.6,6.0,0 287 | 5.7,2.7,1 288 | 5.5,4.6,0 289 | 8.7,5.8,1 290 | 6.0,6.2,0 291 | 5.9,8.1,0 292 | 7.8,4.5,1 293 | 8.2,4.7,1 294 | 2.5,5.2,0 295 | 4.9,4.7,1 296 | 5.7,4.6,1 297 | 8.5,1.8,1 298 | 4.3,6.2,0 299 | 6.9,4.1,1 300 | 7.6,3.8,1 301 | 6.2,7.9,0 302 | 5.9,9.4,0 303 | 3.2,8.1,0 304 | 5.4,6.1,0 305 | 4.5,4.4,1 306 | 8.5,4.1,1 307 | 5.4,8.4,0 308 | 1.8,5.8,0 309 | 4.6,6.8,1 310 | 4.5,5.4,1 311 | 6.2,6.7,0 312 | 5.8,6.2,0 313 | 2.0,5.0,0 314 | 5.3,7.6,0 315 | 7.1,2.9,1 316 | 3.9,6.4,1 317 | 5.9,2.9,1 318 | 6.1,6.5,0 319 | 8.7,5.9,1 320 | 5.4,4.9,1 321 | 4.8,5.1,1 322 | 3.2,7.6,0 323 | 4.9,7.5,0 324 | 6.2,3.2,1 325 | 5.0,3.6,1 326 | 4.0,5.4,1 327 | 4.3,5.3,1 328 | 6.6,8.0,0 329 | 6.5,4.2,1 330 | 9.0,4.3,1 331 | 6.9,2.2,1 332 | 4.5,7.2,0 333 | 2.9,8.3,0 334 | 5.3,3.2,1 335 | 3.9,7.6,0 336 | 3.7,5.4,0 337 | 9.5,4.8,1 338 | 7.4,5.1,1 339 | 3.7,4.7,0 340 | 6.2,4.2,1 341 | 2.7,4.8,0 342 | 8.1,3.4,1 343 | 6.5,6.7,0 344 | 3.6,6.2,0 345 | 8.7,4.4,1 346 | 5.7,6.6,0 347 | 3.4,4.8,0 348 | 8.6,4.1,1 349 | 5.4,7.8,0 350 | 3.2,6.3,1 351 | 6.9,7.4,0 352 | 2.9,7.6,0 353 | 8.1,3.8,1 354 | 6.5,5.1,0 355 | 5.6,3.9,1 356 | 7.6,4.1,1 357 | 7.0,7.8,0 358 | 7.6,3.5,1 359 | 4.1,8.4,0 360 | 7.7,5.9,1 361 | 2.4,6.6,0 362 | 7.7,5.1,1 363 | 6.9,4.3,1 364 | 5.5,3.5,1 365 | 5.3,7.4,0 366 | 5.2,7.5,0 367 | 4.9,8.1,0 368 | 6.7,4.2,1 369 | 2.8,5.2,0 370 | 5.2,1.9,1 371 | 6.1,4.3,1 372 | 6.0,6.0,0 373 | 4.9,5.6,0 374 | 5.3,3.8,1 375 | 4.9,4.3,1 376 | 7.4,5.1,0 377 | 5.4,4.8,1 378 | 3.6,6.1,0 379 | 5.5,4.5,1 380 | 7.0,4.3,0 381 | 4.4,6.0,1 382 | 5.3,8.1,0 383 | 5.6,4.2,1 384 | 3.5,7.0,0 385 | 4.8,7.5,0 386 | 6.4,4.8,0 387 | 7.4,3.4,1 388 | 4.6,3.0,1 389 | 3.8,7.5,0 390 | 5.0,6.2,0 391 | 3.8,6.1,0 392 | 6.7,1.2,1 393 | 5.7,4.3,1 394 | 3.1,7.5,0 395 | 4.2,6.9,1 396 | 4.9,3.6,1 397 | 5.4,5.2,1 398 | 5.9,9.0,0 399 | 5.3,7.2,0 400 | 3.3,7.1,0 401 | 8.2,5.4,1 402 | 4.7,7.0,0 403 | 8.8,6.2,1 404 | 5.4,5.3,1 405 | 8.4,4.8,1 406 | 8.8,3.6,1 407 | 4.3,5.0,1 408 | 7.7,6.5,0 409 | 8.1,5.6,1 410 | 4.3,8.3,0 411 | 6.4,3.4,1 412 | 4.8,5.1,1 413 | 6.7,7.1,0 414 | 5.1,6.0,1 415 | 5.9,7.4,0 416 | 5.4,7.6,0 417 | 3.0,5.9,0 418 | 3.1,6.2,0 419 | 6.4,6.6,0 420 | 4.5,5.9,1 421 | 5.7,6.5,0 422 | 6.9,8.4,0 423 | 5.9,4.1,1 424 | 2.5,5.8,0 425 | 4.2,6.2,0 426 | 3.9,7.7,0 427 | 4.2,7.9,0 428 | 4.5,7.7,0 429 | 6.2,4.8,0 430 | 5.0,7.4,0 431 | 6.0,8.4,0 432 | 7.1,4.5,1 433 | 5.8,6.8,0 434 | 8.9,5.5,1 435 | 3.5,6.2,0 436 | 2.7,7.1,0 437 | 2.5,6.6,0 438 | 1.9,7.5,0 439 | 6.0,5.8,1 440 | 7.5,2.2,1 441 | 4.2,6.8,0 442 | 7.3,4.6,0 443 | 4.3,3.2,1 444 | 6.0,2.6,1 445 | 1.9,6.2,0 446 | 6.9,3.4,1 447 | 6.9,7.0,0 448 | 5.3,2.1,1 449 | 8.2,6.7,1 450 | 6.0,5.1,0 451 | 8.2,3.7,1 452 | 8.9,6.5,1 453 | 3.6,8.4,0 454 | 8.1,5.6,1 455 | 1.6,3.5,0 456 | 2.5,5.1,0 457 | 7.3,7.7,0 458 | 3.8,7.3,0 459 | 6.5,4.6,0 460 | 5.8,8.0,0 461 | 6.9,4.7,0 462 | 2.9,5.8,0 463 | 5.9,7.2,0 464 | 6.9,5.4,0 465 | 6.3,5.5,0 466 | 2.6,4.6,0 467 | 4.5,3.4,1 468 | 5.3,8.0,0 469 | 3.8,8.7,0 470 | 6.3,5.2,0 471 | 7.3,4.6,1 472 | 4.5,7.9,0 473 | 6.3,3.7,1 474 | 7.1,2.4,1 475 | 5.8,5.3,0 476 | 8.0,4.9,1 477 | 7.4,4.7,1 478 | 7.4,2.4,1 479 | 7.7,4.2,1 480 | 2.6,6.2,0 481 | 4.1,7.8,0 482 | 7.0,3.6,1 483 | 7.4,7.0,0 484 | 4.7,5.4,1 485 | 7.8,1.9,1 486 | 7.0,4.9,1 487 | 7.3,1.0,1 488 | 6.0,4.1,1 489 | 7.3,3.8,1 490 | 7.0,5.2,0 491 | 8.4,5.8,1 492 | 4.3,7.7,0 493 | 5.0,3.7,1 494 | 9.0,6.2,1 495 | 8.0,5.8,1 496 | 5.3,3.4,1 497 | 4.4,7.6,0 498 | 5.6,7.1,0 499 | 5.5,1.4,1 500 | 6.1,7.3,0 501 | 8.6,4.7,1 502 | 4.9,5.4,1 503 | 5.4,8.4,0 504 | 3.8,7.2,0 505 | 8.6,4.3,1 506 | 6.2,6.1,0 507 | 5.4,3.7,1 508 | 6.6,3.7,1 509 | 3.9,8.5,0 510 | 8.3,4.1,1 511 | 3.3,8.7,0 512 | 8.0,3.8,1 513 | 6.4,5.5,0 514 | 5.7,6.7,0 515 | 6.3,4.7,1 516 | 4.1,7.0,0 517 | 7.2,3.3,1 518 | 4.1,7.7,0 519 | 5.7,6.0,0 520 | 2.4,6.2,0 521 | 4.6,4.5,1 522 | 6.2,5.7,0 523 | 4.0,7.5,0 524 | 5.1,3.7,1 525 | 3.9,8.5,0 526 | 3.1,6.7,0 527 | 4.7,5.6,1 528 | 8.4,6.0,1 529 | 7.2,3.7,1 530 | 4.7,4.1,1 531 | 8.7,3.7,1 532 | 5.2,2.5,1 533 | 3.1,7.7,0 534 | 2.7,6.1,0 535 | 8.1,6.1,1 536 | 5.9,5.3,0 537 | 7.5,1.6,1 538 | 2.6,4.0,0 539 | 8.4,4.4,1 540 | 3.7,5.0,0 541 | 3.8,6.8,0 542 | 6.1,3.3,1 543 | 4.7,4.9,1 544 | 5.7,8.1,0 545 | 7.2,3.1,1 546 | 5.0,7.7,0 547 | 3.3,5.9,0 548 | 6.3,6.6,0 549 | 7.3,3.3,1 550 | 7.3,3.2,1 551 | 3.5,7.6,0 552 | 5.1,5.0,1 553 | 7.6,3.0,1 554 | 6.3,8.8,0 555 | 3.6,6.1,1 556 | 6.1,6.6,0 557 | 8.2,2.7,1 558 | 4.3,8.2,0 559 | 6.5,4.7,0 560 | 7.3,7.3,0 561 | 5.6,8.6,0 562 | 8.3,5.3,1 563 | 5.6,2.6,1 564 | 5.9,2.1,1 565 | 3.8,6.9,0 566 | 6.0,7.4,0 567 | 5.7,4.5,1 568 | 5.3,5.9,1 569 | 5.8,7.8,0 570 | 2.7,6.6,0 571 | 7.2,4.7,1 572 | 5.4,8.3,0 573 | 6.7,4.3,0 574 | 8.9,4.4,1 575 | 3.7,6.3,0 576 | 6.7,2.3,1 577 | 6.3,6.6,0 578 | 5.2,8.3,0 579 | 4.0,6.8,0 580 | 4.0,6.8,0 581 | 6.6,6.3,0 582 | 5.6,6.7,0 583 | 6.4,5.6,0 584 | 7.7,5.0,1 585 | 9.1,5.4,1 586 | 5.8,4.4,0 587 | 4.4,6.8,1 588 | 7.8,3.4,1 589 | 3.8,5.0,1 590 | 4.3,6.9,0 591 | 5.2,3.7,1 592 | 9.3,5.6,1 593 | 8.3,4.6,1 594 | 8.6,5.1,1 595 | 1.5,5.3,0 596 | 2.5,6.0,0 597 | 7.6,4.9,0 598 | 4.9,3.7,1 599 | 5.9,7.3,0 600 | 4.5,4.2,1 601 | 3.1,5.4,0 602 | 5.2,7.7,0 603 | 4.8,8.3,0 604 | 6.1,5.7,0 605 | 5.2,4.1,1 606 | 3.1,6.3,0 607 | 5.0,5.6,1 608 | 3.8,8.4,0 609 | 4.5,4.0,1 610 | 8.4,6.2,1 611 | 6.3,3.5,1 612 | 8.8,5.2,1 613 | 6.4,6.6,0 614 | 7.6,3.3,1 615 | 3.2,6.2,0 616 | 2.8,6.1,0 617 | 9.1,5.9,1 618 | 4.4,6.0,1 619 | 2.4,6.4,0 620 | 6.6,6.1,0 621 | 6.8,4.2,0 622 | 9.2,7.4,1 623 | 5.1,6.1,0 624 | 4.8,4.8,1 625 | 5.9,4.6,1 626 | 8.8,2.4,1 627 | 7.3,2.5,1 628 | 4.7,7.5,0 629 | 2.0,6.4,0 630 | 4.8,5.5,1 631 | 6.0,8.5,0 632 | 5.0,8.0,0 633 | 8.4,4.7,1 634 | 8.3,5.2,1 635 | 6.9,1.9,1 636 | 7.8,4.6,1 637 | 5.5,7.0,0 638 | 7.9,5.0,1 639 | 5.6,7.8,0 640 | 8.2,4.6,1 641 | 3.3,7.1,0 642 | 4.8,3.8,1 643 | 2.3,5.8,0 644 | 4.7,6.3,1 645 | 7.8,3.6,1 646 | 4.5,7.8,0 647 | 3.1,8.0,0 648 | 8.3,5.8,1 649 | 7.0,5.6,0 650 | 4.5,8.1,0 651 | 5.3,3.4,1 652 | 3.8,6.3,1 653 | 6.0,5.6,0 654 | 9.2,4.8,1 655 | 8.1,3.9,1 656 | 7.7,5.1,1 657 | 7.4,3.3,1 658 | 3.4,7.0,0 659 | 7.7,3.1,1 660 | 3.6,7.8,0 661 | 8.8,7.4,1 662 | 3.4,7.9,0 663 | 7.9,3.7,1 664 | 6.7,3.1,1 665 | 5.8,6.0,0 666 | 5.5,7.4,0 667 | 6.6,2.2,1 668 | 7.1,3.8,1 669 | 5.4,6.1,0 670 | 5.1,3.4,1 671 | 4.5,2.5,1 672 | 7.0,3.7,1 673 | 4.4,5.9,1 674 | 4.3,9.0,0 675 | 6.6,3.0,1 676 | 3.7,8.0,0 677 | 7.6,3.7,1 678 | 2.9,6.9,0 679 | 4.3,8.3,0 680 | 5.3,4.2,1 681 | 2.2,4.7,0 682 | 7.2,3.4,1 683 | 6.2,2.9,1 684 | 9.3,4.1,1 685 | 3.8,6.4,0 686 | 4.2,6.4,0 687 | 5.5,2.7,1 688 | 2.7,4.0,0 689 | 5.0,3.7,1 690 | 5.6,4.3,1 691 | 3.2,6.8,0 692 | 7.9,2.8,1 693 | 7.4,3.4,1 694 | 3.0,5.2,0 695 | 4.5,6.2,1 696 | 8.1,4.7,1 697 | 8.1,4.2,1 698 | 6.6,3.6,1 699 | 6.8,2.6,1 700 | 4.2,6.1,1 701 | 2.7,6.0,0 702 | 5.9,6.5,0 703 | 5.6,5.1,1 704 | 6.4,5.2,0 705 | 6.4,2.9,1 706 | 6.2,4.5,0 707 | 6.5,2.9,1 708 | 6.6,5.3,0 709 | 5.7,5.6,0 710 | 7.0,5.2,0 711 | 8.1,4.2,1 712 | 5.4,5.0,1 713 | 3.0,7.4,0 714 | 4.3,7.2,0 715 | 3.2,6.2,0 716 | 8.2,3.5,1 717 | 2.1,4.0,0 718 | 6.9,3.0,1 719 | 3.8,8.3,0 720 | 4.7,7.2,0 721 | 2.4,5.7,0 722 | 2.5,6.0,0 723 | 5.0,4.0,1 724 | 7.4,3.5,1 725 | 5.8,6.3,0 726 | 2.9,7.4,0 727 | 2.7,2.7,0 728 | 7.1,5.1,0 729 | 6.4,3.9,1 730 | 6.2,1.5,1 731 | 5.7,8.6,0 732 | 9.7,5.2,1 733 | 5.1,3.7,1 734 | 6.0,5.8,0 735 | 8.7,5.0,1 736 | 2.4,7.1,0 737 | 8.1,2.8,1 738 | 6.9,4.4,0 739 | 6.5,7.0,0 740 | 3.6,9.2,0 741 | 8.3,4.4,1 742 | 4.9,7.7,0 743 | 3.2,4.6,0 744 | 5.7,6.8,0 745 | 2.0,5.4,0 746 | 8.7,4.6,1 747 | 6.6,4.9,0 748 | 4.4,4.3,1 749 | 8.6,4.9,1 750 | 5.0,5.0,1 751 | 7.3,5.7,0 752 | 9.2,6.4,1 753 | 7.3,6.6,0 754 | 3.0,7.9,0 755 | 4.8,6.9,1 756 | 5.0,6.1,0 757 | 8.6,4.9,1 758 | 5.0,7.6,0 759 | 4.9,7.9,0 760 | 6.3,4.0,1 761 | 3.3,8.0,0 762 | 2.4,5.0,0 763 | 8.5,6.3,1 764 | 5.3,6.6,0 765 | 5.7,3.2,1 766 | 8.2,1.9,1 767 | 5.0,7.5,0 768 | 6.6,4.0,1 769 | 8.4,3.8,1 770 | 7.3,3.8,1 771 | 6.9,3.8,1 772 | 5.1,4.7,1 773 | 4.1,6.7,0 774 | 5.5,3.1,1 775 | 2.5,5.2,0 776 | 6.3,6.9,0 777 | 4.1,6.1,0 778 | 3.1,5.3,0 779 | 8.5,5.3,1 780 | 4.6,8.7,0 781 | 6.5,7.6,0 782 | 6.4,5.6,0 783 | 5.3,3.9,1 784 | 6.8,2.9,1 785 | 5.6,8.2,0 786 | 2.9,4.8,0 787 | 3.9,8.2,0 788 | 8.2,2.8,1 789 | 7.0,4.0,1 790 | 6.5,2.4,1 791 | 5.1,5.8,1 792 | 5.3,3.4,1 793 | 3.6,7.3,0 794 | 5.8,7.7,0 795 | 4.8,6.4,0 796 | 3.4,5.6,0 797 | 4.4,4.6,1 798 | 8.2,4.1,1 799 | 3.1,6.1,0 800 | 9.5,6.3,1 801 | 7.6,4.3,1 802 | 5.5,7.7,0 803 | 6.6,3.4,1 804 | 4.1,4.2,1 805 | 7.0,6.4,0 806 | 3.0,3.9,0 807 | 7.6,2.7,1 808 | 4.6,4.2,1 809 | 5.6,6.7,0 810 | 3.2,7.9,0 811 | 7.2,7.1,0 812 | 4.0,6.9,0 813 | 4.8,2.3,1 814 | 5.7,3.5,1 815 | 2.3,4.2,0 816 | 3.2,5.4,0 817 | 8.2,5.0,1 818 | 5.8,3.3,1 819 | 7.4,5.7,0 820 | 7.2,3.2,1 821 | 4.1,7.3,0 822 | 6.5,1.6,1 823 | 5.8,8.8,0 824 | 8.5,5.6,1 825 | 6.5,6.9,0 826 | 7.5,4.2,1 827 | 5.0,6.6,1 828 | 6.1,1.5,1 829 | 1.8,4.9,0 830 | 3.4,5.7,0 831 | 3.2,7.6,0 832 | 8.1,4.7,1 833 | 2.8,8.1,0 834 | 4.8,6.4,0 835 | 3.3,8.2,0 836 | 5.0,7.3,0 837 | 5.1,7.9,0 838 | 6.8,3.9,0 839 | 7.2,1.8,1 840 | 7.7,3.4,1 841 | 9.4,4.9,1 842 | 7.1,2.1,1 843 | 8.3,5.3,1 844 | 7.5,3.8,1 845 | 4.7,2.0,1 846 | 3.7,7.6,0 847 | 5.0,7.6,0 848 | 7.5,3.5,1 849 | 3.2,6.8,0 850 | 5.5,4.0,1 851 | 3.5,8.2,0 852 | 5.3,5.0,1 853 | 4.2,6.3,1 854 | 5.3,4.3,1 855 | 5.6,3.8,1 856 | 2.5,4.2,0 857 | 6.8,8.5,0 858 | 2.3,4.6,0 859 | 3.2,7.2,1 860 | 7.2,1.7,1 861 | 7.5,3.6,1 862 | 8.7,5.0,1 863 | 4.9,7.9,0 864 | 4.3,7.4,0 865 | 4.2,6.5,0 866 | 5.8,7.0,0 867 | 8.4,2.5,1 868 | 4.2,7.8,0 869 | 6.2,3.5,1 870 | 8.0,6.1,1 871 | 8.4,4.0,1 872 | 6.0,6.0,0 873 | 5.4,6.8,0 874 | 6.4,6.2,0 875 | 8.3,4.4,1 876 | 4.8,8.4,0 877 | 5.6,7.4,0 878 | 2.5,6.1,0 879 | 7.1,3.6,1 880 | 2.5,4.7,0 881 | 5.3,7.3,0 882 | 9.0,4.3,1 883 | 4.8,4.1,1 884 | 2.3,6.7,0 885 | 5.2,6.4,1 886 | 4.7,7.7,0 887 | 8.4,4.1,1 888 | 4.8,7.4,1 889 | 8.1,5.6,1 890 | 4.8,6.4,0 891 | 5.9,3.0,1 892 | 3.5,8.2,0 893 | 7.8,4.1,1 894 | 3.6,6.0,0 895 | 5.5,6.3,0 896 | 4.5,5.4,1 897 | 7.1,3.3,1 898 | 3.6,8.6,0 899 | 5.3,4.7,1 900 | 6.5,4.6,0 901 | 6.5,4.2,0 902 | 5.5,7.4,0 903 | 5.6,7.1,0 904 | 8.2,4.1,1 905 | 7.0,4.8,0 906 | 5.0,3.8,1 907 | 3.2,7.0,0 908 | 4.2,6.8,0 909 | 3.0,8.3,0 910 | 6.4,4.5,0 911 | 4.0,8.4,0 912 | 6.7,3.2,1 913 | 7.3,4.7,1 914 | 7.2,3.4,1 915 | 2.3,7.3,0 916 | 4.7,6.7,0 917 | 2.5,5.3,0 918 | 5.8,4.1,1 919 | 9.0,2.8,1 920 | 2.2,5.1,0 921 | 6.4,5.1,0 922 | 9.1,6.5,1 923 | 6.7,7.3,0 924 | 7.7,6.2,1 925 | 6.1,6.9,0 926 | 5.7,2.4,1 927 | 2.9,3.2,0 928 | 3.3,7.2,0 929 | 4.7,5.7,1 930 | 3.1,7.8,0 931 | 6.3,2.4,1 932 | 5.9,6.6,0 933 | 2.4,3.8,0 934 | 5.9,3.3,1 935 | 4.7,4.6,1 936 | 7.2,3.2,1 937 | 5.3,5.6,1 938 | 5.0,3.6,1 939 | 3.6,6.6,0 940 | 5.0,4.0,1 941 | 2.5,5.7,0 942 | 9.1,3.2,1 943 | 5.8,7.5,0 944 | 2.5,5.4,0 945 | 4.3,6.4,0 946 | 6.8,6.2,0 947 | 2.8,5.4,0 948 | 5.0,8.4,0 949 | 8.3,5.9,1 950 | 6.1,4.7,1 951 | 2.5,6.0,0 952 | 4.6,6.7,1 953 | 5.1,5.1,1 954 | 6.3,7.0,0 955 | 8.6,4.4,1 956 | 2.7,6.2,0 957 | 5.5,7.3,0 958 | 4.2,5.2,1 959 | 7.8,3.5,1 960 | 5.2,7.2,0 961 | 8.3,5.7,1 962 | 4.1,7.9,0 963 | 2.6,5.0,0 964 | 5.1,7.2,0 965 | 9.0,5.4,1 966 | 9.0,5.1,1 967 | 3.1,7.0,0 968 | 6.9,4.7,1 969 | 4.1,8.2,0 970 | 3.9,6.7,0 971 | 3.1,7.4,0 972 | 9.1,3.9,1 973 | 5.0,3.3,1 974 | 4.7,8.1,0 975 | 3.1,7.0,0 976 | 9.1,5.8,1 977 | 7.5,2.3,1 978 | 6.9,3.3,1 979 | 6.9,3.2,1 980 | 5.6,3.2,1 981 | 4.3,6.7,0 982 | 4.1,7.6,0 983 | 7.9,2.4,1 984 | 6.3,3.2,1 985 | 3.3,9.4,0 986 | 7.0,2.8,1 987 | 7.1,3.7,1 988 | 5.8,3.8,1 989 | 4.3,8.6,0 990 | 4.1,8.3,0 991 | 5.2,5.5,1 992 | 8.8,6.9,1 993 | 7.0,5.0,0 994 | 5.4,5.0,1 995 | 7.0,3.5,1 996 | 6.6,2.3,1 997 | 4.6,7.0,0 998 | 6.0,6.8,0 999 | 2.5,7.3,0 1000 | 3.5,7.2,0 1001 | 3.0,6.5,0 1002 | 8.2,6.3,1 1003 | 5.2,7.5,0 1004 | 4.2,6.8,0 1005 | 6.7,7.0,0 1006 | 6.3,7.0,0 1007 | 7.0,3.1,1 1008 | 6.4,3.1,1 1009 | 4.1,8.5,0 1010 | 6.2,3.5,1 1011 | 6.4,6.6,0 1012 | 3.1,4.6,0 1013 | 7.3,1.8,1 1014 | 6.0,7.1,0 1015 | 2.2,6.4,0 1016 | 7.5,3.6,1 1017 | 4.4,4.2,1 1018 | 5.1,7.6,0 1019 | 5.1,5.6,1 1020 | 7.0,6.1,0 1021 | 5.3,4.6,1 1022 | 3.4,6.9,0 1023 | 2.7,5.2,0 1024 | 5.3,6.2,0 1025 | 6.5,3.3,1 1026 | 7.9,3.1,1 1027 | 5.8,5.1,0 1028 | 3.6,7.5,0 1029 | 3.7,9.4,0 1030 | 4.0,8.9,0 1031 | 3.5,6.3,0 1032 | 7.0,2.1,1 1033 | 7.6,4.1,1 1034 | 3.5,4.7,0 1035 | 6.1,5.7,0 1036 | 4.8,4.5,1 1037 | 4.2,5.2,1 1038 | 5.6,7.9,0 1039 | 5.9,2.9,1 1040 | 4.5,7.6,0 1041 | 9.3,4.1,1 1042 | 5.8,1.2,1 1043 | 6.3,4.2,1 1044 | 7.0,4.9,1 1045 | 5.1,7.9,0 1046 | 7.8,4.1,1 1047 | 4.5,7.8,0 1048 | 4.9,5.4,1 1049 | 6.9,5.4,0 1050 | 4.1,4.7,1 1051 | 3.1,6.3,0 1052 | 8.2,5.2,1 1053 | 5.4,4.2,1 1054 | 5.6,4.9,1 1055 | 2.1,5.6,0 1056 | 5.5,1.2,1 1057 | 7.0,1.2,1 1058 | 2.0,5.2,0 1059 | 5.4,3.2,1 1060 | 6.6,6.9,0 1061 | 6.3,4.1,1 1062 | 5.2,3.4,1 1063 | 3.8,6.0,1 1064 | 5.9,7.5,0 1065 | 4.0,6.9,0 1066 | 2.4,5.9,0 1067 | 5.7,6.1,1 1068 | 4.3,5.4,1 1069 | 7.2,3.7,1 1070 | 8.1,6.3,1 1071 | 3.9,6.0,1 1072 | 6.6,5.0,0 1073 | 6.7,4.7,1 1074 | 4.9,7.4,0 1075 | 2.7,7.3,0 1076 | 7.5,5.3,0 1077 | 5.5,2.9,1 1078 | 2.9,7.1,0 1079 | 4.0,8.2,0 1080 | 7.2,2.0,1 1081 | 6.8,5.8,0 1082 | 6.3,7.2,0 1083 | 4.2,5.0,1 1084 | 2.8,6.9,0 1085 | 5.7,8.3,0 1086 | 6.3,5.9,0 1087 | 5.7,5.2,1 1088 | 9.5,4.7,1 1089 | 7.8,3.7,1 1090 | 2.6,8.1,0 1091 | 2.7,5.7,0 1092 | 6.3,5.6,0 1093 | 6.5,6.1,0 1094 | 5.1,4.3,1 1095 | 4.9,8.1,0 1096 | 6.6,4.1,1 1097 | 6.6,4.7,1 1098 | 2.5,6.1,0 1099 | 8.2,4.1,1 1100 | 5.4,2.0,1 1101 | 3.6,6.6,0 1102 | 7.5,5.3,0 1103 | 5.5,4.3,1 1104 | 7.0,2.9,1 1105 | 5.9,9.2,0 1106 | 8.7,5.8,1 1107 | 6.5,2.6,1 1108 | 9.5,5.8,1 1109 | 8.9,5.5,1 1110 | 2.9,6.0,0 1111 | 4.0,6.2,1 1112 | 6.3,3.7,1 1113 | 6.0,6.7,0 1114 | 4.9,3.5,1 1115 | 3.5,5.6,0 1116 | 7.7,3.9,1 1117 | 5.4,7.7,0 1118 | 4.6,3.3,1 1119 | 8.1,5.7,1 1120 | 8.1,3.3,1 1121 | 2.9,5.6,0 1122 | 4.6,4.3,1 1123 | 4.5,7.0,0 1124 | 8.8,5.2,1 1125 | 5.8,6.5,0 1126 | 5.3,7.1,0 1127 | 3.2,6.4,0 1128 | 6.0,6.4,0 1129 | 6.2,1.9,1 1130 | 5.9,6.1,0 1131 | 5.0,6.6,1 1132 | 5.4,3.7,1 1133 | 6.7,3.1,0 1134 | 7.5,3.7,1 1135 | 3.8,7.8,0 1136 | 4.1,3.9,1 1137 | 5.2,5.1,1 1138 | 2.4,6.0,0 1139 | 6.5,5.7,0 1140 | 5.5,7.0,0 1141 | 6.9,4.3,1 1142 | 2.4,4.9,0 1143 | 1.8,2.9,0 1144 | 8.2,4.3,1 1145 | 4.2,7.2,0 1146 | 4.0,7.3,0 1147 | 4.4,6.5,1 1148 | 6.0,7.1,0 1149 | 2.4,6.6,0 1150 | 5.1,2.2,1 1151 | 5.1,5.8,1 1152 | 4.9,3.7,1 1153 | 6.4,3.5,1 1154 | 5.2,6.7,0 1155 | 7.2,4.0,0 1156 | 4.7,5.1,1 1157 | 4.2,8.5,0 1158 | 3.0,7.7,0 1159 | 6.2,3.5,1 1160 | 4.9,8.2,0 1161 | 4.7,7.0,0 1162 | 6.0,5.6,0 1163 | 3.1,5.5,0 1164 | 5.0,3.0,1 1165 | 3.3,7.5,0 1166 | 2.8,5.5,0 1167 | 6.9,4.4,1 1168 | 7.4,3.8,1 1169 | 7.0,3.9,1 1170 | 5.4,3.8,1 1171 | 4.5,7.7,0 1172 | 8.1,6.2,1 1173 | 7.0,5.2,0 1174 | 3.8,5.8,0 1175 | 5.8,2.4,1 1176 | 4.1,8.0,0 1177 | 2.0,5.2,0 1178 | 4.8,5.6,1 1179 | 8.5,5.2,1 1180 | 6.4,3.5,0 1181 | 8.4,5.6,1 1182 | 6.4,5.9,0 1183 | 3.8,8.4,0 1184 | 2.6,7.7,0 1185 | 8.8,5.3,1 1186 | 8.5,4.7,1 1187 | 6.5,7.1,0 1188 | 8.6,5.1,1 1189 | 3.9,8.2,0 1190 | 4.2,7.7,0 1191 | 8.3,5.1,1 1192 | 5.3,2.8,1 1193 | 5.7,5.2,0 1194 | 5.7,6.4,0 1195 | 5.9,4.0,1 1196 | 2.7,6.2,0 1197 | 5.6,7.2,0 1198 | 6.1,8.4,0 1199 | 4.6,7.3,0 1200 | 6.4,6.3,0 1201 | 6.5,2.3,1 1202 | 5.3,6.8,0 1203 | 8.6,5.8,1 1204 | 3.4,5.8,0 1205 | 3.8,7.3,0 1206 | 4.4,4.4,1 1207 | 7.2,4.3,1 1208 | 2.2,6.1,0 1209 | 8.2,3.5,1 1210 | 2.6,7.0,0 1211 | 7.5,4.9,0 1212 | 4.4,7.6,0 1213 | 4.2,6.3,0 1214 | 8.3,4.6,1 1215 | 5.1,7.2,0 1216 | 7.1,3.6,1 1217 | 5.6,7.7,0 1218 | 8.6,3.1,1 1219 | 6.9,3.8,1 1220 | 7.9,5.4,1 1221 | 3.8,6.4,0 1222 | 5.3,4.8,1 1223 | 4.6,5.3,1 1224 | 5.8,6.7,0 1225 | 5.2,2.9,1 1226 | 7.0,2.3,1 1227 | 4.1,5.4,1 1228 | 8.6,5.4,1 1229 | 5.3,7.5,0 1230 | 6.2,5.0,0 1231 | 3.2,7.5,0 1232 | 8.7,3.3,1 1233 | 6.7,4.0,0 1234 | 3.3,5.0,0 1235 | 6.6,6.5,0 1236 | 5.8,8.2,0 1237 | 6.0,3.6,1 1238 | 6.5,4.0,0 1239 | 5.8,3.3,1 1240 | 6.8,6.2,0 1241 | 7.2,5.7,0 1242 | 6.6,1.5,1 1243 | 8.2,6.3,1 1244 | 3.9,6.3,0 1245 | 7.9,5.4,1 1246 | 8.6,3.4,1 1247 | 5.0,5.3,1 1248 | 6.9,6.8,0 1249 | 2.9,5.3,0 1250 | 5.6,6.4,1 1251 | 7.2,4.0,1 1252 | 8.7,4.6,1 1253 | 8.4,5.6,1 1254 | 4.3,5.3,1 1255 | 8.2,5.8,1 1256 | 5.1,8.0,0 1257 | 2.5,4.9,0 1258 | 7.0,3.1,1 1259 | 5.9,6.8,0 1260 | 2.9,4.7,0 1261 | 3.7,7.3,0 1262 | 4.6,4.2,1 1263 | 3.2,5.5,0 1264 | 7.3,2.8,1 1265 | 6.9,6.2,0 1266 | 5.5,2.2,1 1267 | 6.3,3.6,1 1268 | 3.9,7.5,0 1269 | 7.8,2.2,1 1270 | 7.1,3.6,1 1271 | 7.3,4.8,1 1272 | 9.2,4.3,1 1273 | 8.0,5.1,1 1274 | 6.0,5.7,0 1275 | 6.4,4.7,0 1276 | 5.2,3.9,1 1277 | 3.3,8.2,0 1278 | 6.0,8.1,0 1279 | 5.9,8.0,0 1280 | 5.7,4.1,1 1281 | 5.4,3.5,1 1282 | 5.8,7.3,0 1283 | 5.3,2.2,1 1284 | 7.0,3.5,1 1285 | 7.8,5.5,1 1286 | 8.5,4.9,1 1287 | 6.1,3.0,1 1288 | 3.1,5.8,0 1289 | 5.0,4.3,1 1290 | 6.9,5.3,0 1291 | 4.1,7.8,0 1292 | 6.9,1.8,1 1293 | 6.1,6.6,0 1294 | 1.9,4.8,0 1295 | 3.5,7.5,0 1296 | 5.5,7.2,0 1297 | 5.1,3.7,1 1298 | 7.9,3.8,1 1299 | 8.2,5.3,1 1300 | 6.6,8.8,0 1301 | 5.3,5.1,0 1302 | 4.3,5.7,0 1303 | 6.2,7.7,0 1304 | 5.6,6.4,0 1305 | 8.4,7.2,1 1306 | 5.8,6.7,0 1307 | 3.5,6.9,0 1308 | 6.6,5.3,0 1309 | 5.6,6.8,0 1310 | 3.7,5.8,1 1311 | 8.0,5.5,1 1312 | 4.9,6.6,0 1313 | 6.0,3.2,1 1314 | 2.5,8.1,0 1315 | 3.0,6.1,0 1316 | 5.9,3.8,1 1317 | 2.3,6.2,0 1318 | 6.5,3.9,1 1319 | 6.1,4.4,0 1320 | 7.0,3.0,1 1321 | 6.3,5.1,1 1322 | 7.7,5.0,0 1323 | 2.8,5.2,0 1324 | 4.1,5.7,1 1325 | 5.8,4.7,1 1326 | 9.0,3.9,1 1327 | 5.2,2.5,1 1328 | 4.3,7.1,0 1329 | 8.4,5.2,1 1330 | 5.4,7.8,0 1331 | 3.1,6.0,0 1332 | 7.3,5.5,0 1333 | 7.6,3.9,1 1334 | 3.8,6.5,0 1335 | 8.8,5.7,1 1336 | 4.6,6.4,1 1337 | 6.7,3.6,1 1338 | 8.7,5.1,1 1339 | 7.1,3.9,1 1340 | 6.7,3.4,1 1341 | 2.5,5.7,0 1342 | 7.8,2.9,1 1343 | 5.6,7.6,0 1344 | 8.2,3.9,1 1345 | 7.0,5.9,0 1346 | 8.4,5.5,1 1347 | 4.0,6.2,0 1348 | 4.1,7.0,0 1349 | 5.2,5.7,1 1350 | 7.4,4.6,1 1351 | 7.7,4.5,1 1352 | 5.9,7.3,0 1353 | 4.7,7.0,0 1354 | 4.2,4.2,1 1355 | 8.3,4.7,1 1356 | 4.8,9.1,0 1357 | 6.1,4.8,1 1358 | 6.1,8.4,0 1359 | 8.8,4.8,1 1360 | 3.1,6.2,0 1361 | 6.0,5.5,0 1362 | 6.4,6.4,0 1363 | 5.7,2.6,1 1364 | 6.4,2.9,1 1365 | 8.6,6.4,1 1366 | 4.9,5.5,1 1367 | 4.5,8.5,0 1368 | 5.3,4.6,1 1369 | 4.4,6.7,0 1370 | 5.7,3.3,1 1371 | 4.3,5.3,1 1372 | 5.4,6.0,0 1373 | 5.3,3.3,1 1374 | 6.7,2.6,1 1375 | 2.9,5.6,0 1376 | 6.0,8.1,0 1377 | 4.2,7.5,0 1378 | 7.7,3.8,1 1379 | 6.6,6.9,0 1380 | 3.9,6.4,0 1381 | 5.5,3.0,1 1382 | 5.6,3.3,1 1383 | 5.4,3.8,1 1384 | 4.4,8.2,0 1385 | 3.6,8.3,0 1386 | 7.6,4.6,1 1387 | 8.5,6.0,1 1388 | 4.6,8.0,0 1389 | 7.9,3.5,1 1390 | 8.7,5.1,1 1391 | 2.2,5.5,0 1392 | 8.3,6.3,1 1393 | 5.2,9.8,0 1394 | 7.5,3.8,1 1395 | 3.4,5.9,0 1396 | 6.2,7.5,0 1397 | 2.1,5.2,0 1398 | 6.2,2.7,1 1399 | 4.5,4.7,1 1400 | 6.3,2.5,1 1401 | 8.7,2.9,1 1402 | 8.3,3.8,1 1403 | 4.2,4.4,1 1404 | 8.2,4.0,1 1405 | 2.3,6.7,0 1406 | 5.8,5.8,0 1407 | 5.4,7.8,0 1408 | 2.4,3.7,0 1409 | 2.1,5.2,0 1410 | 7.4,3.0,1 1411 | 2.3,6.9,0 1412 | 6.4,3.5,1 1413 | 5.2,6.2,0 1414 | 5.8,8.2,0 1415 | 3.2,5.7,0 1416 | 5.1,4.2,1 1417 | 7.7,3.0,1 1418 | 2.5,4.5,0 1419 | 6.0,6.1,0 1420 | 5.1,4.0,1 1421 | 4.8,4.1,1 1422 | 6.0,8.4,0 1423 | 8.5,3.6,1 1424 | 5.4,2.7,1 1425 | 8.6,5.5,1 1426 | 2.9,3.4,0 1427 | 5.7,7.7,0 1428 | 6.4,4.0,1 1429 | 2.2,5.3,0 1430 | 8.1,2.7,1 1431 | 5.4,7.0,0 1432 | 6.1,8.0,0 1433 | 6.7,4.4,0 1434 | 8.3,4.0,1 1435 | 7.2,2.3,1 1436 | 2.5,7.3,0 1437 | 6.5,3.1,1 1438 | 2.1,6.6,0 1439 | 3.7,4.4,1 1440 | 2.8,3.9,0 1441 | 5.6,3.1,1 1442 | 1.9,5.8,0 1443 | 4.9,8.1,0 1444 | 8.2,1.4,1 1445 | 6.4,6.1,0 1446 | 4.4,5.6,1 1447 | 6.8,3.6,1 1448 | 7.4,3.4,1 1449 | 6.0,2.3,1 1450 | 2.7,6.7,0 1451 | 5.9,5.5,1 1452 | 4.3,5.9,1 1453 | 8.4,5.2,1 1454 | 8.6,5.4,1 1455 | 1.2,5.9,0 1456 | 7.4,2.9,1 1457 | 6.2,8.3,0 1458 | 4.2,7.1,0 1459 | 2.4,4.1,0 1460 | 2.9,6.5,0 1461 | 5.1,4.7,1 1462 | 5.9,4.7,0 1463 | 3.5,7.3,0 1464 | 9.0,4.6,1 1465 | 3.5,6.6,0 1466 | 5.7,3.2,1 1467 | 5.2,4.9,1 1468 | 2.8,5.1,0 1469 | 2.8,5.2,0 1470 | 6.6,4.6,0 1471 | 7.9,2.4,1 1472 | 6.7,6.5,0 1473 | 2.5,6.0,0 1474 | 4.8,7.3,0 1475 | 4.1,4.9,1 1476 | 8.4,4.3,1 1477 | 5.9,4.5,1 1478 | 5.5,7.9,0 1479 | 7.6,4.3,1 1480 | 5.3,2.9,1 1481 | 3.4,6.8,0 1482 | 2.0,4.9,0 1483 | 5.0,8.0,0 1484 | 6.4,6.6,0 1485 | 4.8,4.2,1 1486 | 4.2,7.5,0 1487 | 4.8,2.9,1 1488 | 4.5,8.0,0 1489 | 5.6,5.6,0 1490 | 4.7,5.4,1 1491 | 5.6,3.6,1 1492 | 8.8,6.5,1 1493 | 6.9,5.8,0 1494 | 4.3,7.3,0 1495 | 5.8,2.3,1 1496 | 8.7,6.5,1 1497 | 3.2,7.5,0 1498 | 7.2,3.6,1 1499 | 7.3,3.6,1 1500 | 5.3,3.6,1 1501 | 3.6,7.2,0 1502 | 6.9,4.3,0 1503 | 6.4,7.1,0 1504 | 6.1,7.8,0 1505 | 4.1,6.9,0 1506 | 5.6,3.7,1 1507 | 8.6,5.2,1 1508 | 7.5,3.3,1 1509 | 4.7,6.5,1 1510 | 8.5,5.8,1 1511 | 7.3,2.5,1 1512 | 2.4,6.3,0 1513 | 2.5,6.0,0 1514 | 7.3,2.0,1 1515 | 4.7,4.0,1 1516 | 4.6,8.6,0 1517 | 7.4,4.6,1 1518 | 5.2,2.6,1 1519 | 8.9,4.6,1 1520 | 3.8,6.6,0 1521 | 6.4,2.9,1 1522 | 5.7,7.0,1 1523 | 2.7,5.9,0 1524 | 6.4,5.0,1 1525 | 5.2,4.3,1 1526 | 4.6,5.0,1 1527 | 5.4,3.7,1 1528 | 6.6,3.0,1 1529 | 7.8,3.6,1 1530 | 4.5,4.8,1 1531 | 7.0,2.1,1 1532 | 2.4,5.9,0 1533 | 3.7,6.4,0 1534 | 9.1,4.8,1 1535 | 4.8,4.7,1 1536 | 5.9,5.7,0 1537 | 5.8,6.8,0 1538 | 3.2,9.3,0 1539 | 5.1,8.5,0 1540 | 6.1,6.7,0 1541 | 5.6,6.2,0 1542 | 6.0,4.8,0 1543 | 5.4,6.7,0 1544 | 6.8,3.6,1 1545 | 3.0,6.6,0 1546 | 1.0,4.6,0 1547 | 5.9,4.7,0 1548 | 5.2,6.9,0 1549 | 8.2,4.2,1 1550 | 6.9,7.2,0 1551 | 7.9,2.9,1 1552 | 8.1,6.2,1 1553 | 3.7,7.7,0 1554 | 6.8,5.1,0 1555 | 6.7,7.6,0 1556 | 4.6,5.2,1 1557 | 2.7,4.5,0 1558 | 6.6,5.5,0 1559 | 5.1,7.1,0 1560 | 9.7,6.0,1 1561 | 6.7,5.5,0 1562 | 8.9,5.0,1 1563 | 5.0,7.1,0 1564 | 9.4,5.5,1 1565 | 8.4,3.7,1 1566 | 6.4,2.0,1 1567 | 6.5,3.9,1 1568 | 8.5,6.2,1 1569 | 8.1,5.9,1 1570 | 7.9,5.6,1 1571 | 6.1,2.8,1 1572 | 6.4,6.9,0 1573 | 6.3,6.4,0 1574 | 5.4,8.1,0 1575 | 3.5,6.0,0 1576 | 5.0,8.0,0 1577 | 5.7,7.1,0 1578 | 5.6,2.2,1 1579 | 3.8,7.6,0 1580 | 2.8,7.8,0 1581 | 3.2,4.6,0 1582 | 8.4,5.5,1 1583 | 6.5,4.2,0 1584 | 3.5,5.0,1 1585 | 4.7,7.6,0 1586 | 2.7,5.1,0 1587 | 7.9,3.2,1 1588 | 2.7,6.3,0 1589 | 4.6,4.5,1 1590 | 5.0,5.2,1 1591 | 6.4,3.6,1 1592 | 4.4,5.5,1 1593 | 7.8,3.4,1 1594 | 5.6,5.8,0 1595 | 8.3,4.0,1 1596 | 6.4,6.6,0 1597 | 2.9,7.4,0 1598 | 6.0,3.4,1 1599 | 3.3,6.3,0 1600 | 5.0,4.8,1 1601 | 4.4,6.6,1 1602 | 3.4,7.9,0 1603 | 7.0,6.1,0 1604 | 5.8,7.8,0 1605 | 4.3,5.5,1 1606 | 2.5,4.9,0 1607 | 2.5,6.6,0 1608 | 7.7,2.5,1 1609 | 8.8,3.5,1 1610 | 4.7,8.7,0 1611 | 4.6,6.0,1 1612 | 2.7,3.9,0 1613 | 5.8,6.9,0 1614 | 4.2,6.0,0 1615 | 4.7,7.4,0 1616 | 5.5,5.8,0 1617 | 5.5,2.7,1 1618 | 6.6,2.9,1 1619 | 5.8,8.4,0 1620 | 5.0,3.6,1 1621 | 3.9,6.1,0 1622 | 3.6,8.6,0 1623 | 5.1,5.4,1 1624 | 4.1,7.2,0 1625 | 6.0,2.9,1 1626 | 6.4,4.7,0 1627 | 8.6,4.9,1 1628 | 4.7,7.9,0 1629 | 6.7,7.7,0 1630 | 6.2,7.3,0 1631 | 6.7,3.9,1 1632 | 2.6,7.6,0 1633 | 4.7,5.8,1 1634 | 8.6,4.3,1 1635 | 4.6,8.1,0 1636 | 3.7,6.9,0 1637 | 8.3,5.1,1 1638 | 4.4,4.6,1 1639 | 8.2,4.8,1 1640 | 4.2,5.8,1 1641 | 8.5,5.2,1 1642 | 4.8,4.6,1 1643 | 8.5,6.2,1 1644 | 3.5,8.2,0 1645 | 6.3,8.3,0 1646 | 4.8,6.2,1 1647 | 3.0,6.3,0 1648 | 5.8,3.2,1 1649 | 9.6,5.2,1 1650 | 7.4,4.2,1 1651 | 4.5,5.2,1 1652 | 3.8,7.1,0 1653 | 6.0,3.4,1 1654 | 7.0,5.0,0 1655 | 6.6,7.0,0 1656 | 4.7,5.7,1 1657 | 5.1,3.8,1 1658 | 6.8,2.9,1 1659 | 8.1,5.5,1 1660 | 4.3,5.1,1 1661 | 6.4,2.5,1 1662 | 4.9,5.3,1 1663 | 8.1,4.1,1 1664 | 4.6,7.4,0 1665 | 3.1,6.4,0 1666 | 5.2,3.6,1 1667 | 5.9,7.5,0 1668 | 6.6,4.2,1 1669 | 4.4,7.0,0 1670 | 6.5,4.0,0 1671 | 4.7,5.6,1 1672 | 5.6,4.3,1 1673 | 7.0,6.5,0 1674 | 7.0,4.3,0 1675 | 4.9,3.8,1 1676 | 3.7,5.6,1 1677 | 8.4,6.2,1 1678 | 7.7,3.0,1 1679 | 5.9,3.1,1 1680 | 5.3,3.7,1 1681 | 6.7,3.3,1 1682 | 5.3,4.4,1 1683 | 6.2,3.6,1 1684 | 7.7,2.9,1 1685 | 8.9,4.2,1 1686 | 5.7,4.8,1 1687 | 7.1,6.6,0 1688 | 5.1,8.8,0 1689 | 6.0,3.7,0 1690 | 5.4,2.3,1 1691 | 6.5,3.3,1 1692 | 7.7,3.6,1 1693 | 8.1,6.0,1 1694 | 5.1,5.6,0 1695 | 6.4,3.8,1 1696 | 4.6,5.1,1 1697 | 6.1,3.5,1 1698 | 4.6,5.9,1 1699 | 8.9,4.6,1 1700 | 2.1,3.6,0 1701 | 3.7,7.2,0 1702 | 7.5,2.2,1 1703 | 7.7,4.3,1 1704 | 6.2,3.2,1 1705 | 6.8,3.3,1 1706 | 7.2,3.8,1 1707 | 5.8,6.4,0 1708 | 4.3,8.2,0 1709 | 5.3,3.0,1 1710 | 6.3,3.9,1 1711 | 5.5,3.4,1 1712 | 6.7,5.3,0 1713 | 1.7,6.2,0 1714 | 7.4,3.2,1 1715 | 5.1,8.7,0 1716 | 4.7,7.1,0 1717 | 8.0,5.6,1 1718 | 4.3,3.7,1 1719 | 7.9,2.1,1 1720 | 4.7,6.7,1 1721 | 5.0,4.6,1 1722 | 5.1,3.9,1 1723 | 6.5,5.6,0 1724 | 7.2,4.6,1 1725 | 6.0,4.6,1 1726 | 4.6,3.7,1 1727 | 2.8,5.8,0 1728 | 5.2,7.6,0 1729 | 5.4,7.7,0 1730 | 3.3,4.8,1 1731 | 3.2,4.6,0 1732 | 6.2,2.4,1 1733 | 7.8,4.1,1 1734 | 5.1,6.7,1 1735 | 6.8,3.6,1 1736 | 7.6,3.5,1 1737 | 5.8,6.1,0 1738 | 3.9,5.6,1 1739 | 8.5,3.7,1 1740 | 4.0,7.7,0 1741 | 2.3,5.2,0 1742 | 5.0,6.4,1 1743 | 4.4,8.9,0 1744 | 5.1,6.9,0 1745 | 6.5,1.6,1 1746 | 7.5,3.6,1 1747 | 4.7,4.3,1 1748 | 7.1,5.1,0 1749 | 5.3,7.5,0 1750 | 6.7,3.1,1 1751 | 3.8,5.1,0 1752 | 6.3,3.6,0 1753 | 5.3,3.8,1 1754 | 5.5,5.8,1 1755 | 4.6,4.7,1 1756 | 5.7,6.8,0 1757 | 5.0,3.2,1 1758 | 2.5,6.2,0 1759 | 4.0,5.3,0 1760 | 4.2,5.0,1 1761 | 3.5,7.0,0 1762 | 5.6,5.5,0 1763 | 4.8,5.2,1 1764 | 7.7,4.7,1 1765 | 3.3,5.0,0 1766 | 7.1,3.8,0 1767 | 5.1,5.3,1 1768 | 6.6,5.0,1 1769 | 8.3,3.6,1 1770 | 6.9,4.8,1 1771 | 6.0,2.4,1 1772 | 4.8,4.2,1 1773 | 5.5,8.0,0 1774 | 2.3,6.3,0 1775 | 6.5,3.4,0 1776 | 5.4,8.2,0 1777 | 6.3,4.3,1 1778 | 9.0,4.7,1 1779 | 5.3,7.9,0 1780 | 2.4,5.5,0 1781 | 2.7,4.2,0 1782 | 6.4,2.9,1 1783 | 2.8,4.7,0 1784 | 2.6,4.6,0 1785 | 6.8,6.3,0 1786 | 5.6,7.9,0 1787 | 5.6,7.0,0 1788 | 8.0,3.4,1 1789 | 2.8,6.3,0 1790 | 3.1,6.6,0 1791 | 4.9,7.0,0 1792 | 4.2,8.2,0 1793 | 8.1,4.9,1 1794 | 5.1,4.2,1 1795 | 6.9,5.9,0 1796 | 5.3,8.2,0 1797 | 2.9,7.3,0 1798 | 6.1,3.3,1 1799 | 6.5,8.0,0 1800 | 2.5,5.5,0 1801 | 2.6,6.0,0 1802 | 8.1,3.4,1 1803 | 7.7,4.1,1 1804 | 5.1,4.5,1 1805 | 4.3,9.6,0 1806 | 7.7,5.4,1 1807 | 2.9,4.7,0 1808 | 4.6,7.9,0 1809 | 8.2,2.3,1 1810 | 2.6,5.2,0 1811 | 8.4,4.1,1 1812 | 8.3,4.7,1 1813 | 6.2,4.0,1 1814 | 6.3,2.4,1 1815 | 5.2,4.0,1 1816 | 2.9,6.5,0 1817 | 7.3,2.5,1 1818 | 4.0,8.8,0 1819 | 8.9,4.2,1 1820 | 3.6,8.2,0 1821 | 4.7,7.4,0 1822 | 4.6,7.0,1 1823 | 7.1,2.6,1 1824 | 5.8,3.8,1 1825 | 5.8,7.8,0 1826 | 6.2,5.7,0 1827 | 8.2,3.6,1 1828 | 3.1,5.5,0 1829 | 6.8,2.7,1 1830 | 3.8,8.0,0 1831 | 2.1,5.0,0 1832 | 4.1,6.0,1 1833 | 9.3,5.9,1 1834 | 3.7,7.6,0 1835 | 5.5,5.7,0 1836 | 8.1,5.2,1 1837 | 3.2,7.9,0 1838 | 6.0,7.5,0 1839 | 7.4,3.9,0 1840 | 3.3,7.7,0 1841 | 5.2,7.7,0 1842 | 4.0,7.3,0 1843 | 4.0,7.8,0 1844 | 5.4,6.7,0 1845 | 6.0,6.7,0 1846 | 6.1,5.3,0 1847 | 4.3,4.8,1 1848 | 5.3,8.1,0 1849 | 5.0,6.5,0 1850 | 4.9,3.4,1 1851 | 4.0,6.6,0 1852 | 2.7,5.2,0 1853 | 6.6,4.0,1 1854 | 3.3,8.5,0 1855 | 9.2,5.2,1 1856 | 5.5,4.8,1 1857 | 2.6,6.1,0 1858 | 6.2,3.7,1 1859 | 3.7,8.1,0 1860 | 5.0,5.9,1 1861 | 4.0,4.7,1 1862 | 3.0,8.0,0 1863 | 4.7,8.7,0 1864 | 8.7,5.4,1 1865 | 6.5,3.2,1 1866 | 6.8,3.2,1 1867 | 7.0,2.8,1 1868 | 6.2,7.4,0 1869 | 4.3,5.6,1 1870 | 6.3,6.4,0 1871 | 5.3,4.7,1 1872 | 5.6,3.1,1 1873 | 8.5,4.6,1 1874 | 4.3,7.2,0 1875 | 7.8,2.7,1 1876 | 6.4,1.9,1 1877 | 2.5,5.2,0 1878 | 2.8,6.1,0 1879 | 6.6,3.7,1 1880 | 3.1,4.5,0 1881 | 8.0,6.8,1 1882 | 6.1,4.0,0 1883 | 1.6,5.3,0 1884 | 8.5,6.5,1 1885 | 2.9,5.0,0 1886 | 4.3,8.6,0 1887 | 5.3,8.5,0 1888 | 4.5,5.7,1 1889 | 6.4,4.1,0 1890 | 6.6,2.8,1 1891 | 2.8,7.6,0 1892 | 4.3,6.1,1 1893 | 7.8,2.2,1 1894 | 6.0,4.0,1 1895 | 4.9,5.2,1 1896 | 3.5,5.4,0 1897 | 6.0,3.6,0 1898 | 8.9,5.4,1 1899 | 4.0,6.4,0 1900 | 4.8,6.3,0 1901 | 8.1,6.7,1 1902 | 4.0,6.9,0 1903 | 3.1,5.9,0 1904 | 2.8,4.4,0 1905 | 5.6,6.9,0 1906 | 4.9,7.4,0 1907 | 6.2,6.0,0 1908 | 3.5,6.9,0 1909 | 2.9,3.9,0 1910 | 8.1,3.2,1 1911 | 6.6,5.2,0 1912 | 7.9,4.0,1 1913 | 6.4,7.6,0 1914 | 2.5,6.0,0 1915 | 6.1,3.5,1 1916 | 4.8,6.2,0 1917 | 6.5,3.4,0 1918 | 2.6,6.4,0 1919 | 3.6,8.7,0 1920 | 3.6,7.4,0 1921 | 5.0,2.4,1 1922 | 6.4,4.7,1 1923 | 5.9,4.7,0 1924 | 3.7,7.3,0 1925 | 2.9,6.6,0 1926 | 8.8,4.4,1 1927 | 5.7,4.2,1 1928 | 5.7,4.8,0 1929 | 5.7,9.5,0 1930 | 2.6,5.5,0 1931 | 4.6,6.0,1 1932 | 3.2,6.8,0 1933 | 8.7,3.9,1 1934 | 5.5,7.3,0 1935 | 4.4,4.4,1 1936 | 7.6,5.4,0 1937 | 7.2,3.1,1 1938 | 6.8,3.8,1 1939 | 3.4,6.4,0 1940 | 4.4,7.3,0 1941 | 3.1,6.5,0 1942 | 3.4,6.7,0 1943 | 8.3,3.3,1 1944 | 4.9,3.9,1 1945 | 5.9,5.5,0 1946 | 5.1,7.8,0 1947 | 5.6,9.7,0 1948 | 3.9,8.2,0 1949 | 8.3,2.3,1 1950 | 7.8,3.1,1 1951 | 6.9,5.9,0 1952 | 7.7,4.1,1 1953 | 5.7,2.9,1 1954 | 4.2,5.3,1 1955 | 8.7,6.0,1 1956 | 1.9,6.5,0 1957 | 6.1,5.6,0 1958 | 8.4,5.1,1 1959 | 8.5,5.8,1 1960 | 6.9,2.4,1 1961 | 6.3,3.3,1 1962 | 3.6,8.4,0 1963 | 9.2,5.1,1 1964 | 3.4,7.3,0 1965 | 8.3,4.6,1 1966 | 3.4,5.1,1 1967 | 5.9,6.1,0 1968 | 6.2,2.0,1 1969 | 8.0,5.9,1 1970 | 5.5,2.9,1 1971 | 5.7,4.4,1 1972 | 6.1,7.0,0 1973 | 4.6,3.6,1 1974 | 5.4,2.9,1 1975 | 8.1,4.6,1 1976 | 6.3,3.4,1 1977 | 4.9,5.8,0 1978 | 5.7,4.4,1 1979 | 5.2,4.6,1 1980 | 4.0,7.5,0 1981 | 5.5,3.2,1 1982 | 8.0,4.6,1 1983 | 5.2,7.2,0 1984 | 2.2,5.0,0 1985 | 8.2,6.4,1 1986 | 5.9,3.8,1 1987 | 2.9,5.1,0 1988 | 3.9,6.9,0 1989 | 2.6,4.7,0 1990 | 5.4,8.1,0 1991 | 5.3,3.2,1 1992 | 3.2,7.6,0 1993 | 5.7,5.3,0 1994 | 4.7,8.8,0 1995 | 5.2,4.4,1 1996 | 4.9,5.0,1 1997 | 4.1,6.6,0 1998 | 3.3,6.2,0 1999 | 3.2,8.9,0 2000 | 8.0,4.3,1 2001 | 9.3,6.0,1 2002 | 4.7,5.7,1 2003 | 8.1,3.7,1 2004 | 6.2,3.1,1 2005 | 6.6,4.6,1 2006 | 4.5,8.3,0 2007 | 5.1,4.3,1 2008 | 2.8,6.0,0 2009 | 4.0,6.6,0 2010 | 4.6,4.8,1 2011 | 3.1,5.0,0 2012 | 6.0,2.8,1 2013 | 8.5,4.4,1 2014 | 3.0,7.8,0 2015 | 7.0,3.3,1 2016 | 3.3,6.7,0 2017 | 5.2,4.1,1 2018 | 1.8,6.5,0 2019 | 5.3,3.8,1 2020 | 7.0,4.0,1 2021 | 7.4,3.3,1 2022 | 8.7,5.5,1 2023 | 6.6,4.5,0 2024 | 5.7,4.0,1 2025 | 5.6,3.0,1 2026 | 4.1,6.9,0 2027 | 8.0,3.9,1 2028 | 3.7,6.2,0 2029 | 3.0,7.7,0 2030 | 6.6,7.5,0 2031 | 3.2,6.6,0 2032 | 2.0,6.0,0 2033 | 5.2,7.1,0 2034 | 4.3,7.6,0 2035 | 8.1,5.2,1 2036 | 6.5,4.6,1 2037 | 7.9,3.0,1 2038 | 3.1,6.7,0 2039 | 2.6,5.4,0 2040 | 8.2,2.8,1 2041 | 4.7,6.8,1 2042 | 6.8,5.9,0 2043 | 7.4,7.0,0 2044 | 7.8,3.1,1 2045 | 6.0,6.7,0 2046 | 8.0,4.3,1 2047 | 6.3,5.7,0 2048 | 6.7,3.6,1 2049 | 6.5,4.9,0 2050 | 5.2,6.6,0 2051 | 8.6,4.9,1 2052 | 8.0,4.8,0 2053 | 6.7,6.0,1 2054 | 4.8,4.0,1 2055 | 4.3,7.1,0 2056 | 8.5,3.0,1 2057 | 7.1,4.3,0 2058 | 6.3,6.0,0 2059 | 5.1,3.7,1 2060 | 6.8,4.9,1 2061 | 5.6,2.9,1 2062 | 8.3,3.3,1 2063 | 6.0,4.2,1 2064 | 4.2,5.7,1 2065 | 5.4,6.4,0 2066 | 5.3,4.3,1 2067 | 3.3,6.1,0 2068 | 3.8,7.6,0 2069 | 4.0,6.6,0 2070 | 6.1,7.5,0 2071 | 4.0,7.3,0 2072 | 8.4,4.4,1 2073 | 6.7,6.9,0 2074 | 5.3,3.3,1 2075 | 6.3,3.2,1 2076 | 4.5,5.0,1 2077 | 6.5,3.8,1 2078 | 2.6,4.9,0 2079 | 3.2,7.1,0 2080 | 4.2,4.1,1 2081 | 9.3,5.3,1 2082 | 5.4,3.6,1 2083 | 4.1,7.9,0 2084 | 5.1,4.1,1 2085 | 8.7,5.5,1 2086 | 2.4,6.6,0 2087 | 8.1,4.8,1 2088 | 8.2,6.0,1 2089 | 3.5,5.1,0 2090 | 4.9,4.4,1 2091 | 4.6,8.3,0 2092 | 2.8,6.5,0 2093 | 8.3,4.9,1 2094 | 7.8,3.3,1 2095 | 4.9,5.7,1 2096 | 9.0,4.3,1 2097 | 6.9,6.0,0 2098 | 7.2,4.4,0 2099 | 6.0,3.4,1 2100 | 4.2,8.5,0 2101 | 2.6,6.7,0 2102 | 4.7,2.9,1 2103 | 6.7,3.2,1 2104 | 7.3,1.0,1 2105 | 2.8,5.7,0 2106 | 5.5,3.8,1 2107 | 2.5,6.9,0 2108 | 7.8,5.2,1 2109 | 6.4,3.6,1 2110 | 6.1,6.1,0 2111 | 5.9,3.8,1 2112 | 5.3,6.8,0 2113 | 6.9,4.6,1 2114 | 8.6,3.4,1 2115 | 3.9,6.5,1 2116 | 2.7,5.6,0 2117 | 9.0,4.7,1 2118 | 5.9,3.0,1 2119 | 7.4,3.7,1 2120 | 7.4,2.3,1 2121 | 3.8,5.5,0 2122 | 5.8,7.6,0 2123 | 5.1,6.3,1 2124 | 7.4,4.8,1 2125 | 5.2,2.9,1 2126 | 4.9,6.0,1 2127 | 5.7,3.6,1 2128 | 6.1,7.1,0 2129 | 7.4,2.4,1 2130 | 5.3,2.9,1 2131 | 4.5,8.5,0 2132 | 4.2,8.0,0 2133 | 5.8,3.6,1 2134 | 5.7,6.1,0 2135 | 5.0,3.7,1 2136 | 4.8,4.3,1 2137 | 4.9,4.9,1 2138 | 6.3,6.2,0 2139 | 5.7,6.8,0 2140 | 5.6,2.8,1 2141 | 6.5,2.9,1 2142 | 5.1,7.6,0 2143 | 7.1,5.4,0 2144 | 5.6,6.6,0 2145 | 6.3,5.7,0 2146 | 5.0,7.1,0 2147 | 6.9,3.5,1 2148 | 8.9,3.6,1 2149 | 2.6,5.8,0 2150 | 7.2,3.5,1 2151 | 2.5,4.8,0 2152 | 7.9,4.7,1 2153 | 4.4,8.2,0 2154 | 6.2,6.5,0 2155 | 3.1,3.9,0 2156 | 3.6,8.4,0 2157 | 5.3,3.8,1 2158 | 4.7,5.6,1 2159 | 6.6,6.0,0 2160 | 4.5,6.9,0 2161 | 5.9,5.6,1 2162 | 6.6,6.0,0 2163 | 6.2,4.7,0 2164 | 5.6,5.2,1 2165 | 6.5,7.6,0 2166 | 6.1,4.8,0 2167 | 3.4,6.1,0 2168 | 3.7,7.9,0 2169 | 6.1,6.3,0 2170 | 3.4,6.7,0 2171 | 6.9,6.6,0 2172 | 6.6,3.0,1 2173 | 2.9,6.1,0 2174 | 6.8,3.1,1 2175 | 4.3,6.1,1 2176 | 4.9,4.9,1 2177 | 8.6,4.1,1 2178 | 8.1,3.7,1 2179 | 8.6,4.2,1 2180 | 5.5,3.0,1 2181 | 7.8,5.3,1 2182 | 5.3,3.9,1 2183 | 4.8,4.9,1 2184 | 3.1,5.6,0 2185 | 4.9,8.1,1 2186 | 5.4,8.9,0 2187 | 7.1,2.3,1 2188 | 2.7,4.4,0 2189 | 6.3,5.3,0 2190 | 7.5,2.6,1 2191 | 4.4,7.2,0 2192 | 7.6,3.4,1 2193 | 7.0,7.7,0 2194 | 6.9,5.1,0 2195 | 9.0,4.5,1 2196 | 6.1,4.0,1 2197 | 6.2,1.4,1 2198 | 5.2,8.0,0 2199 | 6.9,6.5,0 2200 | 5.9,4.4,1 2201 | 2.9,6.6,0 2202 | 8.0,2.3,1 2203 | 5.0,2.7,1 2204 | 8.0,3.1,1 2205 | 8.6,3.4,1 2206 | 5.1,2.7,1 2207 | 5.7,7.7,0 2208 | 4.2,5.6,1 2209 | 8.6,3.7,1 2210 | 8.8,3.2,1 2211 | 6.8,2.0,1 2212 | 5.5,4.5,1 2213 | 3.6,6.4,0 2214 | 4.5,7.1,1 2215 | 2.4,6.7,0 2216 | 4.4,8.2,0 2217 | 3.7,7.8,0 2218 | 2.9,5.8,0 2219 | 7.4,3.3,1 2220 | 6.6,6.9,0 2221 | 5.1,2.2,1 2222 | 6.1,4.6,0 2223 | 6.8,7.5,0 2224 | 5.4,8.4,0 2225 | 3.9,7.4,0 2226 | 6.3,5.3,0 2227 | 5.5,8.0,0 2228 | 6.5,6.2,0 2229 | 8.2,3.2,1 2230 | 3.1,5.6,0 2231 | 7.5,4.0,1 2232 | 4.1,8.8,0 2233 | 6.2,3.6,1 2234 | 1.9,5.4,0 2235 | 3.4,6.9,0 2236 | 5.3,5.6,0 2237 | 6.5,3.9,0 2238 | 7.3,5.7,0 2239 | 2.9,7.9,0 2240 | 3.6,7.0,0 2241 | 7.4,3.1,1 2242 | 4.8,3.1,1 2243 | 5.6,4.2,1 2244 | 3.2,6.2,0 2245 | 5.4,5.8,1 2246 | 5.1,8.5,0 2247 | 2.6,5.6,0 2248 | 8.6,4.1,1 2249 | 5.0,7.4,0 2250 | 2.5,6.1,0 2251 | 6.3,1.7,1 2252 | 5.7,4.3,0 2253 | 8.7,5.2,1 2254 | 4.6,7.7,0 2255 | 6.0,4.4,0 2256 | 5.2,8.5,0 2257 | 5.0,5.2,1 2258 | 6.8,7.6,0 2259 | 4.6,6.0,1 2260 | 7.2,6.4,0 2261 | 3.9,6.8,0 2262 | 4.8,2.8,1 2263 | 5.2,3.7,1 2264 | 6.5,3.3,1 2265 | 4.7,7.4,0 2266 | 6.2,2.7,1 2267 | 7.9,3.3,1 2268 | 6.7,4.4,0 2269 | 5.7,3.5,1 2270 | 6.8,6.8,0 2271 | 2.0,4.4,0 2272 | 6.1,2.8,1 2273 | 6.9,5.4,0 2274 | 5.4,5.1,1 2275 | 7.5,3.3,1 2276 | 6.4,2.9,1 2277 | 6.0,4.1,0 2278 | 4.6,8.7,0 2279 | 6.2,4.3,1 2280 | 6.0,1.6,1 2281 | 5.0,7.4,0 2282 | 6.0,6.4,0 2283 | 3.7,6.6,0 2284 | 6.9,3.7,1 2285 | 6.8,5.7,0 2286 | 5.6,6.7,0 2287 | 3.2,4.9,0 2288 | 5.2,4.2,1 2289 | 5.7,6.4,0 2290 | 2.8,5.0,0 2291 | 6.3,2.8,1 2292 | 2.5,6.6,0 2293 | 7.4,6.0,1 2294 | 6.7,2.6,1 2295 | 6.3,6.3,0 2296 | 5.7,2.5,1 2297 | 5.8,6.2,0 2298 | 9.5,5.8,1 2299 | 8.7,5.0,1 2300 | 5.2,3.6,1 2301 | 5.2,7.3,0 2302 | 5.6,7.6,0 2303 | 6.4,7.2,0 2304 | 8.0,3.4,1 2305 | 5.7,3.2,1 2306 | 6.0,6.9,0 2307 | 5.4,7.5,0 2308 | 5.8,3.0,1 2309 | 6.1,7.3,0 2310 | 5.5,8.2,0 2311 | 5.8,5.8,0 2312 | 5.7,4.0,1 2313 | 3.6,4.7,1 2314 | 5.9,3.6,1 2315 | 5.6,3.0,1 2316 | 7.9,4.1,1 2317 | 8.0,4.8,1 2318 | 9.2,4.9,1 2319 | 6.2,7.2,0 2320 | 2.5,5.2,0 2321 | 5.1,8.4,0 2322 | 7.2,3.9,1 2323 | 6.8,4.6,1 2324 | 5.6,3.8,1 2325 | 4.9,2.8,1 2326 | 3.2,5.4,0 2327 | 6.4,4.5,0 2328 | 7.3,3.9,1 2329 | 2.3,5.1,0 2330 | 5.6,3.4,1 2331 | 4.4,6.2,1 2332 | 5.6,3.9,1 2333 | 5.9,6.3,0 2334 | 5.1,7.7,0 2335 | 4.9,6.8,0 2336 | 5.6,7.7,0 2337 | 8.8,7.0,1 2338 | 6.2,3.0,1 2339 | 4.5,4.9,1 2340 | 9.9,5.9,1 2341 | 4.3,9.8,0 2342 | 2.6,6.5,0 2343 | 7.1,3.8,0 2344 | 3.7,9.0,0 2345 | 8.3,5.4,1 2346 | 7.3,3.3,1 2347 | 3.7,6.4,0 2348 | 6.2,5.5,0 2349 | 6.1,4.0,1 2350 | 6.4,5.9,0 2351 | 5.1,4.2,1 2352 | 7.9,3.1,1 2353 | 9.1,5.3,1 2354 | 8.2,3.2,1 2355 | 7.9,6.3,1 2356 | 7.5,4.6,0 2357 | 6.2,4.6,1 2358 | 4.8,3.6,1 2359 | 5.1,7.9,0 2360 | 6.1,6.8,0 2361 | 3.9,5.5,1 2362 | 5.3,5.9,0 2363 | 4.2,5.9,1 2364 | 3.5,6.6,0 2365 | 6.0,4.5,1 2366 | 7.6,4.6,1 2367 | 3.6,5.9,0 2368 | 5.7,3.6,1 2369 | 5.2,7.7,0 2370 | 6.2,5.9,0 2371 | 4.2,7.1,0 2372 | 5.2,6.9,0 2373 | 7.2,3.1,1 2374 | 2.8,5.5,0 2375 | 2.9,7.9,0 2376 | 2.4,7.4,0 2377 | 6.0,6.0,0 2378 | 5.1,7.5,0 2379 | 6.7,7.4,0 2380 | 4.7,7.0,0 2381 | 3.3,4.6,0 2382 | 3.4,6.8,0 2383 | 6.0,7.7,0 2384 | 2.1,5.8,0 2385 | 7.8,3.3,1 2386 | 4.6,4.7,1 2387 | 3.3,6.1,0 2388 | 5.9,3.1,1 2389 | 5.4,7.0,1 2390 | 8.6,3.7,1 2391 | 2.2,6.2,0 2392 | 4.9,5.5,1 2393 | 3.0,5.4,0 2394 | 8.2,4.3,1 2395 | 6.9,5.6,0 2396 | 3.4,6.8,0 2397 | 3.3,6.4,0 2398 | 5.0,4.1,1 2399 | 7.1,3.1,1 2400 | 7.6,4.5,1 2401 | 6.0,2.9,1 2402 | 5.7,5.5,0 2403 | 3.2,6.0,0 2404 | 4.2,8.0,0 2405 | 3.9,7.5,0 2406 | 4.7,8.0,0 2407 | 4.2,5.8,1 2408 | 3.2,4.8,0 2409 | 5.1,7.9,0 2410 | 9.3,6.7,1 2411 | 7.7,3.3,1 2412 | 5.1,3.3,1 2413 | 4.4,4.6,1 2414 | 2.2,4.9,0 2415 | 4.5,6.3,0 2416 | 3.6,7.9,0 2417 | 8.9,5.6,1 2418 | 4.7,6.0,1 2419 | 8.2,4.1,1 2420 | 9.0,5.7,1 2421 | 8.8,1.7,1 2422 | 5.7,8.4,0 2423 | 6.6,5.8,0 2424 | 6.5,5.7,0 2425 | 8.5,4.7,1 2426 | 5.2,9.0,0 2427 | 5.6,7.0,0 2428 | 8.1,5.1,1 2429 | 2.3,6.4,0 2430 | 7.3,2.9,1 2431 | 4.7,4.3,1 2432 | 3.2,7.6,0 2433 | 3.3,6.5,0 2434 | 6.3,4.5,0 2435 | 4.6,8.1,0 2436 | 5.2,4.5,1 2437 | 4.9,6.5,0 2438 | 7.9,3.8,1 2439 | 5.7,3.7,1 2440 | 2.5,6.2,0 2441 | 3.5,6.3,1 2442 | 7.0,3.7,1 2443 | 8.6,3.9,1 2444 | 5.6,1.4,1 2445 | 5.0,6.1,1 2446 | 3.6,6.0,0 2447 | 3.0,4.3,0 2448 | 5.1,3.0,1 2449 | 7.8,3.1,1 2450 | 5.2,6.0,1 2451 | 3.0,6.3,0 2452 | 4.6,5.4,1 2453 | 4.0,6.3,0 2454 | 4.0,7.1,0 2455 | 6.7,5.8,0 2456 | 5.3,8.4,0 2457 | 8.2,6.6,1 2458 | 2.8,7.0,0 2459 | 8.3,4.6,1 2460 | 7.5,4.6,1 2461 | 3.1,6.5,0 2462 | 3.2,6.6,0 2463 | 6.4,3.2,1 2464 | 3.5,7.5,0 2465 | 3.1,8.2,0 2466 | 2.3,5.0,0 2467 | 7.4,1.5,1 2468 | 3.9,6.9,0 2469 | 6.5,5.5,0 2470 | 8.8,5.4,1 2471 | 3.9,8.2,0 2472 | 4.3,6.3,0 2473 | 8.7,6.1,1 2474 | 6.7,6.4,0 2475 | 7.2,5.9,0 2476 | 5.8,7.1,0 2477 | 7.9,3.6,1 2478 | 7.1,2.9,1 2479 | 8.2,2.9,1 2480 | 5.5,5.9,0 2481 | 2.6,4.5,0 2482 | 7.9,4.3,1 2483 | 5.2,3.1,1 2484 | 5.4,9.1,0 2485 | 6.8,2.1,1 2486 | 2.0,4.6,0 2487 | 4.4,4.4,1 2488 | 3.8,7.0,0 2489 | 9.1,6.0,1 2490 | 6.1,3.9,1 2491 | 4.8,6.3,1 2492 | 6.3,4.7,0 2493 | 6.7,4.2,1 2494 | 5.7,2.4,1 2495 | 8.2,7.2,1 2496 | 3.3,8.1,0 2497 | 4.6,5.1,1 2498 | 2.6,6.3,0 2499 | 6.5,3.5,1 2500 | 5.0,3.5,1 2501 | 4.4,6.8,0 2502 | 4.0,8.5,0 2503 | 5.6,6.6,0 2504 | 4.2,5.8,1 2505 | 4.9,4.8,1 2506 | 4.4,8.8,0 2507 | 4.7,7.3,0 2508 | 6.9,6.5,0 2509 | 5.3,5.7,0 2510 | 4.6,5.3,1 2511 | 9.0,6.2,1 2512 | 6.6,6.0,0 2513 | 5.6,3.4,1 2514 | 3.9,7.7,0 2515 | 3.9,4.5,1 2516 | 7.5,3.3,0 2517 | 7.3,3.9,1 2518 | 7.4,6.5,0 2519 | 3.4,7.1,0 2520 | 3.5,6.8,0 2521 | 2.3,5.9,0 2522 | 8.2,3.7,1 2523 | 7.7,4.7,1 2524 | 8.3,5.1,1 2525 | 4.9,5.8,1 2526 | 7.9,3.3,1 2527 | 7.2,2.6,1 2528 | 5.4,3.2,1 2529 | 4.0,10.0,0 2530 | 6.7,2.9,1 2531 | 3.1,8.9,0 2532 | 6.2,7.8,0 2533 | 6.9,3.5,1 2534 | 4.8,3.7,1 2535 | 6.6,6.6,0 2536 | 5.8,7.3,0 2537 | 2.9,5.6,0 2538 | 3.5,7.3,0 2539 | 10.0,5.6,1 2540 | 9.8,4.9,1 2541 | 4.8,3.6,1 2542 | 5.7,3.7,1 2543 | 6.8,2.5,1 2544 | 6.5,5.5,0 2545 | 8.3,5.2,1 2546 | 2.4,5.7,0 2547 | 4.6,5.9,1 2548 | 4.3,7.0,0 2549 | 7.8,3.6,1 2550 | 8.2,4.0,1 2551 | 7.2,4.1,1 2552 | 6.7,4.8,1 2553 | 3.3,6.7,0 2554 | 8.9,5.4,1 2555 | 3.9,7.2,0 2556 | 5.2,5.2,1 2557 | 6.7,3.9,1 2558 | 4.3,8.2,0 2559 | 3.6,6.1,0 2560 | 7.6,4.0,1 2561 | 3.6,8.4,0 2562 | 3.3,4.2,1 2563 | 6.4,4.8,0 2564 | 8.0,4.4,1 2565 | 4.8,6.9,0 2566 | 3.2,5.3,0 2567 | 5.2,7.7,0 2568 | 3.4,7.0,0 2569 | 4.3,7.1,0 2570 | 5.4,8.1,0 2571 | 5.1,6.5,0 2572 | 2.8,8.0,0 2573 | 2.9,7.1,0 2574 | 5.2,8.0,0 2575 | 5.3,6.5,0 2576 | 8.1,2.5,1 2577 | 4.4,5.1,1 2578 | 4.5,7.5,0 2579 | 5.0,3.5,1 2580 | 3.5,6.1,0 2581 | 9.0,4.5,1 2582 | 6.1,5.0,0 2583 | 3.8,6.0,0 2584 | 8.4,4.6,1 2585 | 5.6,3.5,1 2586 | 4.5,7.1,0 2587 | 4.3,3.4,1 2588 | 4.2,7.4,0 2589 | 5.9,5.3,0 2590 | 5.0,8.9,0 2591 | 7.9,4.2,1 2592 | 9.1,4.6,1 2593 | 8.2,5.2,1 2594 | 4.4,7.7,0 2595 | 6.6,8.1,0 2596 | 5.5,7.0,0 2597 | 6.7,4.7,0 2598 | 3.4,5.8,0 2599 | 4.4,6.6,0 2600 | 4.1,8.1,0 2601 | 2.0,5.3,0 2602 | 3.8,6.9,0 2603 | 6.3,4.7,0 2604 | 5.0,6.4,1 2605 | 6.3,2.3,1 2606 | 7.9,3.9,1 2607 | 2.6,6.3,0 2608 | 4.1,7.7,0 2609 | 4.9,6.6,0 2610 | 4.8,4.2,1 2611 | 6.5,3.1,1 2612 | 7.0,3.8,1 2613 | 6.0,3.2,1 2614 | 2.3,6.5,0 2615 | 5.5,8.0,0 2616 | 6.9,5.6,0 2617 | 3.9,8.1,0 2618 | 6.5,3.2,1 2619 | 5.7,4.9,1 2620 | 4.1,7.5,0 2621 | 3.2,7.5,0 2622 | 3.2,6.2,0 2623 | 6.6,4.1,1 2624 | 4.3,2.8,1 2625 | 3.5,6.5,0 2626 | 6.1,6.7,0 2627 | 8.2,2.4,1 2628 | 6.8,3.1,1 2629 | 6.6,5.3,0 2630 | 4.4,7.3,0 2631 | 6.9,3.1,0 2632 | 8.7,5.7,1 2633 | 4.8,7.1,0 2634 | 8.2,3.8,1 2635 | 4.1,8.3,0 2636 | 6.0,4.1,1 2637 | 5.0,4.7,1 2638 | 5.4,6.7,0 2639 | 4.5,5.1,1 2640 | 8.4,5.4,1 2641 | 5.8,7.3,0 2642 | 4.3,7.2,0 2643 | 2.3,5.8,0 2644 | 8.1,3.2,1 2645 | 6.5,5.8,0 2646 | 4.4,3.8,1 2647 | 5.4,7.1,0 2648 | 8.8,5.6,1 2649 | 2.7,5.3,0 2650 | 5.0,6.6,0 2651 | 8.3,6.2,1 2652 | 5.6,5.5,1 2653 | 5.1,5.3,1 2654 | 5.7,2.3,1 2655 | 7.5,5.8,0 2656 | 7.9,7.2,1 2657 | 5.2,3.0,1 2658 | 4.2,8.4,0 2659 | 8.1,7.2,1 2660 | 6.9,5.2,0 2661 | 3.0,7.9,0 2662 | 2.8,8.4,0 2663 | 5.2,8.1,0 2664 | 5.2,9.1,0 2665 | 7.6,5.3,0 2666 | 6.5,7.9,0 2667 | 7.4,3.8,1 2668 | 8.9,3.2,1 2669 | 3.8,6.2,0 2670 | 8.6,5.9,1 2671 | 7.4,6.0,1 2672 | 8.9,3.3,1 2673 | 3.6,8.1,0 2674 | 6.9,4.1,1 2675 | 6.9,3.6,1 2676 | 2.9,5.4,0 2677 | 7.3,4.7,0 2678 | 8.2,5.8,1 2679 | 5.6,6.2,0 2680 | 5.0,7.4,0 2681 | 9.0,2.9,1 2682 | 8.8,5.6,1 2683 | 3.6,4.8,1 2684 | 4.6,6.7,0 2685 | 8.5,1.7,1 2686 | 4.5,7.7,0 2687 | 6.3,6.4,0 2688 | 6.1,3.1,1 2689 | 4.4,5.2,1 2690 | 7.9,3.5,1 2691 | 9.0,6.5,1 2692 | 6.3,3.5,1 2693 | 5.6,3.9,1 2694 | 4.6,5.4,1 2695 | 3.2,7.7,0 2696 | 5.2,7.2,0 2697 | 4.2,7.8,0 2698 | 8.7,7.4,1 2699 | 5.6,8.3,0 2700 | 8.8,5.4,1 2701 | 3.7,6.0,0 2702 | 3.6,6.9,0 2703 | 2.4,5.1,0 2704 | 8.4,3.7,1 2705 | 5.0,5.9,1 2706 | 8.7,6.7,1 2707 | 2.8,7.1,0 2708 | 8.3,4.5,1 2709 | 4.5,3.3,1 2710 | 7.0,4.8,0 2711 | 4.4,5.4,1 2712 | 3.8,7.1,0 2713 | 7.6,6.6,1 2714 | 4.4,9.2,0 2715 | 5.0,2.6,1 2716 | 5.7,3.8,1 2717 | 6.7,4.3,1 2718 | 6.8,5.4,0 2719 | 8.6,3.8,1 2720 | 8.4,4.6,1 2721 | 6.6,5.0,0 2722 | 6.5,6.4,0 2723 | 2.3,5.9,0 2724 | 2.6,5.5,0 2725 | 4.5,5.3,1 2726 | 5.5,6.7,0 2727 | 5.2,5.5,0 2728 | 4.4,5.3,1 2729 | 6.6,3.6,1 2730 | 5.7,3.9,1 2731 | 5.4,7.4,0 2732 | 2.5,6.1,0 2733 | 6.2,3.2,1 2734 | 4.6,5.4,1 2735 | 5.8,2.1,1 2736 | 8.7,3.8,1 2737 | 5.3,6.9,0 2738 | 6.6,1.8,1 2739 | 3.4,7.0,0 2740 | 6.9,4.2,1 2741 | 3.8,7.3,0 2742 | 8.4,7.2,1 2743 | 5.1,8.6,0 2744 | 7.8,3.3,1 2745 | 7.7,4.7,1 2746 | 5.0,5.4,1 2747 | 6.3,5.3,0 2748 | 5.2,5.1,1 2749 | 1.3,5.3,0 2750 | 6.7,2.4,1 2751 | 5.4,4.1,1 2752 | 7.9,2.3,1 2753 | 5.6,5.7,1 2754 | 4.8,6.2,0 2755 | 7.6,2.6,1 2756 | 8.2,5.6,1 2757 | 7.7,4.5,1 2758 | 5.4,4.6,1 2759 | 7.5,7.5,0 2760 | 4.3,3.8,1 2761 | 4.4,5.3,1 2762 | 6.7,4.7,0 2763 | 4.2,5.7,1 2764 | 5.4,3.5,1 2765 | 2.6,6.4,0 2766 | 7.2,2.9,1 2767 | 8.0,5.6,1 2768 | 5.1,6.3,0 2769 | 4.8,5.3,1 2770 | 8.0,3.8,1 2771 | 6.8,5.3,0 2772 | 2.7,7.7,0 2773 | 5.6,7.0,0 2774 | 5.4,2.5,1 2775 | 5.6,3.2,1 2776 | 6.6,7.0,0 2777 | 6.9,3.3,1 2778 | 6.6,5.6,0 2779 | 4.1,8.3,0 2780 | 6.0,7.0,0 2781 | 6.6,6.2,0 2782 | 6.7,6.2,0 2783 | 4.8,8.9,0 2784 | 7.9,2.6,1 2785 | 3.8,4.1,0 2786 | 5.8,4.2,1 2787 | 4.7,4.9,1 2788 | 8.2,5.8,1 2789 | 4.4,3.9,1 2790 | 8.6,6.9,1 2791 | 2.9,7.4,0 2792 | 4.3,4.1,1 2793 | 7.6,4.6,1 2794 | 5.0,5.2,1 2795 | 4.9,7.6,0 2796 | 4.5,6.0,1 2797 | 7.0,2.0,1 2798 | 5.2,7.7,0 2799 | 6.2,4.6,0 2800 | 5.6,1.9,1 2801 | 4.8,8.4,0 2802 | 4.5,4.5,1 2803 | 2.3,6.4,0 2804 | 9.4,5.9,1 2805 | 8.3,2.6,1 2806 | 4.5,6.8,1 2807 | 4.4,3.5,1 2808 | 3.6,7.0,0 2809 | 8.1,4.2,1 2810 | 5.3,3.7,1 2811 | 5.9,3.1,1 2812 | 5.5,6.9,0 2813 | 6.2,8.0,0 2814 | 3.1,5.5,0 2815 | 6.1,6.5,0 2816 | 5.9,8.0,0 2817 | 2.8,5.4,0 2818 | 2.9,3.7,0 2819 | 5.8,7.0,0 2820 | 2.7,7.2,0 2821 | 5.9,5.1,1 2822 | 3.4,7.5,0 2823 | 8.3,4.4,1 2824 | 7.6,5.2,1 2825 | 2.8,5.3,0 2826 | 2.3,5.5,0 2827 | 1.9,5.9,0 2828 | 6.7,4.3,1 2829 | 2.6,3.8,0 2830 | 5.1,3.0,1 2831 | 4.4,5.5,1 2832 | 4.8,4.7,1 2833 | 2.8,5.1,0 2834 | 8.9,5.4,1 2835 | 9.3,6.3,1 2836 | 4.8,5.1,1 2837 | 2.6,8.2,0 2838 | 4.0,7.8,0 2839 | 8.4,4.2,1 2840 | 5.3,4.6,1 2841 | 8.9,4.4,1 2842 | 8.2,4.3,1 2843 | 6.9,3.3,1 2844 | 4.8,4.4,1 2845 | 5.4,6.4,1 2846 | 3.1,6.7,0 2847 | 7.6,2.4,1 2848 | 3.0,6.9,0 2849 | 5.9,7.8,0 2850 | 4.8,4.6,1 2851 | 7.5,3.4,1 2852 | 7.8,5.7,1 2853 | 8.3,4.3,1 2854 | 5.3,4.2,1 2855 | 5.9,3.0,1 2856 | 7.0,3.9,0 2857 | 2.9,8.5,0 2858 | 5.3,7.0,0 2859 | 9.0,5.8,1 2860 | 3.9,7.9,0 2861 | 2.6,2.5,0 2862 | 4.5,4.7,1 2863 | 3.0,7.6,0 2864 | 6.6,6.9,0 2865 | 5.3,7.2,0 2866 | 8.5,4.5,1 2867 | 3.7,7.8,0 2868 | 6.3,7.0,0 2869 | 8.6,4.6,1 2870 | 8.4,4.8,1 2871 | 3.2,7.7,0 2872 | 8.6,3.3,1 2873 | 2.1,4.1,0 2874 | 8.1,2.8,1 2875 | 3.3,6.4,0 2876 | 4.8,5.7,1 2877 | 8.2,3.9,1 2878 | 5.0,3.4,1 2879 | 9.2,5.3,1 2880 | 5.8,3.2,1 2881 | 4.8,7.2,0 2882 | 4.1,3.2,1 2883 | 8.1,3.2,1 2884 | 5.7,6.9,0 2885 | 3.8,6.9,0 2886 | 4.5,4.7,1 2887 | 7.2,5.9,0 2888 | 5.6,3.5,1 2889 | 6.6,4.0,1 2890 | 6.7,2.9,1 2891 | 4.9,5.3,1 2892 | 6.4,6.5,0 2893 | 6.8,2.7,1 2894 | 5.3,8.1,0 2895 | 4.4,5.3,1 2896 | 5.6,6.5,0 2897 | 8.0,4.5,1 2898 | 4.4,5.1,1 2899 | 3.0,6.0,0 2900 | 3.3,4.4,0 2901 | 7.9,5.9,1 2902 | 6.1,2.7,1 2903 | 2.7,7.1,0 2904 | 2.6,6.2,0 2905 | 7.5,4.3,1 2906 | 5.5,4.9,0 2907 | 5.5,2.9,1 2908 | 2.9,7.4,0 2909 | 5.0,5.6,0 2910 | 5.5,7.6,0 2911 | 5.7,2.6,1 2912 | 4.9,7.7,0 2913 | 7.3,1.5,1 2914 | 4.2,8.8,0 2915 | 2.7,7.8,0 2916 | 3.9,8.0,0 2917 | 6.8,7.0,0 2918 | 8.1,5.1,1 2919 | 6.7,3.3,1 2920 | 2.9,7.3,0 2921 | 3.4,5.8,0 2922 | 6.3,9.6,0 2923 | 4.3,8.2,0 2924 | 7.1,3.3,1 2925 | 4.0,7.1,0 2926 | 5.2,2.3,1 2927 | 6.3,6.6,0 2928 | 6.0,5.8,0 2929 | 4.5,5.2,1 2930 | 7.5,5.8,1 2931 | 7.7,5.4,1 2932 | 5.3,8.8,0 2933 | 3.7,4.8,1 2934 | 3.1,5.9,0 2935 | 7.7,5.9,1 2936 | 4.1,6.5,0 2937 | 3.4,4.8,1 2938 | 5.2,3.4,1 2939 | 6.0,3.9,1 2940 | 6.2,5.3,0 2941 | 4.5,8.5,0 2942 | 7.7,2.9,1 2943 | 2.2,4.3,0 2944 | 3.6,5.4,0 2945 | 6.2,3.8,1 2946 | 2.6,6.4,0 2947 | 7.8,3.5,1 2948 | 8.0,6.5,1 2949 | 5.7,2.4,1 2950 | 6.5,5.6,0 2951 | 5.6,3.5,1 2952 | 7.9,3.2,1 2953 | 4.8,7.2,0 2954 | 7.7,1.7,1 2955 | 2.2,6.1,0 2956 | 5.6,2.8,1 2957 | 8.4,6.1,1 2958 | 5.7,4.2,1 2959 | 5.1,9.1,0 2960 | 3.9,7.3,1 2961 | 8.4,6.5,1 2962 | 3.4,3.8,0 2963 | 5.5,4.6,1 2964 | 6.0,6.6,0 2965 | 8.6,4.7,1 2966 | 6.7,6.6,0 2967 | 5.6,3.8,1 2968 | 3.8,7.4,0 2969 | 8.3,4.5,1 2970 | 5.9,2.8,1 2971 | 8.3,4.7,1 2972 | 2.9,8.0,0 2973 | 5.3,7.9,0 2974 | 9.3,5.5,1 2975 | 4.2,7.3,0 2976 | 7.0,4.6,1 2977 | 5.8,4.8,0 2978 | 5.7,6.8,0 2979 | 2.9,6.1,0 2980 | 7.6,4.1,1 2981 | 3.8,7.3,0 2982 | 2.6,6.4,0 2983 | 8.3,3.2,1 2984 | 8.1,4.9,1 2985 | 5.0,5.5,1 2986 | 7.2,3.5,1 2987 | 4.2,6.4,0 2988 | 4.2,4.3,1 2989 | 6.4,5.5,0 2990 | 9.0,4.7,1 2991 | 6.5,2.8,1 2992 | 1.6,4.7,0 2993 | 6.8,7.3,0 2994 | 2.8,7.1,0 2995 | 5.8,8.0,0 2996 | 5.4,2.1,1 2997 | 5.0,6.5,1 2998 | 3.4,6.6,0 2999 | 2.7,6.5,0 3000 | 3.3,5.6,0 3001 | 4.6,8.2,0 3002 | -------------------------------------------------------------------------------- /00_python_into.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "733f8cec", 6 | "metadata": { 7 | "id": "733f8cec" 8 | }, 9 | "source": [ 10 | "# Python Tutorial" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "id": "b0c8be96", 16 | "metadata": {}, 17 | "source": [ 18 | "Inspired by stanford cs224n" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "347cd487", 24 | "metadata": { 25 | "id": "347cd487" 26 | }, 27 | "source": [ 28 | "## Collections" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "id": "e691f94d", 34 | "metadata": { 35 | "id": "e691f94d" 36 | }, 37 | "source": [ 38 | "Python has several built-in types that are useful for storing and manipulating data: list, tuple, dict. Here is the official Python documentation on these types (and many others): https://docs.python.org/3/library/stdtypes.html." 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "id": "635401d7", 44 | "metadata": { 45 | "id": "635401d7" 46 | }, 47 | "source": [ 48 | "### Lists" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "id": "ce42dfd9", 54 | "metadata": { 55 | "id": "ce42dfd9" 56 | }, 57 | "source": [ 58 | "Lists are mutable arrays. Let's see how they work." 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 1, 64 | "id": "3f24605e", 65 | "metadata": { 66 | "id": "3f24605e" 67 | }, 68 | "outputs": [], 69 | "source": [ 70 | "names = [\"Zach\", \"Jay\"]" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 2, 76 | "id": "ae2fb323", 77 | "metadata": { 78 | "colab": { 79 | "base_uri": "https://localhost:8080/" 80 | }, 81 | "id": "ae2fb323", 82 | "outputId": "504fa423-23f8-42f9-9de1-183600722e3e" 83 | }, 84 | "outputs": [ 85 | { 86 | "name": "stdout", 87 | "output_type": "stream", 88 | "text": [ 89 | "Zach\n" 90 | ] 91 | } 92 | ], 93 | "source": [ 94 | "# Index into list by index\n", 95 | "print(names[0])" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": 3, 101 | "id": "64066853", 102 | "metadata": { 103 | "colab": { 104 | "base_uri": "https://localhost:8080/" 105 | }, 106 | "id": "64066853", 107 | "outputId": "4de8cc78-90ae-496a-9960-32b2bca0efcb" 108 | }, 109 | "outputs": [ 110 | { 111 | "name": "stdout", 112 | "output_type": "stream", 113 | "text": [ 114 | "['Zach', 'Jay', 'Richard']\n" 115 | ] 116 | } 117 | ], 118 | "source": [ 119 | "# Append to list (appends to end of list)\n", 120 | "names.append(\"Richard\")\n", 121 | "print(names)" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 4, 127 | "id": "357799cc", 128 | "metadata": { 129 | "colab": { 130 | "base_uri": "https://localhost:8080/" 131 | }, 132 | "id": "357799cc", 133 | "outputId": "0d92d03d-3a15-4ef6-83a7-96d6e6f36c61" 134 | }, 135 | "outputs": [ 136 | { 137 | "name": "stdout", 138 | "output_type": "stream", 139 | "text": [ 140 | "3\n" 141 | ] 142 | } 143 | ], 144 | "source": [ 145 | "# Get length of list\n", 146 | "print(len(names))" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 5, 152 | "id": "8977adcf", 153 | "metadata": { 154 | "colab": { 155 | "base_uri": "https://localhost:8080/" 156 | }, 157 | "id": "8977adcf", 158 | "outputId": "74b3cbe0-a3c6-4aaf-90b8-3f4335abe8c0" 159 | }, 160 | "outputs": [ 161 | { 162 | "name": "stdout", 163 | "output_type": "stream", 164 | "text": [ 165 | "['Zach', 'Jay', 'Richard', 'Abi', 'Kevin']\n" 166 | ] 167 | } 168 | ], 169 | "source": [ 170 | "# Concatenate two lists\n", 171 | "# += operator is a short hand for list1 = list1 + list2 (can also be used for -, *, / and on other types of variables)\n", 172 | "names += [\"Abi\", \"Kevin\"]\n", 173 | "print(names)" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": 6, 179 | "id": "57c178a7", 180 | "metadata": { 181 | "id": "57c178a7" 182 | }, 183 | "outputs": [], 184 | "source": [ 185 | "# Two ways to create an empty list\n", 186 | "more_names = []\n", 187 | "more_names = list()" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": 7, 193 | "id": "7913fce7", 194 | "metadata": { 195 | "colab": { 196 | "base_uri": "https://localhost:8080/" 197 | }, 198 | "id": "7913fce7", 199 | "outputId": "0f91fe15-6e63-4894-a4dc-87ea34ccb531", 200 | "scrolled": true 201 | }, 202 | "outputs": [ 203 | { 204 | "name": "stdout", 205 | "output_type": "stream", 206 | "text": [ 207 | "[1, ['hi', 'bye'], -0.12, None]\n" 208 | ] 209 | } 210 | ], 211 | "source": [ 212 | "# Create a list that contains different data types, this is allowed in Python\n", 213 | "stuff = [1, [\"hi\", \"bye\"], -0.12, None]\n", 214 | "print(stuff)" 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "id": "68682c20", 220 | "metadata": { 221 | "id": "68682c20" 222 | }, 223 | "source": [ 224 | "List slicing is a useful way to access a slice of elements in a list." 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 8, 230 | "id": "8fc049ef", 231 | "metadata": { 232 | "colab": { 233 | "base_uri": "https://localhost:8080/" 234 | }, 235 | "id": "8fc049ef", 236 | "outputId": "37a1b397-b34f-4f07-82a2-5392bd614ea3" 237 | }, 238 | "outputs": [ 239 | { 240 | "name": "stdout", 241 | "output_type": "stream", 242 | "text": [ 243 | "[0, 1, 2]\n" 244 | ] 245 | } 246 | ], 247 | "source": [ 248 | "numbers = [0, 1, 2, 3, 4, 5, 6]\n", 249 | "\n", 250 | "# Slices from start index (inclusive) to end index (exclusive)\n", 251 | "print(numbers[0:3])" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 9, 257 | "id": "3e34a509", 258 | "metadata": { 259 | "colab": { 260 | "base_uri": "https://localhost:8080/" 261 | }, 262 | "id": "3e34a509", 263 | "outputId": "764bdcdb-794b-48e7-d12b-1095e91b0cbf" 264 | }, 265 | "outputs": [ 266 | { 267 | "name": "stdout", 268 | "output_type": "stream", 269 | "text": [ 270 | "[0, 1, 2]\n", 271 | "[5, 6]\n" 272 | ] 273 | } 274 | ], 275 | "source": [ 276 | "# When start index is not specified, it is start of list\n", 277 | "# When end index is not specified, it is end of list\n", 278 | "print(numbers[:3])\n", 279 | "print(numbers[5:])" 280 | ] 281 | }, 282 | { 283 | "cell_type": "code", 284 | "execution_count": 10, 285 | "id": "813da35a", 286 | "metadata": { 287 | "colab": { 288 | "base_uri": "https://localhost:8080/" 289 | }, 290 | "id": "813da35a", 291 | "outputId": "bc547329-e265-4659-82ef-e30b0ef409fd" 292 | }, 293 | "outputs": [ 294 | { 295 | "name": "stdout", 296 | "output_type": "stream", 297 | "text": [ 298 | "[0, 1, 2, 3, 4, 5, 6]\n" 299 | ] 300 | } 301 | ], 302 | "source": [ 303 | "# : takes the slice of all elements along a dimension, is very useful when working with numpy arrays\n", 304 | "print(numbers[:])" 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": 11, 310 | "id": "eaa197af", 311 | "metadata": { 312 | "colab": { 313 | "base_uri": "https://localhost:8080/" 314 | }, 315 | "id": "eaa197af", 316 | "outputId": "4c1738c0-3cc2-46a5-ea02-ae37f426f6ae" 317 | }, 318 | "outputs": [ 319 | { 320 | "name": "stdout", 321 | "output_type": "stream", 322 | "text": [ 323 | "6\n", 324 | "[4, 5, 6]\n", 325 | "[3, 4]\n" 326 | ] 327 | } 328 | ], 329 | "source": [ 330 | "# Negative index wraps around, start counting from the end of list\n", 331 | "print(numbers[-1])\n", 332 | "print(numbers[-3:])\n", 333 | "print(numbers[3:-2])" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "id": "22371049", 339 | "metadata": { 340 | "id": "22371049" 341 | }, 342 | "source": [ 343 | "### Tuples" 344 | ] 345 | }, 346 | { 347 | "cell_type": "markdown", 348 | "id": "bfca6098", 349 | "metadata": { 350 | "id": "bfca6098" 351 | }, 352 | "source": [ 353 | "Tuples are immutable arrays. Let's see how they work." 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 12, 359 | "id": "b542e470", 360 | "metadata": { 361 | "id": "b542e470" 362 | }, 363 | "outputs": [], 364 | "source": [ 365 | "# Use parentheses for tuples, square brackets for lists\n", 366 | "names = (\"Zach\", \"Jay\")" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 13, 372 | "id": "3906a033", 373 | "metadata": { 374 | "colab": { 375 | "base_uri": "https://localhost:8080/" 376 | }, 377 | "id": "3906a033", 378 | "outputId": "d589ddd8-c62f-4f23-8790-9b9f9dd2b744" 379 | }, 380 | "outputs": [ 381 | { 382 | "name": "stdout", 383 | "output_type": "stream", 384 | "text": [ 385 | "Zach\n", 386 | "2\n" 387 | ] 388 | } 389 | ], 390 | "source": [ 391 | "# Syntax for accessing an element and getting length are the same as lists\n", 392 | "print(names[0])\n", 393 | "print(len(names))" 394 | ] 395 | }, 396 | { 397 | "cell_type": "code", 398 | "execution_count": 14, 399 | "id": "8799a4c5", 400 | "metadata": { 401 | "colab": { 402 | "base_uri": "https://localhost:8080/", 403 | "height": 182 404 | }, 405 | "id": "8799a4c5", 406 | "outputId": "d85ff2f2-9d9c-40ee-bda3-5dbcb4b5841e" 407 | }, 408 | "outputs": [ 409 | { 410 | "ename": "TypeError", 411 | "evalue": "'tuple' object does not support item assignment", 412 | "output_type": "error", 413 | "traceback": [ 414 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 415 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 416 | "Cell \u001b[1;32mIn[14], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# But unlike lists, tuples do not support item re-assignment\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[43mnames\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRichard\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", 417 | "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" 418 | ] 419 | } 420 | ], 421 | "source": [ 422 | "# But unlike lists, tuples do not support item re-assignment\n", 423 | "names[0] = \"Richard\"" 424 | ] 425 | }, 426 | { 427 | "cell_type": "code", 428 | "execution_count": 15, 429 | "id": "9918ac4b", 430 | "metadata": { 431 | "colab": { 432 | "base_uri": "https://localhost:8080/" 433 | }, 434 | "id": "9918ac4b", 435 | "outputId": "5df94620-0758-4a17-9b78-11840d7ed227" 436 | }, 437 | "outputs": [ 438 | { 439 | "name": "stdout", 440 | "output_type": "stream", 441 | "text": [ 442 | "()\n", 443 | "(10,)\n" 444 | ] 445 | } 446 | ], 447 | "source": [ 448 | "# Create an empty tuple\n", 449 | "empty = tuple()\n", 450 | "print(empty)\n", 451 | "\n", 452 | "# Create a tuple with a single item, the comma is important\n", 453 | "single = (10,)\n", 454 | "print(single)" 455 | ] 456 | }, 457 | { 458 | "cell_type": "markdown", 459 | "id": "00800704", 460 | "metadata": { 461 | "id": "00800704" 462 | }, 463 | "source": [ 464 | "## Dictionary" 465 | ] 466 | }, 467 | { 468 | "cell_type": "markdown", 469 | "id": "8111c6c3", 470 | "metadata": { 471 | "id": "8111c6c3" 472 | }, 473 | "source": [ 474 | "Dictionaries are hash maps. Let's see how they work." 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "execution_count": 16, 480 | "id": "646bda2f", 481 | "metadata": { 482 | "id": "646bda2f" 483 | }, 484 | "outputs": [], 485 | "source": [ 486 | "# Two ways to create an empty dictionary\n", 487 | "phonebook = {}\n", 488 | "phonebook = dict()" 489 | ] 490 | }, 491 | { 492 | "cell_type": "code", 493 | "execution_count": 17, 494 | "id": "65c67196", 495 | "metadata": { 496 | "id": "65c67196" 497 | }, 498 | "outputs": [], 499 | "source": [ 500 | "# Create dictionary with one item\n", 501 | "phonebook = {\"Zach\": \"12-37\"}\n", 502 | "# Add another item\n", 503 | "phonebook[\"Jay\"] = \"34-23\"" 504 | ] 505 | }, 506 | { 507 | "cell_type": "code", 508 | "execution_count": 18, 509 | "id": "1bc431d9", 510 | "metadata": { 511 | "colab": { 512 | "base_uri": "https://localhost:8080/" 513 | }, 514 | "id": "1bc431d9", 515 | "outputId": "f854999e-2bf3-4ad9-af67-0b9f214bf143" 516 | }, 517 | "outputs": [ 518 | { 519 | "name": "stdout", 520 | "output_type": "stream", 521 | "text": [ 522 | "True\n", 523 | "False\n" 524 | ] 525 | } 526 | ], 527 | "source": [ 528 | "# Check if a key is in the dictionary\n", 529 | "print(\"Zach\" in phonebook)\n", 530 | "print(\"Kevin\" in phonebook)" 531 | ] 532 | }, 533 | { 534 | "cell_type": "code", 535 | "execution_count": 19, 536 | "id": "87018123", 537 | "metadata": { 538 | "colab": { 539 | "base_uri": "https://localhost:8080/" 540 | }, 541 | "id": "87018123", 542 | "outputId": "6706a4e5-aec7-40a7-9d1f-915558b9a582" 543 | }, 544 | "outputs": [ 545 | { 546 | "name": "stdout", 547 | "output_type": "stream", 548 | "text": [ 549 | "34-23\n" 550 | ] 551 | } 552 | ], 553 | "source": [ 554 | "# Get corresponding value for a key\n", 555 | "print(phonebook[\"Jay\"])" 556 | ] 557 | }, 558 | { 559 | "cell_type": "code", 560 | "execution_count": 20, 561 | "id": "18555a3a", 562 | "metadata": { 563 | "colab": { 564 | "base_uri": "https://localhost:8080/" 565 | }, 566 | "id": "18555a3a", 567 | "outputId": "def9ea35-d497-4278-ca9e-1777542a7357" 568 | }, 569 | "outputs": [ 570 | { 571 | "name": "stdout", 572 | "output_type": "stream", 573 | "text": [ 574 | "{'Jay': '34-23'}\n" 575 | ] 576 | } 577 | ], 578 | "source": [ 579 | "# Delete an item\n", 580 | "del phonebook[\"Zach\"]\n", 581 | "print(phonebook)" 582 | ] 583 | }, 584 | { 585 | "cell_type": "markdown", 586 | "id": "60aceb86", 587 | "metadata": { 588 | "id": "60aceb86" 589 | }, 590 | "source": [ 591 | "## Loops" 592 | ] 593 | }, 594 | { 595 | "cell_type": "code", 596 | "execution_count": 21, 597 | "id": "f7189f9d", 598 | "metadata": { 599 | "colab": { 600 | "base_uri": "https://localhost:8080/" 601 | }, 602 | "id": "f7189f9d", 603 | "outputId": "fca407da-ccfc-4c8d-b3f8-2cb056ee16e7" 604 | }, 605 | "outputs": [ 606 | { 607 | "name": "stdout", 608 | "output_type": "stream", 609 | "text": [ 610 | "0\n", 611 | "1\n", 612 | "2\n", 613 | "3\n", 614 | "4\n" 615 | ] 616 | } 617 | ], 618 | "source": [ 619 | "# Basic for loop\n", 620 | "for i in range(5):\n", 621 | " print(i)" 622 | ] 623 | }, 624 | { 625 | "cell_type": "code", 626 | "execution_count": 22, 627 | "id": "10ae15db", 628 | "metadata": { 629 | "colab": { 630 | "base_uri": "https://localhost:8080/" 631 | }, 632 | "id": "10ae15db", 633 | "outputId": "04a5147c-fc24-4376-9f87-31cc7d0ef041" 634 | }, 635 | "outputs": [ 636 | { 637 | "name": "stdout", 638 | "output_type": "stream", 639 | "text": [ 640 | "Zach\n", 641 | "Jay\n", 642 | "Richard\n" 643 | ] 644 | } 645 | ], 646 | "source": [ 647 | "# To iterate over a list\n", 648 | "names = [\"Zach\", \"Jay\", \"Richard\"]\n", 649 | "for name in names:\n", 650 | " print(name)" 651 | ] 652 | }, 653 | { 654 | "cell_type": "code", 655 | "execution_count": 23, 656 | "id": "00d5035b", 657 | "metadata": { 658 | "colab": { 659 | "base_uri": "https://localhost:8080/" 660 | }, 661 | "id": "00d5035b", 662 | "outputId": "e5f8d3f3-02c5-48fe-833e-93123a3ad5f5" 663 | }, 664 | "outputs": [ 665 | { 666 | "name": "stdout", 667 | "output_type": "stream", 668 | "text": [ 669 | "0 Zach\n", 670 | "1 Jay\n", 671 | "2 Richard\n", 672 | "---\n", 673 | "0 Zach\n", 674 | "1 Jay\n", 675 | "2 Richard\n" 676 | ] 677 | } 678 | ], 679 | "source": [ 680 | "# To iterate over indices and values in a list\n", 681 | "# Way 1\n", 682 | "for i in range(len(names)):\n", 683 | " print(i, names[i])\n", 684 | "\n", 685 | "print(\"---\")\n", 686 | "\n", 687 | "# Way 2\n", 688 | "for i, name in enumerate(names):\n", 689 | " print(i, name)" 690 | ] 691 | }, 692 | { 693 | "cell_type": "code", 694 | "execution_count": 24, 695 | "id": "f18b7ce6", 696 | "metadata": { 697 | "colab": { 698 | "base_uri": "https://localhost:8080/" 699 | }, 700 | "id": "f18b7ce6", 701 | "outputId": "68d2057f-4d63-4a7f-c5a2-359add5a71c3" 702 | }, 703 | "outputs": [ 704 | { 705 | "name": "stdout", 706 | "output_type": "stream", 707 | "text": [ 708 | "Zach\n", 709 | "Jay\n", 710 | "---\n", 711 | "12-37\n", 712 | "34-23\n", 713 | "---\n", 714 | "Zach 12-37\n", 715 | "Jay 34-23\n" 716 | ] 717 | } 718 | ], 719 | "source": [ 720 | "# To iterate over a dictionary\n", 721 | "phonebook = {\"Zach\": \"12-37\", \"Jay\": \"34-23\"}\n", 722 | "\n", 723 | "# Iterate over keys\n", 724 | "for name in phonebook:\n", 725 | " print(name)\n", 726 | "\n", 727 | "print(\"---\")\n", 728 | "\n", 729 | "# Iterate over values\n", 730 | "for number in phonebook.values():\n", 731 | " print(number)\n", 732 | "\n", 733 | "print(\"---\")\n", 734 | "\n", 735 | "# Iterate over keys and values\n", 736 | "for name, number in phonebook.items():\n", 737 | " print(name, number)" 738 | ] 739 | }, 740 | { 741 | "cell_type": "markdown", 742 | "id": "df7a1def", 743 | "metadata": {}, 744 | "source": [ 745 | "List comprehensions" 746 | ] 747 | }, 748 | { 749 | "cell_type": "code", 750 | "execution_count": 25, 751 | "id": "4bf78097", 752 | "metadata": {}, 753 | "outputs": [ 754 | { 755 | "name": "stdout", 756 | "output_type": "stream", 757 | "text": [ 758 | "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" 759 | ] 760 | } 761 | ], 762 | "source": [ 763 | "l = [i for i in range(10)]\n", 764 | "print(l)" 765 | ] 766 | }, 767 | { 768 | "cell_type": "code", 769 | "execution_count": 26, 770 | "id": "e1b81b7c", 771 | "metadata": {}, 772 | "outputs": [ 773 | { 774 | "name": "stdout", 775 | "output_type": "stream", 776 | "text": [ 777 | "[0, 0, 1, 2, 2, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18]\n" 778 | ] 779 | } 780 | ], 781 | "source": [ 782 | "l = [i * j for i in range(10) \n", 783 | " for j in range(1, 3)]\n", 784 | "print(l)" 785 | ] 786 | }, 787 | { 788 | "cell_type": "markdown", 789 | "id": "35da460a", 790 | "metadata": {}, 791 | "source": [ 792 | "## Functions" 793 | ] 794 | }, 795 | { 796 | "cell_type": "code", 797 | "execution_count": 27, 798 | "id": "1e9387d6", 799 | "metadata": {}, 800 | "outputs": [], 801 | "source": [ 802 | "def foo(arg1, arg2='default value'):\n", 803 | " return arg1, arg2" 804 | ] 805 | }, 806 | { 807 | "cell_type": "code", 808 | "execution_count": 28, 809 | "id": "f6380944", 810 | "metadata": {}, 811 | "outputs": [ 812 | { 813 | "data": { 814 | "text/plain": [ 815 | "(5, 'default value')" 816 | ] 817 | }, 818 | "execution_count": 28, 819 | "metadata": {}, 820 | "output_type": "execute_result" 821 | } 822 | ], 823 | "source": [ 824 | "foo(5)" 825 | ] 826 | }, 827 | { 828 | "cell_type": "code", 829 | "execution_count": 29, 830 | "id": "0456a49f", 831 | "metadata": {}, 832 | "outputs": [], 833 | "source": [ 834 | "# Type hints are optional and are just that hints\n", 835 | "# There is no obligation to actually follow them\n", 836 | "def bar(arg1: int, arg2: str='default value') -> tuple[int, str]:\n", 837 | " return arg1, arg2" 838 | ] 839 | }, 840 | { 841 | "cell_type": "code", 842 | "execution_count": 30, 843 | "id": "47d1fb74", 844 | "metadata": {}, 845 | "outputs": [ 846 | { 847 | "data": { 848 | "text/plain": [ 849 | "(42, 'meaning')" 850 | ] 851 | }, 852 | "execution_count": 30, 853 | "metadata": {}, 854 | "output_type": "execute_result" 855 | } 856 | ], 857 | "source": [ 858 | "bar(42, 'meaning')" 859 | ] 860 | }, 861 | { 862 | "cell_type": "code", 863 | "execution_count": 31, 864 | "id": "a62444e4", 865 | "metadata": {}, 866 | "outputs": [ 867 | { 868 | "data": { 869 | "text/plain": [ 870 | "('meaning', 42)" 871 | ] 872 | }, 873 | "execution_count": 31, 874 | "metadata": {}, 875 | "output_type": "execute_result" 876 | } 877 | ], 878 | "source": [ 879 | "bar('meaning', 42)" 880 | ] 881 | }, 882 | { 883 | "cell_type": "markdown", 884 | "id": "a3bcc5a8", 885 | "metadata": {}, 886 | "source": [ 887 | "#### `*args` & `**kwargs`" 888 | ] 889 | }, 890 | { 891 | "cell_type": "code", 892 | "execution_count": 32, 893 | "id": "e0f6cd7f", 894 | "metadata": {}, 895 | "outputs": [], 896 | "source": [ 897 | "def bar(*args, **kwargs):\n", 898 | " print(f'args = {args} {type(args)}')\n", 899 | " print(f'kwargs = {kwargs} {type(kwargs)}')" 900 | ] 901 | }, 902 | { 903 | "cell_type": "code", 904 | "execution_count": 33, 905 | "id": "01ad2f23", 906 | "metadata": {}, 907 | "outputs": [ 908 | { 909 | "name": "stdout", 910 | "output_type": "stream", 911 | "text": [ 912 | "args = (4, 2, 'AI') \n", 913 | "kwargs = {'animals': ['pandas', 'cats', ''], 'people': {'Knut', 'Curry', 'Dijkstra'}} \n" 914 | ] 915 | } 916 | ], 917 | "source": [ 918 | "bar(4, 2, 'AI',\n", 919 | " animals=['pandas', 'cats', ''],\n", 920 | " people={'Knut', 'Dijkstra', 'Curry'})" 921 | ] 922 | }, 923 | { 924 | "cell_type": "markdown", 925 | "id": "089dd810", 926 | "metadata": {}, 927 | "source": [ 928 | "### Higher-Order Functions: Map Filter And Zip" 929 | ] 930 | }, 931 | { 932 | "cell_type": "code", 933 | "execution_count": 34, 934 | "id": "5a568233", 935 | "metadata": {}, 936 | "outputs": [], 937 | "source": [ 938 | "def fact(n):\n", 939 | " return 1 if n < 2 else n * fact(n-1)" 940 | ] 941 | }, 942 | { 943 | "cell_type": "code", 944 | "execution_count": 35, 945 | "id": "f60d3779", 946 | "metadata": {}, 947 | "outputs": [ 948 | { 949 | "data": { 950 | "text/plain": [ 951 | "" 952 | ] 953 | }, 954 | "execution_count": 35, 955 | "metadata": {}, 956 | "output_type": "execute_result" 957 | } 958 | ], 959 | "source": [ 960 | "map(fact, [1, 2, 3, 4, 5])" 961 | ] 962 | }, 963 | { 964 | "cell_type": "code", 965 | "execution_count": 36, 966 | "id": "c95627b4", 967 | "metadata": {}, 968 | "outputs": [ 969 | { 970 | "name": "stdout", 971 | "output_type": "stream", 972 | "text": [ 973 | "[1, 2, 6, 24, 120]\n" 974 | ] 975 | } 976 | ], 977 | "source": [ 978 | "l = list(map(fact, [1, 2, 3, 4, 5]))\n", 979 | "print(l)" 980 | ] 981 | }, 982 | { 983 | "cell_type": "code", 984 | "execution_count": 37, 985 | "id": "28b953db", 986 | "metadata": {}, 987 | "outputs": [ 988 | { 989 | "data": { 990 | "text/plain": [ 991 | "(x)>" 992 | ] 993 | }, 994 | "execution_count": 37, 995 | "metadata": {}, 996 | "output_type": "execute_result" 997 | } 998 | ], 999 | "source": [ 1000 | "lambda x : x + 1" 1001 | ] 1002 | }, 1003 | { 1004 | "cell_type": "code", 1005 | "execution_count": 38, 1006 | "id": "5d282a53", 1007 | "metadata": {}, 1008 | "outputs": [ 1009 | { 1010 | "data": { 1011 | "text/plain": [ 1012 | "2" 1013 | ] 1014 | }, 1015 | "execution_count": 38, 1016 | "metadata": {}, 1017 | "output_type": "execute_result" 1018 | } 1019 | ], 1020 | "source": [ 1021 | "(lambda x : x + 1)(1)" 1022 | ] 1023 | }, 1024 | { 1025 | "cell_type": "code", 1026 | "execution_count": 39, 1027 | "id": "c33a4436", 1028 | "metadata": {}, 1029 | "outputs": [ 1030 | { 1031 | "name": "stdout", 1032 | "output_type": "stream", 1033 | "text": [ 1034 | "[11, 22, 33, 44, 55]\n" 1035 | ] 1036 | } 1037 | ], 1038 | "source": [ 1039 | "l1 = [1, 2, 3, 4, 5]\n", 1040 | "l2 = [10, 20, 30, 40, 50]\n", 1041 | "\n", 1042 | "f = lambda x, y: x + y\n", 1043 | "\n", 1044 | "m = map(f, l1, l2)\n", 1045 | "print(list(m))" 1046 | ] 1047 | }, 1048 | { 1049 | "cell_type": "code", 1050 | "execution_count": 40, 1051 | "id": "28ae836b", 1052 | "metadata": {}, 1053 | "outputs": [ 1054 | { 1055 | "name": "stdout", 1056 | "output_type": "stream", 1057 | "text": [ 1058 | "[2, 4, 6, 8]\n" 1059 | ] 1060 | } 1061 | ], 1062 | "source": [ 1063 | "l = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n", 1064 | "result = filter(lambda x: x % 2 == 0, l)\n", 1065 | "print(list(result))" 1066 | ] 1067 | }, 1068 | { 1069 | "cell_type": "code", 1070 | "execution_count": 41, 1071 | "id": "b4bbc733", 1072 | "metadata": {}, 1073 | "outputs": [ 1074 | { 1075 | "data": { 1076 | "text/plain": [ 1077 | "[(1, 'a'), (2, 'b'), (3, 'c')]" 1078 | ] 1079 | }, 1080 | "execution_count": 41, 1081 | "metadata": {}, 1082 | "output_type": "execute_result" 1083 | } 1084 | ], 1085 | "source": [ 1086 | "l1 = 1, 2, 3\n", 1087 | "l2 = 'a', 'b', 'c'\n", 1088 | "list(zip(l1, l2))" 1089 | ] 1090 | }, 1091 | { 1092 | "cell_type": "markdown", 1093 | "id": "b8308a2e", 1094 | "metadata": {}, 1095 | "source": [ 1096 | "### Closures\n", 1097 | "\n", 1098 | "A closure is poor mans object and an object is a poor mans closure" 1099 | ] 1100 | }, 1101 | { 1102 | "cell_type": "code", 1103 | "execution_count": 42, 1104 | "id": "4012856e", 1105 | "metadata": {}, 1106 | "outputs": [], 1107 | "source": [ 1108 | "def outer():\n", 1109 | " x = 'python'\n", 1110 | " def inner():\n", 1111 | " print(x)\n", 1112 | " return inner" 1113 | ] 1114 | }, 1115 | { 1116 | "cell_type": "code", 1117 | "execution_count": 43, 1118 | "id": "d3bebaf5", 1119 | "metadata": {}, 1120 | "outputs": [], 1121 | "source": [ 1122 | "fn = outer()" 1123 | ] 1124 | }, 1125 | { 1126 | "cell_type": "code", 1127 | "execution_count": 44, 1128 | "id": "371b08ee", 1129 | "metadata": {}, 1130 | "outputs": [ 1131 | { 1132 | "name": "stdout", 1133 | "output_type": "stream", 1134 | "text": [ 1135 | "python\n" 1136 | ] 1137 | } 1138 | ], 1139 | "source": [ 1140 | "fn()" 1141 | ] 1142 | }, 1143 | { 1144 | "cell_type": "code", 1145 | "execution_count": 45, 1146 | "id": "5604df96", 1147 | "metadata": {}, 1148 | "outputs": [], 1149 | "source": [ 1150 | "def outer():\n", 1151 | " x = [1, 2, 3]\n", 1152 | " print('outer:', hex(id(x)))\n", 1153 | " def inner():\n", 1154 | " print('inner:', hex(id(x)))\n", 1155 | " print(x)\n", 1156 | " return inner" 1157 | ] 1158 | }, 1159 | { 1160 | "cell_type": "code", 1161 | "execution_count": 46, 1162 | "id": "3fd4af17", 1163 | "metadata": {}, 1164 | "outputs": [ 1165 | { 1166 | "name": "stdout", 1167 | "output_type": "stream", 1168 | "text": [ 1169 | "outer: 0x1ff0a34df00\n" 1170 | ] 1171 | } 1172 | ], 1173 | "source": [ 1174 | "fn = outer()" 1175 | ] 1176 | }, 1177 | { 1178 | "cell_type": "code", 1179 | "execution_count": 47, 1180 | "id": "8dff2921", 1181 | "metadata": {}, 1182 | "outputs": [ 1183 | { 1184 | "name": "stdout", 1185 | "output_type": "stream", 1186 | "text": [ 1187 | "inner: 0x1ff0a34df00\n", 1188 | "[1, 2, 3]\n" 1189 | ] 1190 | } 1191 | ], 1192 | "source": [ 1193 | "fn()" 1194 | ] 1195 | }, 1196 | { 1197 | "cell_type": "code", 1198 | "execution_count": 48, 1199 | "id": "9edfa671", 1200 | "metadata": {}, 1201 | "outputs": [], 1202 | "source": [ 1203 | "def adder(n):\n", 1204 | " def inner(x):\n", 1205 | " return x + n\n", 1206 | " return inner" 1207 | ] 1208 | }, 1209 | { 1210 | "cell_type": "code", 1211 | "execution_count": 49, 1212 | "id": "2aaf821c", 1213 | "metadata": {}, 1214 | "outputs": [], 1215 | "source": [ 1216 | "def create_adders():\n", 1217 | " adders = []\n", 1218 | " for n in range(1, 5):\n", 1219 | " adders.append(lambda x: x + n)\n", 1220 | " return adders" 1221 | ] 1222 | }, 1223 | { 1224 | "cell_type": "code", 1225 | "execution_count": 50, 1226 | "id": "e8f21701", 1227 | "metadata": {}, 1228 | "outputs": [], 1229 | "source": [ 1230 | "adders = create_adders()" 1231 | ] 1232 | }, 1233 | { 1234 | "cell_type": "code", 1235 | "execution_count": 51, 1236 | "id": "83194b45", 1237 | "metadata": {}, 1238 | "outputs": [ 1239 | { 1240 | "data": { 1241 | "text/plain": [ 1242 | "[.(x)>,\n", 1243 | " .(x)>,\n", 1244 | " .(x)>,\n", 1245 | " .(x)>]" 1246 | ] 1247 | }, 1248 | "execution_count": 51, 1249 | "metadata": {}, 1250 | "output_type": "execute_result" 1251 | } 1252 | ], 1253 | "source": [ 1254 | "adders" 1255 | ] 1256 | }, 1257 | { 1258 | "cell_type": "code", 1259 | "execution_count": 52, 1260 | "id": "57d92c0d", 1261 | "metadata": {}, 1262 | "outputs": [ 1263 | { 1264 | "data": { 1265 | "text/plain": [ 1266 | "(14, 14)" 1267 | ] 1268 | }, 1269 | "execution_count": 52, 1270 | "metadata": {}, 1271 | "output_type": "execute_result" 1272 | } 1273 | ], 1274 | "source": [ 1275 | "adders[0](10), adders[1](10)" 1276 | ] 1277 | }, 1278 | { 1279 | "cell_type": "code", 1280 | "execution_count": 53, 1281 | "id": "191820cb", 1282 | "metadata": {}, 1283 | "outputs": [], 1284 | "source": [ 1285 | "def create_adders():\n", 1286 | " adders = []\n", 1287 | " for n in range(1, 5):\n", 1288 | " adders.append(lambda x, step=n: x + step)\n", 1289 | " return adders" 1290 | ] 1291 | }, 1292 | { 1293 | "cell_type": "code", 1294 | "execution_count": 54, 1295 | "id": "02b9503e", 1296 | "metadata": {}, 1297 | "outputs": [], 1298 | "source": [ 1299 | "adders_2 = create_adders()" 1300 | ] 1301 | }, 1302 | { 1303 | "cell_type": "code", 1304 | "execution_count": 55, 1305 | "id": "b27af71a", 1306 | "metadata": {}, 1307 | "outputs": [ 1308 | { 1309 | "data": { 1310 | "text/plain": [ 1311 | "(11, 12)" 1312 | ] 1313 | }, 1314 | "execution_count": 55, 1315 | "metadata": {}, 1316 | "output_type": "execute_result" 1317 | } 1318 | ], 1319 | "source": [ 1320 | "adders_2[0](10), adders_2[1](10)" 1321 | ] 1322 | }, 1323 | { 1324 | "cell_type": "markdown", 1325 | "id": "1be6dab9", 1326 | "metadata": {}, 1327 | "source": [ 1328 | "### Decorators" 1329 | ] 1330 | }, 1331 | { 1332 | "cell_type": "code", 1333 | "execution_count": 56, 1334 | "id": "3d5b3c2f", 1335 | "metadata": {}, 1336 | "outputs": [], 1337 | "source": [ 1338 | "def counter(fn):\n", 1339 | " count = 0\n", 1340 | " \n", 1341 | " def inner(*args, **kwargs):\n", 1342 | " nonlocal count\n", 1343 | " count += 1\n", 1344 | " print(f'Function {fn.__name__} was called {count} times with args {args} and kwargs {kwargs}')\n", 1345 | " return fn(*args, **kwargs)\n", 1346 | " return inner" 1347 | ] 1348 | }, 1349 | { 1350 | "cell_type": "code", 1351 | "execution_count": 57, 1352 | "id": "36b2e2ef", 1353 | "metadata": {}, 1354 | "outputs": [], 1355 | "source": [ 1356 | "def add(a, b):\n", 1357 | " return a + b" 1358 | ] 1359 | }, 1360 | { 1361 | "cell_type": "code", 1362 | "execution_count": 58, 1363 | "id": "42508605", 1364 | "metadata": {}, 1365 | "outputs": [], 1366 | "source": [ 1367 | "add = counter(add)" 1368 | ] 1369 | }, 1370 | { 1371 | "cell_type": "code", 1372 | "execution_count": 59, 1373 | "id": "d3f59cd2", 1374 | "metadata": {}, 1375 | "outputs": [ 1376 | { 1377 | "name": "stdout", 1378 | "output_type": "stream", 1379 | "text": [ 1380 | "Function add was called 1 times with args (1, 2) and kwargs {}\n" 1381 | ] 1382 | }, 1383 | { 1384 | "data": { 1385 | "text/plain": [ 1386 | "3" 1387 | ] 1388 | }, 1389 | "execution_count": 59, 1390 | "metadata": {}, 1391 | "output_type": "execute_result" 1392 | } 1393 | ], 1394 | "source": [ 1395 | "add(1, 2)" 1396 | ] 1397 | }, 1398 | { 1399 | "cell_type": "code", 1400 | "execution_count": 60, 1401 | "id": "6813880f", 1402 | "metadata": {}, 1403 | "outputs": [ 1404 | { 1405 | "name": "stdout", 1406 | "output_type": "stream", 1407 | "text": [ 1408 | "Function add was called 2 times with args (1,) and kwargs {'b': 4}\n" 1409 | ] 1410 | }, 1411 | { 1412 | "data": { 1413 | "text/plain": [ 1414 | "5" 1415 | ] 1416 | }, 1417 | "execution_count": 60, 1418 | "metadata": {}, 1419 | "output_type": "execute_result" 1420 | } 1421 | ], 1422 | "source": [ 1423 | "add(1, b=4)" 1424 | ] 1425 | }, 1426 | { 1427 | "cell_type": "code", 1428 | "execution_count": 61, 1429 | "id": "f0c8f117", 1430 | "metadata": {}, 1431 | "outputs": [], 1432 | "source": [ 1433 | "@counter\n", 1434 | "def mult(a, b):\n", 1435 | " return a * b" 1436 | ] 1437 | }, 1438 | { 1439 | "cell_type": "code", 1440 | "execution_count": 62, 1441 | "id": "62c2aef7", 1442 | "metadata": {}, 1443 | "outputs": [ 1444 | { 1445 | "name": "stdout", 1446 | "output_type": "stream", 1447 | "text": [ 1448 | "Function mult was called 1 times with args (1, 2) and kwargs {}\n" 1449 | ] 1450 | }, 1451 | { 1452 | "data": { 1453 | "text/plain": [ 1454 | "2" 1455 | ] 1456 | }, 1457 | "execution_count": 62, 1458 | "metadata": {}, 1459 | "output_type": "execute_result" 1460 | } 1461 | ], 1462 | "source": [ 1463 | "mult(1, 2)" 1464 | ] 1465 | }, 1466 | { 1467 | "cell_type": "code", 1468 | "execution_count": 63, 1469 | "id": "bce45918", 1470 | "metadata": {}, 1471 | "outputs": [ 1472 | { 1473 | "name": "stdout", 1474 | "output_type": "stream", 1475 | "text": [ 1476 | "Function mult was called 2 times with args (4,) and kwargs {'b': 2}\n" 1477 | ] 1478 | }, 1479 | { 1480 | "data": { 1481 | "text/plain": [ 1482 | "8" 1483 | ] 1484 | }, 1485 | "execution_count": 63, 1486 | "metadata": {}, 1487 | "output_type": "execute_result" 1488 | } 1489 | ], 1490 | "source": [ 1491 | "mult(4, b=2)" 1492 | ] 1493 | }, 1494 | { 1495 | "cell_type": "code", 1496 | "execution_count": 64, 1497 | "id": "0e49f71c", 1498 | "metadata": {}, 1499 | "outputs": [], 1500 | "source": [ 1501 | "def fib(n):\n", 1502 | " print(f\"Calculating {n}\")\n", 1503 | " if n < 2:\n", 1504 | " return n\n", 1505 | " return fib(n-1) + fib(n-2)" 1506 | ] 1507 | }, 1508 | { 1509 | "cell_type": "code", 1510 | "execution_count": 65, 1511 | "id": "e4f99aee", 1512 | "metadata": {}, 1513 | "outputs": [ 1514 | { 1515 | "name": "stdout", 1516 | "output_type": "stream", 1517 | "text": [ 1518 | "Calculating 3\n", 1519 | "Calculating 2\n", 1520 | "Calculating 1\n", 1521 | "Calculating 0\n", 1522 | "Calculating 1\n" 1523 | ] 1524 | }, 1525 | { 1526 | "data": { 1527 | "text/plain": [ 1528 | "2" 1529 | ] 1530 | }, 1531 | "execution_count": 65, 1532 | "metadata": {}, 1533 | "output_type": "execute_result" 1534 | } 1535 | ], 1536 | "source": [ 1537 | "fib(3)" 1538 | ] 1539 | }, 1540 | { 1541 | "cell_type": "code", 1542 | "execution_count": 66, 1543 | "id": "82f18adf", 1544 | "metadata": {}, 1545 | "outputs": [ 1546 | { 1547 | "name": "stdout", 1548 | "output_type": "stream", 1549 | "text": [ 1550 | "Calculating 4\n", 1551 | "Calculating 3\n", 1552 | "Calculating 2\n", 1553 | "Calculating 1\n", 1554 | "Calculating 0\n", 1555 | "Calculating 1\n", 1556 | "Calculating 2\n", 1557 | "Calculating 1\n", 1558 | "Calculating 0\n" 1559 | ] 1560 | }, 1561 | { 1562 | "data": { 1563 | "text/plain": [ 1564 | "3" 1565 | ] 1566 | }, 1567 | "execution_count": 66, 1568 | "metadata": {}, 1569 | "output_type": "execute_result" 1570 | } 1571 | ], 1572 | "source": [ 1573 | "fib(4)" 1574 | ] 1575 | }, 1576 | { 1577 | "cell_type": "code", 1578 | "execution_count": 67, 1579 | "id": "5abaefd1", 1580 | "metadata": {}, 1581 | "outputs": [], 1582 | "source": [ 1583 | "from functools import wraps\n", 1584 | "\n", 1585 | "def memoize(fn):\n", 1586 | " cache = dict()\n", 1587 | " \n", 1588 | " @wraps(fn)\n", 1589 | " def inner(n):\n", 1590 | " if n not in cache:\n", 1591 | " cache[n] = fn(n)\n", 1592 | " return cache[n]\n", 1593 | " \n", 1594 | " return inner" 1595 | ] 1596 | }, 1597 | { 1598 | "cell_type": "code", 1599 | "execution_count": 68, 1600 | "id": "1787f8f1", 1601 | "metadata": {}, 1602 | "outputs": [], 1603 | "source": [ 1604 | "@memoize\n", 1605 | "def fib_memo(n):\n", 1606 | " print(f\"Calculating {n}\")\n", 1607 | " if n < 2:\n", 1608 | " return n\n", 1609 | " return fib_memo(n-1) + fib_memo(n-2)" 1610 | ] 1611 | }, 1612 | { 1613 | "cell_type": "code", 1614 | "execution_count": 69, 1615 | "id": "b80b604b", 1616 | "metadata": {}, 1617 | "outputs": [ 1618 | { 1619 | "name": "stdout", 1620 | "output_type": "stream", 1621 | "text": [ 1622 | "Calculating 3\n", 1623 | "Calculating 2\n", 1624 | "Calculating 1\n", 1625 | "Calculating 0\n" 1626 | ] 1627 | }, 1628 | { 1629 | "data": { 1630 | "text/plain": [ 1631 | "2" 1632 | ] 1633 | }, 1634 | "execution_count": 69, 1635 | "metadata": {}, 1636 | "output_type": "execute_result" 1637 | } 1638 | ], 1639 | "source": [ 1640 | "fib_memo(3)" 1641 | ] 1642 | }, 1643 | { 1644 | "cell_type": "code", 1645 | "execution_count": 70, 1646 | "id": "1c2f8e9d", 1647 | "metadata": {}, 1648 | "outputs": [ 1649 | { 1650 | "name": "stdout", 1651 | "output_type": "stream", 1652 | "text": [ 1653 | "Calculating 4\n" 1654 | ] 1655 | }, 1656 | { 1657 | "data": { 1658 | "text/plain": [ 1659 | "3" 1660 | ] 1661 | }, 1662 | "execution_count": 70, 1663 | "metadata": {}, 1664 | "output_type": "execute_result" 1665 | } 1666 | ], 1667 | "source": [ 1668 | "fib_memo(4)" 1669 | ] 1670 | }, 1671 | { 1672 | "cell_type": "code", 1673 | "execution_count": 71, 1674 | "id": "20e782b9", 1675 | "metadata": {}, 1676 | "outputs": [], 1677 | "source": [ 1678 | "from functools import lru_cache" 1679 | ] 1680 | }, 1681 | { 1682 | "cell_type": "code", 1683 | "execution_count": 72, 1684 | "id": "d267ab12", 1685 | "metadata": {}, 1686 | "outputs": [], 1687 | "source": [ 1688 | "@lru_cache(10)\n", 1689 | "def fib_memo_2(n):\n", 1690 | " print(f\"Calculating {n}\")\n", 1691 | " if n < 2:\n", 1692 | " return n\n", 1693 | " return fib_memo_2(n-1) + fib_memo_2(n-2)" 1694 | ] 1695 | }, 1696 | { 1697 | "cell_type": "code", 1698 | "execution_count": 73, 1699 | "id": "6e17756f", 1700 | "metadata": {}, 1701 | "outputs": [ 1702 | { 1703 | "name": "stdout", 1704 | "output_type": "stream", 1705 | "text": [ 1706 | "Calculating 1\n", 1707 | "Calculating 2\n", 1708 | "Calculating 0\n", 1709 | "Calculating 3\n" 1710 | ] 1711 | }, 1712 | { 1713 | "data": { 1714 | "text/plain": [ 1715 | "(1, 1, 2)" 1716 | ] 1717 | }, 1718 | "execution_count": 73, 1719 | "metadata": {}, 1720 | "output_type": "execute_result" 1721 | } 1722 | ], 1723 | "source": [ 1724 | "fib_memo_2(1), fib_memo_2(2), fib_memo_2(3)" 1725 | ] 1726 | }, 1727 | { 1728 | "cell_type": "code", 1729 | "execution_count": 74, 1730 | "id": "98d30af8", 1731 | "metadata": {}, 1732 | "outputs": [ 1733 | { 1734 | "name": "stdout", 1735 | "output_type": "stream", 1736 | "text": [ 1737 | "Calculating 10\n", 1738 | "Calculating 9\n", 1739 | "Calculating 8\n", 1740 | "Calculating 7\n", 1741 | "Calculating 6\n", 1742 | "Calculating 5\n", 1743 | "Calculating 4\n" 1744 | ] 1745 | }, 1746 | { 1747 | "data": { 1748 | "text/plain": [ 1749 | "55" 1750 | ] 1751 | }, 1752 | "execution_count": 74, 1753 | "metadata": {}, 1754 | "output_type": "execute_result" 1755 | } 1756 | ], 1757 | "source": [ 1758 | "fib_memo_2(10)" 1759 | ] 1760 | }, 1761 | { 1762 | "cell_type": "code", 1763 | "execution_count": 75, 1764 | "id": "205aae0e", 1765 | "metadata": {}, 1766 | "outputs": [ 1767 | { 1768 | "data": { 1769 | "text/plain": [ 1770 | "55" 1771 | ] 1772 | }, 1773 | "execution_count": 75, 1774 | "metadata": {}, 1775 | "output_type": "execute_result" 1776 | } 1777 | ], 1778 | "source": [ 1779 | "fib_memo_2(10)" 1780 | ] 1781 | }, 1782 | { 1783 | "cell_type": "markdown", 1784 | "id": "670e1839", 1785 | "metadata": {}, 1786 | "source": [ 1787 | "### Generators" 1788 | ] 1789 | }, 1790 | { 1791 | "cell_type": "code", 1792 | "execution_count": 76, 1793 | "id": "3999482e", 1794 | "metadata": {}, 1795 | "outputs": [], 1796 | "source": [ 1797 | "def even_numbers(start=2):\n", 1798 | " if start % 2 == 0:\n", 1799 | " number = start\n", 1800 | " else:\n", 1801 | " number = start + 1\n", 1802 | " while True:\n", 1803 | " yield number\n", 1804 | " number += 2" 1805 | ] 1806 | }, 1807 | { 1808 | "cell_type": "code", 1809 | "execution_count": 77, 1810 | "id": "4a9926e0", 1811 | "metadata": {}, 1812 | "outputs": [], 1813 | "source": [ 1814 | "evens = even_numbers(2)" 1815 | ] 1816 | }, 1817 | { 1818 | "cell_type": "code", 1819 | "execution_count": 78, 1820 | "id": "4cc37820", 1821 | "metadata": {}, 1822 | "outputs": [ 1823 | { 1824 | "data": { 1825 | "text/plain": [ 1826 | "(2, 4)" 1827 | ] 1828 | }, 1829 | "execution_count": 78, 1830 | "metadata": {}, 1831 | "output_type": "execute_result" 1832 | } 1833 | ], 1834 | "source": [ 1835 | "next(evens), next(evens) " 1836 | ] 1837 | }, 1838 | { 1839 | "cell_type": "code", 1840 | "execution_count": 79, 1841 | "id": "5baf0299", 1842 | "metadata": {}, 1843 | "outputs": [ 1844 | { 1845 | "name": "stdout", 1846 | "output_type": "stream", 1847 | "text": [ 1848 | "6\n", 1849 | "8\n", 1850 | "10\n", 1851 | "12\n", 1852 | "14\n", 1853 | "16\n" 1854 | ] 1855 | } 1856 | ], 1857 | "source": [ 1858 | "for i, el in enumerate(evens):\n", 1859 | " print(el)\n", 1860 | " if i == 5:\n", 1861 | " break" 1862 | ] 1863 | }, 1864 | { 1865 | "cell_type": "markdown", 1866 | "id": "ee076ecd", 1867 | "metadata": {}, 1868 | "source": [ 1869 | "## OOP" 1870 | ] 1871 | }, 1872 | { 1873 | "cell_type": "code", 1874 | "execution_count": 80, 1875 | "id": "24c19b07", 1876 | "metadata": {}, 1877 | "outputs": [], 1878 | "source": [ 1879 | "class Person:\n", 1880 | " def __init__(self, name):\n", 1881 | " self.name = name" 1882 | ] 1883 | }, 1884 | { 1885 | "cell_type": "code", 1886 | "execution_count": 81, 1887 | "id": "bdd243a9", 1888 | "metadata": {}, 1889 | "outputs": [], 1890 | "source": [ 1891 | "p = Person(\"Milen\")" 1892 | ] 1893 | }, 1894 | { 1895 | "cell_type": "code", 1896 | "execution_count": 82, 1897 | "id": "2be5784e", 1898 | "metadata": {}, 1899 | "outputs": [ 1900 | { 1901 | "name": "stdout", 1902 | "output_type": "stream", 1903 | "text": [ 1904 | "<__main__.Person object at 0x000001FF0A1AF9D0>\n" 1905 | ] 1906 | } 1907 | ], 1908 | "source": [ 1909 | "print(p)" 1910 | ] 1911 | }, 1912 | { 1913 | "cell_type": "code", 1914 | "execution_count": 83, 1915 | "id": "c060acd7", 1916 | "metadata": {}, 1917 | "outputs": [ 1918 | { 1919 | "data": { 1920 | "text/plain": [ 1921 | "'Milen'" 1922 | ] 1923 | }, 1924 | "execution_count": 83, 1925 | "metadata": {}, 1926 | "output_type": "execute_result" 1927 | } 1928 | ], 1929 | "source": [ 1930 | "p.name" 1931 | ] 1932 | }, 1933 | { 1934 | "cell_type": "code", 1935 | "execution_count": 84, 1936 | "id": "29901fce", 1937 | "metadata": {}, 1938 | "outputs": [], 1939 | "source": [ 1940 | "class Person:\n", 1941 | " def __init__(self, name):\n", 1942 | " self.name = name\n", 1943 | " def __str__(self) -> str:\n", 1944 | " return self.name" 1945 | ] 1946 | }, 1947 | { 1948 | "cell_type": "code", 1949 | "execution_count": 85, 1950 | "id": "0a84d86e", 1951 | "metadata": {}, 1952 | "outputs": [], 1953 | "source": [ 1954 | "p = Person(\"Milen\")" 1955 | ] 1956 | }, 1957 | { 1958 | "cell_type": "code", 1959 | "execution_count": 86, 1960 | "id": "68773400", 1961 | "metadata": {}, 1962 | "outputs": [ 1963 | { 1964 | "name": "stdout", 1965 | "output_type": "stream", 1966 | "text": [ 1967 | "Milen\n" 1968 | ] 1969 | } 1970 | ], 1971 | "source": [ 1972 | "print(p)" 1973 | ] 1974 | }, 1975 | { 1976 | "cell_type": "code", 1977 | "execution_count": 87, 1978 | "id": "1b482839", 1979 | "metadata": {}, 1980 | "outputs": [], 1981 | "source": [ 1982 | "class Person:\n", 1983 | " def __init__(self, name):\n", 1984 | " self.name = name\n", 1985 | " def __str__(self) -> str:\n", 1986 | " return self.name\n", 1987 | " \n", 1988 | "class Student(Person):\n", 1989 | " def __init__(self, name, student_number):\n", 1990 | " super().__init__(name)\n", 1991 | " self.student_number = student_number\n", 1992 | " def __str__(self) -> str:\n", 1993 | " return f'{super().__str__()} with student number {self.student_number}'" 1994 | ] 1995 | }, 1996 | { 1997 | "cell_type": "code", 1998 | "execution_count": 88, 1999 | "id": "75396ea0", 2000 | "metadata": {}, 2001 | "outputs": [], 2002 | "source": [ 2003 | "s = Student('Ivan', 42)" 2004 | ] 2005 | }, 2006 | { 2007 | "cell_type": "code", 2008 | "execution_count": 89, 2009 | "id": "118f2429", 2010 | "metadata": {}, 2011 | "outputs": [ 2012 | { 2013 | "name": "stdout", 2014 | "output_type": "stream", 2015 | "text": [ 2016 | "Ivan with student number 42\n" 2017 | ] 2018 | } 2019 | ], 2020 | "source": [ 2021 | "print(s)" 2022 | ] 2023 | }, 2024 | { 2025 | "cell_type": "code", 2026 | "execution_count": 90, 2027 | "id": "33c74c20", 2028 | "metadata": {}, 2029 | "outputs": [ 2030 | { 2031 | "data": { 2032 | "text/plain": [ 2033 | "'Ivan'" 2034 | ] 2035 | }, 2036 | "execution_count": 90, 2037 | "metadata": {}, 2038 | "output_type": "execute_result" 2039 | } 2040 | ], 2041 | "source": [ 2042 | "s.name" 2043 | ] 2044 | }, 2045 | { 2046 | "cell_type": "markdown", 2047 | "id": "021b23d1", 2048 | "metadata": {}, 2049 | "source": [ 2050 | "### Exeptions" 2051 | ] 2052 | }, 2053 | { 2054 | "cell_type": "code", 2055 | "execution_count": 91, 2056 | "id": "9a3a9ea7", 2057 | "metadata": {}, 2058 | "outputs": [ 2059 | { 2060 | "name": "stdout", 2061 | "output_type": "stream", 2062 | "text": [ 2063 | "division by zero\n", 2064 | "Goodbye, world!\n" 2065 | ] 2066 | } 2067 | ], 2068 | "source": [ 2069 | "try:\n", 2070 | " raise 1/0\n", 2071 | "except Exception as e:\n", 2072 | " print(e)\n", 2073 | "finally:\n", 2074 | " print('Goodbye, world!')" 2075 | ] 2076 | }, 2077 | { 2078 | "cell_type": "code", 2079 | "execution_count": 92, 2080 | "id": "a32cb1b0", 2081 | "metadata": {}, 2082 | "outputs": [ 2083 | { 2084 | "name": "stdout", 2085 | "output_type": "stream", 2086 | "text": [ 2087 | "division by zero\n", 2088 | "Isn't that just infinity\n", 2089 | "Goodbye, world!\n" 2090 | ] 2091 | } 2092 | ], 2093 | "source": [ 2094 | "try:\n", 2095 | " raise 1/0\n", 2096 | "except ZeroDivisionError as e:\n", 2097 | " print(e)\n", 2098 | " print(\"Isn't that just infinity\")\n", 2099 | "except Exception as e:\n", 2100 | " print(e)\n", 2101 | "finally:\n", 2102 | " print('Goodbye, world!')" 2103 | ] 2104 | }, 2105 | { 2106 | "cell_type": "markdown", 2107 | "id": "7c528a20", 2108 | "metadata": {}, 2109 | "source": [ 2110 | "### Duck typing or why sometimes it is EAFP (easier to as for forgiveness than permission)" 2111 | ] 2112 | }, 2113 | { 2114 | "cell_type": "code", 2115 | "execution_count": 93, 2116 | "id": "d2d202b2", 2117 | "metadata": {}, 2118 | "outputs": [], 2119 | "source": [ 2120 | "class Duck:\n", 2121 | "\n", 2122 | " def quack(self):\n", 2123 | " print('Quack, quack')\n", 2124 | "\n", 2125 | " def fly(self):\n", 2126 | " print('Flap, Flap!')\n", 2127 | "\n", 2128 | "\n", 2129 | "class Person:\n", 2130 | "\n", 2131 | " def quack(self):\n", 2132 | " print(\"I'm Quacking Like a Duck!\")\n", 2133 | "\n", 2134 | " def fly(self):\n", 2135 | " print(\"I'm Flapping my Arms!\")\n" 2136 | ] 2137 | }, 2138 | { 2139 | "cell_type": "code", 2140 | "execution_count": 94, 2141 | "id": "aee42261", 2142 | "metadata": {}, 2143 | "outputs": [], 2144 | "source": [ 2145 | "duck_duck = Duck()\n", 2146 | "duck_person = Person()" 2147 | ] 2148 | }, 2149 | { 2150 | "cell_type": "code", 2151 | "execution_count": 95, 2152 | "id": "914be99a", 2153 | "metadata": {}, 2154 | "outputs": [], 2155 | "source": [ 2156 | "def quack_and_fly(thing):\n", 2157 | " pass\n", 2158 | " # Not Duck-Typed (\"Non-Pythonic\")\n", 2159 | " # if isinstance(thing, Duck):\n", 2160 | " # thing.quack()\n", 2161 | " # thing.fly()\n", 2162 | " # else:\n", 2163 | " # print('This has to be a Duck!')\n", 2164 | "\n", 2165 | " # # LBYL (\"Non-Pythonic\")\n", 2166 | " # if hasattr(thing, 'quack'):\n", 2167 | " # if callable(thing.quack):\n", 2168 | " # thing.quack()\n", 2169 | "\n", 2170 | " if hasattr(thing, 'fly'):\n", 2171 | " try:\n", 2172 | " thing.quack()\n", 2173 | " thing.fly()\n", 2174 | " # thing.bark()\n", 2175 | " except AttributeError as e:\n", 2176 | " print(e)\n" 2177 | ] 2178 | }, 2179 | { 2180 | "cell_type": "code", 2181 | "execution_count": 96, 2182 | "id": "bf17033b", 2183 | "metadata": {}, 2184 | "outputs": [ 2185 | { 2186 | "name": "stdout", 2187 | "output_type": "stream", 2188 | "text": [ 2189 | "I'm Quacking Like a Duck!\n", 2190 | "I'm Flapping my Arms!\n" 2191 | ] 2192 | } 2193 | ], 2194 | "source": [ 2195 | "quack_and_fly(duck_person)" 2196 | ] 2197 | }, 2198 | { 2199 | "cell_type": "markdown", 2200 | "id": "9045ebe4", 2201 | "metadata": {}, 2202 | "source": [ 2203 | "### Special (magic, Dunder) Methods" 2204 | ] 2205 | }, 2206 | { 2207 | "cell_type": "code", 2208 | "execution_count": 97, 2209 | "id": "026f348d", 2210 | "metadata": {}, 2211 | "outputs": [], 2212 | "source": [ 2213 | "\n", 2214 | "class CallMe:\n", 2215 | " def __init__(self, name):\n", 2216 | " self.name = name\n", 2217 | " def __call__(self, *args, **kwargs):\n", 2218 | " print(f\"My name is {self.name}. You called me with {args} args and {kwargs} kwargs\")" 2219 | ] 2220 | }, 2221 | { 2222 | "cell_type": "code", 2223 | "execution_count": 98, 2224 | "id": "7dbea993", 2225 | "metadata": {}, 2226 | "outputs": [ 2227 | { 2228 | "name": "stdout", 2229 | "output_type": "stream", 2230 | "text": [ 2231 | "My name is Object. You called me with (42, 'is not enough') args and {'statements': \"I don't believe in AI.\"} kwargs\n" 2232 | ] 2233 | } 2234 | ], 2235 | "source": [ 2236 | "call = CallMe(\"Object\")\n", 2237 | "call(42, 'is not enough', statements=\"I don't believe in AI.\")" 2238 | ] 2239 | }, 2240 | { 2241 | "cell_type": "code", 2242 | "execution_count": 99, 2243 | "id": "c1fe5dbd", 2244 | "metadata": {}, 2245 | "outputs": [], 2246 | "source": [ 2247 | "class Complex(object):\n", 2248 | " def __init__(self, real, imag=0.0):\n", 2249 | " self.real = real\n", 2250 | " self.imag = imag\n", 2251 | " \n", 2252 | " def modulus(self):\n", 2253 | " return float(self.real**2 + self.imag**2) ** (1/2)\n", 2254 | "\n", 2255 | " def __add__(self, other):\n", 2256 | " if isinstance(other, Complex):\n", 2257 | " return Complex(self.real + other.real,\n", 2258 | " self.imag + other.imag)\n", 2259 | " return self + Complex(other)\n", 2260 | " \n", 2261 | " def __radd__(self, other):\n", 2262 | " return other + self\n", 2263 | "\n", 2264 | " def __sub__(self, other):\n", 2265 | " return Complex(self.real - other.real,\n", 2266 | " self.imag - other.imag)\n", 2267 | "\n", 2268 | " def __mul__(self, other):\n", 2269 | " return Complex(self.real*other.real - self.imag*other.imag,\n", 2270 | " self.imag*other.real + self.real*other.imag)\n", 2271 | " def __mul__(self, other):\n", 2272 | " return other * self\n", 2273 | "\n", 2274 | " def __div__(self, other):\n", 2275 | " r = other.modulus() ** 2\n", 2276 | " return Complex((self.real*other.real+self.imag*other.imag)/r, (self.real*other.real-self.real*other.real)/r)\n", 2277 | "\n", 2278 | " def __abs__(self):\n", 2279 | " return self.modulus()\n", 2280 | "\n", 2281 | " def __neg__(self): # defines -c (c is Complex)\n", 2282 | " return Complex(-self.real, -self.imag)\n", 2283 | "\n", 2284 | " def __eq__(self, other):\n", 2285 | " return self.real == other.real and self.imag == other.imag\n", 2286 | "\n", 2287 | " def __ne__(self, other):\n", 2288 | " return not self.__eq__(other)\n", 2289 | "\n", 2290 | " def __str__(self):\n", 2291 | " return f'{self.real}, {self.imag}'\n", 2292 | "\n", 2293 | " def __repr__(self):\n", 2294 | " class_name = type(self).__name__\n", 2295 | " return f'Complex {str(self)}'\n", 2296 | "\n", 2297 | " def __pow__(self, power):\n", 2298 | " raise NotImplementedError\\\n", 2299 | " ('self**power is not yet impl. for Complex')" 2300 | ] 2301 | }, 2302 | { 2303 | "cell_type": "code", 2304 | "execution_count": 100, 2305 | "id": "f350bd8d", 2306 | "metadata": {}, 2307 | "outputs": [], 2308 | "source": [ 2309 | "c1 = Complex(1, 1)\n", 2310 | "c2 = Complex(2, 2)" 2311 | ] 2312 | }, 2313 | { 2314 | "cell_type": "code", 2315 | "execution_count": 101, 2316 | "id": "715ee9ff", 2317 | "metadata": {}, 2318 | "outputs": [ 2319 | { 2320 | "name": "stdout", 2321 | "output_type": "stream", 2322 | "text": [ 2323 | "3, 3\n" 2324 | ] 2325 | } 2326 | ], 2327 | "source": [ 2328 | "print(c1 + c2)" 2329 | ] 2330 | }, 2331 | { 2332 | "cell_type": "code", 2333 | "execution_count": 102, 2334 | "id": "8b7fc037", 2335 | "metadata": {}, 2336 | "outputs": [ 2337 | { 2338 | "data": { 2339 | "text/plain": [ 2340 | "Complex 6, 1.0" 2341 | ] 2342 | }, 2343 | "execution_count": 102, 2344 | "metadata": {}, 2345 | "output_type": "execute_result" 2346 | } 2347 | ], 2348 | "source": [ 2349 | "c1 + 5" 2350 | ] 2351 | }, 2352 | { 2353 | "cell_type": "code", 2354 | "execution_count": 103, 2355 | "id": "1c02293a", 2356 | "metadata": {}, 2357 | "outputs": [ 2358 | { 2359 | "data": { 2360 | "text/plain": [ 2361 | "Complex 3, 3" 2362 | ] 2363 | }, 2364 | "execution_count": 103, 2365 | "metadata": {}, 2366 | "output_type": "execute_result" 2367 | } 2368 | ], 2369 | "source": [ 2370 | "c1 + c2" 2371 | ] 2372 | }, 2373 | { 2374 | "cell_type": "markdown", 2375 | "id": "e9661ef4", 2376 | "metadata": { 2377 | "id": "e9661ef4" 2378 | }, 2379 | "source": [ 2380 | "## NumPy\n", 2381 | "NumPy is a Python library, which adds support for large, multi-dimensional arrays and matrices, along with a large collection of optimized, high-level mathematical functions to operate on these arrays." 2382 | ] 2383 | }, 2384 | { 2385 | "cell_type": "markdown", 2386 | "id": "ecdb0df8", 2387 | "metadata": { 2388 | "id": "ecdb0df8" 2389 | }, 2390 | "source": [ 2391 | "You may need to install numpy first before importing it in the next cell.\n", 2392 | "\n", 2393 | "There are many ways to manage your packages, but the workflow we suggest for this class is to use Anaconda.\n", 2394 | " - Download Anaconda. Create a conda environment when you work on a new project.\n", 2395 | " - Activate your conda environment and install libraries using conda or pip if they are not available in conda.\n", 2396 | " - If you are running scripts on command line, run inside your conda environment.\n", 2397 | " - If you are using a Jupyter notebook, add your conda environment to your Jupyter notebook: https://towardsdatascience.com/get-your-conda-environment-to-show-in-jupyter-notebooks-the-easy-way-17010b76e874. Create your Jupyter notebook and verify you're in your conda environment kernel (top right of notebook should display the name). If you're not, go to the Kernel tab on the top left and click Change kernel to change to your conda environment kernel." 2398 | ] 2399 | }, 2400 | { 2401 | "cell_type": "code", 2402 | "execution_count": 104, 2403 | "id": "ab7d3f32", 2404 | "metadata": { 2405 | "id": "ab7d3f32" 2406 | }, 2407 | "outputs": [], 2408 | "source": [ 2409 | "# Import numpy\n", 2410 | "import numpy as np" 2411 | ] 2412 | }, 2413 | { 2414 | "cell_type": "code", 2415 | "execution_count": 105, 2416 | "id": "6596eb30", 2417 | "metadata": { 2418 | "colab": { 2419 | "base_uri": "https://localhost:8080/" 2420 | }, 2421 | "id": "6596eb30", 2422 | "outputId": "b08c870b-0e1a-4129-bfb8-b94ca4fca602", 2423 | "scrolled": false 2424 | }, 2425 | "outputs": [ 2426 | { 2427 | "name": "stdout", 2428 | "output_type": "stream", 2429 | "text": [ 2430 | "(3,)\n", 2431 | "(1, 3)\n", 2432 | "\n", 2433 | "[[6 7]\n", 2434 | " [8 9]]\n", 2435 | "(2, 2)\n" 2436 | ] 2437 | } 2438 | ], 2439 | "source": [ 2440 | "# Create numpy arrays from lists\n", 2441 | "x = np.array([1,2,3])\n", 2442 | "a = np.array([[1,2,3]])\n", 2443 | "\n", 2444 | "\n", 2445 | "y = np.array([[3,4,5]])\n", 2446 | "z = np.array([[6,7],[8,9]])\n", 2447 | "\n", 2448 | "# Let's take a look at their shapes.\n", 2449 | "# When working with numpy arrays, .shape will be a very useful debugging tool\n", 2450 | "print(x.shape)\n", 2451 | "print(y.shape)\n", 2452 | "print()\n", 2453 | "print(z)\n", 2454 | "print(z.shape)" 2455 | ] 2456 | }, 2457 | { 2458 | "cell_type": "markdown", 2459 | "id": "f4b465bf", 2460 | "metadata": { 2461 | "id": "f4b465bf" 2462 | }, 2463 | "source": [ 2464 | "Vectors can be represented as 1-D arrays of shape (N,) or 2-D arrays of shape (N, 1) or (1, N). But it's important to note that the shapes (N,), (N, 1), and (1,N) are not the same and may result in different behavior (we'll see some examples below involving matrix multiplication and broadcasting).\n", 2465 | "\n", 2466 | "Matrices are generally represented as 2-D arrays of shape (M, N).\n", 2467 | "\n", 2468 | "The best way to ensure your code gives you the behavior you expect is to keep track of your array shapes and try out small test cases or refer back to documentation when you are unsure." 2469 | ] 2470 | }, 2471 | { 2472 | "cell_type": "code", 2473 | "execution_count": 106, 2474 | "id": "A0Wl4qioLmb-", 2475 | "metadata": { 2476 | "colab": { 2477 | "base_uri": "https://localhost:8080/" 2478 | }, 2479 | "id": "A0Wl4qioLmb-", 2480 | "outputId": "120b2e64-68d3-4f7a-e643-6b7a0a91aece" 2481 | }, 2482 | "outputs": [ 2483 | { 2484 | "name": "stdout", 2485 | "output_type": "stream", 2486 | "text": [ 2487 | "[0 1 2 3 4 5 6 7 8 9]\n", 2488 | "\n", 2489 | "[[0 1]\n", 2490 | " [2 3]\n", 2491 | " [4 5]\n", 2492 | " [6 7]\n", 2493 | " [8 9]]\n" 2494 | ] 2495 | } 2496 | ], 2497 | "source": [ 2498 | "a = np.arange(10)\n", 2499 | "b = a.reshape((5, 2))\n", 2500 | "print(a)\n", 2501 | "print()\n", 2502 | "print(b)" 2503 | ] 2504 | }, 2505 | { 2506 | "cell_type": "markdown", 2507 | "id": "bcb3f37c", 2508 | "metadata": { 2509 | "id": "bcb3f37c" 2510 | }, 2511 | "source": [ 2512 | "### Array Operations" 2513 | ] 2514 | }, 2515 | { 2516 | "cell_type": "markdown", 2517 | "id": "18a8a694", 2518 | "metadata": { 2519 | "id": "18a8a694" 2520 | }, 2521 | "source": [ 2522 | "There are many NumPy operations that can be used to reduce a numpy array along an axis.\n", 2523 | "\n", 2524 | "Let's look at the np.max operation (documentation: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.max.html)." 2525 | ] 2526 | }, 2527 | { 2528 | "cell_type": "code", 2529 | "execution_count": 107, 2530 | "id": "1fcf4220", 2531 | "metadata": { 2532 | "colab": { 2533 | "base_uri": "https://localhost:8080/" 2534 | }, 2535 | "id": "1fcf4220", 2536 | "outputId": "4b63370e-2eb1-4891-9e2b-051a8484276e" 2537 | }, 2538 | "outputs": [ 2539 | { 2540 | "name": "stdout", 2541 | "output_type": "stream", 2542 | "text": [ 2543 | "[[1 2]\n", 2544 | " [3 4]\n", 2545 | " [5 6]]\n", 2546 | "\n", 2547 | "(3, 2)\n" 2548 | ] 2549 | } 2550 | ], 2551 | "source": [ 2552 | "x = np.array([[1,2],[3,4], [5, 6]])\n", 2553 | "print(x)\n", 2554 | "print()\n", 2555 | "print(x.shape)" 2556 | ] 2557 | }, 2558 | { 2559 | "cell_type": "code", 2560 | "execution_count": 108, 2561 | "id": "df82f62e", 2562 | "metadata": { 2563 | "colab": { 2564 | "base_uri": "https://localhost:8080/" 2565 | }, 2566 | "id": "df82f62e", 2567 | "outputId": "e5dffa24-26d4-47b2-fbb4-7853d049bdee" 2568 | }, 2569 | "outputs": [ 2570 | { 2571 | "name": "stdout", 2572 | "output_type": "stream", 2573 | "text": [ 2574 | "[2 4 6]\n" 2575 | ] 2576 | } 2577 | ], 2578 | "source": [ 2579 | "print(np.max(x, axis = 1))" 2580 | ] 2581 | }, 2582 | { 2583 | "cell_type": "code", 2584 | "execution_count": 109, 2585 | "id": "WDWPbijv7xsw", 2586 | "metadata": { 2587 | "colab": { 2588 | "base_uri": "https://localhost:8080/" 2589 | }, 2590 | "id": "WDWPbijv7xsw", 2591 | "outputId": "a595b672-585a-4ef4-c62c-debff4c1cf61" 2592 | }, 2593 | "outputs": [ 2594 | { 2595 | "name": "stdout", 2596 | "output_type": "stream", 2597 | "text": [ 2598 | "(3,)\n" 2599 | ] 2600 | } 2601 | ], 2602 | "source": [ 2603 | "print(np.max(x, axis = 1).shape)" 2604 | ] 2605 | }, 2606 | { 2607 | "cell_type": "code", 2608 | "execution_count": 110, 2609 | "id": "0e888b74", 2610 | "metadata": { 2611 | "colab": { 2612 | "base_uri": "https://localhost:8080/" 2613 | }, 2614 | "id": "0e888b74", 2615 | "outputId": "3548a983-7500-4f6b-c3e9-65b1a99275fa" 2616 | }, 2617 | "outputs": [ 2618 | { 2619 | "name": "stdout", 2620 | "output_type": "stream", 2621 | "text": [ 2622 | "[[2]\n", 2623 | " [4]\n", 2624 | " [6]]\n" 2625 | ] 2626 | } 2627 | ], 2628 | "source": [ 2629 | "print(np.max(x, axis = 1, keepdims = True))" 2630 | ] 2631 | }, 2632 | { 2633 | "cell_type": "code", 2634 | "execution_count": 111, 2635 | "id": "bs1NM9oR703c", 2636 | "metadata": { 2637 | "colab": { 2638 | "base_uri": "https://localhost:8080/" 2639 | }, 2640 | "id": "bs1NM9oR703c", 2641 | "outputId": "31c8119a-2e77-4451-8f9a-d3968a4d2b60" 2642 | }, 2643 | "outputs": [ 2644 | { 2645 | "name": "stdout", 2646 | "output_type": "stream", 2647 | "text": [ 2648 | "(3, 1)\n" 2649 | ] 2650 | } 2651 | ], 2652 | "source": [ 2653 | "print(np.max(x, axis = 1, keepdims = True).shape)" 2654 | ] 2655 | }, 2656 | { 2657 | "cell_type": "markdown", 2658 | "id": "29ff27ec", 2659 | "metadata": { 2660 | "id": "29ff27ec" 2661 | }, 2662 | "source": [ 2663 | "Next, let's look at some matrix operations. Let's take an element-wise product (Hadamard product)." 2664 | ] 2665 | }, 2666 | { 2667 | "cell_type": "code", 2668 | "execution_count": 112, 2669 | "id": "25aeb52d", 2670 | "metadata": { 2671 | "colab": { 2672 | "base_uri": "https://localhost:8080/" 2673 | }, 2674 | "id": "25aeb52d", 2675 | "outputId": "e4bfaf4f-7bfa-472e-eac7-ac2e6390c13c" 2676 | }, 2677 | "outputs": [ 2678 | { 2679 | "name": "stdout", 2680 | "output_type": "stream", 2681 | "text": [ 2682 | "[[1 2]\n", 2683 | " [3 4]]\n", 2684 | "[[3 3]\n", 2685 | " [3 3]]\n", 2686 | "---\n", 2687 | "[[ 3 6]\n", 2688 | " [ 9 12]]\n" 2689 | ] 2690 | } 2691 | ], 2692 | "source": [ 2693 | "A = np.array([[1, 2], [3, 4]])\n", 2694 | "B = np.array([[3, 3], [3, 3]])\n", 2695 | "print(A)\n", 2696 | "print(B)\n", 2697 | "print(\"---\")\n", 2698 | "print(A * B)" 2699 | ] 2700 | }, 2701 | { 2702 | "cell_type": "markdown", 2703 | "id": "689f2a8d", 2704 | "metadata": { 2705 | "id": "689f2a8d" 2706 | }, 2707 | "source": [ 2708 | "We can do matrix multiplication with np.matmul or @." 2709 | ] 2710 | }, 2711 | { 2712 | "cell_type": "code", 2713 | "execution_count": 113, 2714 | "id": "c76ec303", 2715 | "metadata": { 2716 | "colab": { 2717 | "base_uri": "https://localhost:8080/" 2718 | }, 2719 | "id": "c76ec303", 2720 | "outputId": "d36b6d3d-5cad-497b-d263-25f6107a7fd2" 2721 | }, 2722 | "outputs": [ 2723 | { 2724 | "name": "stdout", 2725 | "output_type": "stream", 2726 | "text": [ 2727 | "[[ 9 9]\n", 2728 | " [21 21]]\n", 2729 | "[[ 9 9]\n", 2730 | " [21 21]]\n" 2731 | ] 2732 | } 2733 | ], 2734 | "source": [ 2735 | "# One way to do matrix multiplication\n", 2736 | "print(np.matmul(A, B))\n", 2737 | "\n", 2738 | "# Another way to do matrix multiplication\n", 2739 | "print(A @ B)" 2740 | ] 2741 | }, 2742 | { 2743 | "cell_type": "markdown", 2744 | "id": "62696957", 2745 | "metadata": { 2746 | "id": "62696957" 2747 | }, 2748 | "source": [ 2749 | "We can take the dot product or a matrix vector product with np.dot." 2750 | ] 2751 | }, 2752 | { 2753 | "cell_type": "code", 2754 | "execution_count": 114, 2755 | "id": "0caf84b9", 2756 | "metadata": { 2757 | "colab": { 2758 | "base_uri": "https://localhost:8080/" 2759 | }, 2760 | "id": "0caf84b9", 2761 | "outputId": "a9feee27-6a8f-4e75-9ba3-243569a1e62f" 2762 | }, 2763 | "outputs": [ 2764 | { 2765 | "name": "stdout", 2766 | "output_type": "stream", 2767 | "text": [ 2768 | "321\n", 2769 | "321\n" 2770 | ] 2771 | } 2772 | ], 2773 | "source": [ 2774 | "u = np.array([1, 2, 3])\n", 2775 | "v = np.array([1, 10, 100])\n", 2776 | "\n", 2777 | "print(np.dot(u, v))\n", 2778 | "\n", 2779 | "# Can also call numpy operations on the numpy array, useful for chaining together multiple operations\n", 2780 | "print(u.dot(v))" 2781 | ] 2782 | }, 2783 | { 2784 | "cell_type": "code", 2785 | "execution_count": 115, 2786 | "id": "43e635bb", 2787 | "metadata": { 2788 | "colab": { 2789 | "base_uri": "https://localhost:8080/" 2790 | }, 2791 | "id": "43e635bb", 2792 | "outputId": "62cb79e7-a050-4e1c-a9b8-caedbe19a441" 2793 | }, 2794 | "outputs": [ 2795 | { 2796 | "name": "stdout", 2797 | "output_type": "stream", 2798 | "text": [ 2799 | "(3,)\n", 2800 | "(3, 2)\n", 2801 | "[531 642]\n", 2802 | "(2,)\n" 2803 | ] 2804 | } 2805 | ], 2806 | "source": [ 2807 | "W = np.array([[1, 2], [3, 4], [5, 6]])\n", 2808 | "print(v.shape)\n", 2809 | "print(W.shape)\n", 2810 | "\n", 2811 | "# This works.\n", 2812 | "print(np.dot(v, W))\n", 2813 | "print(np.dot(v, W).shape)" 2814 | ] 2815 | }, 2816 | { 2817 | "cell_type": "code", 2818 | "execution_count": 116, 2819 | "id": "683dd6ee", 2820 | "metadata": { 2821 | "colab": { 2822 | "base_uri": "https://localhost:8080/", 2823 | "height": 217 2824 | }, 2825 | "id": "683dd6ee", 2826 | "outputId": "f336b678-ff97-4192-bf69-fac68817342a" 2827 | }, 2828 | "outputs": [ 2829 | { 2830 | "ename": "ValueError", 2831 | "evalue": "shapes (3,2) and (3,) not aligned: 2 (dim 1) != 3 (dim 0)", 2832 | "output_type": "error", 2833 | "traceback": [ 2834 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 2835 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 2836 | "Cell \u001b[1;32mIn[116], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# This does not. Why?\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdot\u001b[49m\u001b[43m(\u001b[49m\u001b[43mW\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mv\u001b[49m\u001b[43m)\u001b[49m)\n", 2837 | "File \u001b[1;32m<__array_function__ internals>:180\u001b[0m, in \u001b[0;36mdot\u001b[1;34m(*args, **kwargs)\u001b[0m\n", 2838 | "\u001b[1;31mValueError\u001b[0m: shapes (3,2) and (3,) not aligned: 2 (dim 1) != 3 (dim 0)" 2839 | ] 2840 | } 2841 | ], 2842 | "source": [ 2843 | "# This does not. Why?\n", 2844 | "print(np.dot(W, v))" 2845 | ] 2846 | }, 2847 | { 2848 | "cell_type": "code", 2849 | "execution_count": 117, 2850 | "id": "9e8b2184", 2851 | "metadata": { 2852 | "colab": { 2853 | "base_uri": "https://localhost:8080/" 2854 | }, 2855 | "id": "9e8b2184", 2856 | "outputId": "b89a0299-edda-47fb-87a5-1b28b85b5242" 2857 | }, 2858 | "outputs": [ 2859 | { 2860 | "name": "stdout", 2861 | "output_type": "stream", 2862 | "text": [ 2863 | "[531 642]\n", 2864 | "(2,)\n" 2865 | ] 2866 | } 2867 | ], 2868 | "source": [ 2869 | "# We can fix the above issue by transposing W.\n", 2870 | "print(np.dot(W.T, v))\n", 2871 | "print(np.dot(W.T, v).shape)" 2872 | ] 2873 | }, 2874 | { 2875 | "cell_type": "markdown", 2876 | "id": "c13199d8", 2877 | "metadata": { 2878 | "id": "c13199d8" 2879 | }, 2880 | "source": [ 2881 | "### Indexing" 2882 | ] 2883 | }, 2884 | { 2885 | "cell_type": "markdown", 2886 | "id": "d3d3d5c2", 2887 | "metadata": { 2888 | "id": "d3d3d5c2" 2889 | }, 2890 | "source": [ 2891 | "Slicing / indexing numpy arrays is a extension of the Python concept of slicing (lists) to N dimensions." 2892 | ] 2893 | }, 2894 | { 2895 | "cell_type": "code", 2896 | "execution_count": 118, 2897 | "id": "bb930e29", 2898 | "metadata": { 2899 | "colab": { 2900 | "base_uri": "https://localhost:8080/" 2901 | }, 2902 | "id": "bb930e29", 2903 | "outputId": "6bc7bcbe-3313-456b-c4e2-a542d4a63a06", 2904 | "scrolled": true 2905 | }, 2906 | "outputs": [ 2907 | { 2908 | "name": "stdout", 2909 | "output_type": "stream", 2910 | "text": [ 2911 | "[[0.03549899 0.1057219 0.37616781 0.55445077]\n", 2912 | " [0.73029126 0.40791812 0.00987253 0.16581069]\n", 2913 | " [0.69985401 0.19752091 0.86961542 0.13286428]]\n" 2914 | ] 2915 | } 2916 | ], 2917 | "source": [ 2918 | "x = np.random.random((3, 4))\n", 2919 | "\n", 2920 | "# Selects all of x\n", 2921 | "print(x[:])" 2922 | ] 2923 | }, 2924 | { 2925 | "cell_type": "code", 2926 | "execution_count": 119, 2927 | "id": "16d0fe9a", 2928 | "metadata": { 2929 | "colab": { 2930 | "base_uri": "https://localhost:8080/" 2931 | }, 2932 | "id": "16d0fe9a", 2933 | "outputId": "07b3702f-64f6-437f-8b5d-26d72ffd1d00" 2934 | }, 2935 | "outputs": [ 2936 | { 2937 | "name": "stdout", 2938 | "output_type": "stream", 2939 | "text": [ 2940 | "[[0.03549899 0.1057219 0.37616781 0.55445077]\n", 2941 | " [0.69985401 0.19752091 0.86961542 0.13286428]]\n", 2942 | "---\n", 2943 | "[0.40791812 0.00987253]\n" 2944 | ] 2945 | } 2946 | ], 2947 | "source": [ 2948 | "# Selects the 0th and 2nd rows\n", 2949 | "print(x[np.array([0, 2]), :])\n", 2950 | "\n", 2951 | "print(\"---\")\n", 2952 | "\n", 2953 | "# Selects 1st row as 1-D vector and and 1st through 2nd elements\n", 2954 | "print(x[1, 1:3])" 2955 | ] 2956 | }, 2957 | { 2958 | "cell_type": "code", 2959 | "execution_count": 120, 2960 | "id": "04bf1911", 2961 | "metadata": { 2962 | "colab": { 2963 | "base_uri": "https://localhost:8080/" 2964 | }, 2965 | "id": "04bf1911", 2966 | "outputId": "9fa8d581-f646-46cf-a752-f01a1ced48ca" 2967 | }, 2968 | "outputs": [ 2969 | { 2970 | "name": "stdout", 2971 | "output_type": "stream", 2972 | "text": [ 2973 | "[0.55445077 0.73029126 0.69985401 0.86961542]\n" 2974 | ] 2975 | } 2976 | ], 2977 | "source": [ 2978 | "# Boolean indexing\n", 2979 | "print(x[x > 0.5])" 2980 | ] 2981 | }, 2982 | { 2983 | "cell_type": "code", 2984 | "execution_count": 121, 2985 | "id": "118924a3", 2986 | "metadata": { 2987 | "colab": { 2988 | "base_uri": "https://localhost:8080/" 2989 | }, 2990 | "id": "118924a3", 2991 | "outputId": "79d5d19b-1230-4728-8f6e-039aa56fe7f0" 2992 | }, 2993 | "outputs": [ 2994 | { 2995 | "name": "stdout", 2996 | "output_type": "stream", 2997 | "text": [ 2998 | "[[[0.03549899]\n", 2999 | " [0.1057219 ]\n", 3000 | " [0.37616781]\n", 3001 | " [0.55445077]]\n", 3002 | "\n", 3003 | " [[0.73029126]\n", 3004 | " [0.40791812]\n", 3005 | " [0.00987253]\n", 3006 | " [0.16581069]]\n", 3007 | "\n", 3008 | " [[0.69985401]\n", 3009 | " [0.19752091]\n", 3010 | " [0.86961542]\n", 3011 | " [0.13286428]]]\n" 3012 | ] 3013 | } 3014 | ], 3015 | "source": [ 3016 | "# 3-D vector of shape (3, 4, 1)\n", 3017 | "print(x[:, :, np.newaxis])" 3018 | ] 3019 | }, 3020 | { 3021 | "cell_type": "markdown", 3022 | "id": "48e1704f", 3023 | "metadata": { 3024 | "id": "48e1704f" 3025 | }, 3026 | "source": [ 3027 | "### Broadcasting" 3028 | ] 3029 | }, 3030 | { 3031 | "cell_type": "markdown", 3032 | "id": "40d35521", 3033 | "metadata": { 3034 | "id": "40d35521" 3035 | }, 3036 | "source": [ 3037 | "The term broadcasting describes how NumPy treats arrays with different shapes during arithmetic operations.\n", 3038 | "\n", 3039 | "**General Broadcasting Rules**\n", 3040 | "\n", 3041 | "When operating on two arrays, NumPy compares their shapes element-wise. It starts with the trailing (i.e. rightmost) dimensions and works its way left. Two dimensions are compatible when:\n", 3042 | "- they are equal, or\n", 3043 | "- one of them is 1 (in which case, elements on the axis are repeated along the dimension)\n", 3044 | "\n", 3045 | "More details: https://numpy.org/doc/stable/user/basics.broadcasting.html" 3046 | ] 3047 | }, 3048 | { 3049 | "cell_type": "code", 3050 | "execution_count": 122, 3051 | "id": "e3f0c8b1", 3052 | "metadata": { 3053 | "id": "e3f0c8b1" 3054 | }, 3055 | "outputs": [], 3056 | "source": [ 3057 | "x = np.random.random((3, 4))\n", 3058 | "\n", 3059 | "y = np.random.random((3, 1))\n", 3060 | "z = np.random.random((1, 4))\n", 3061 | "\n", 3062 | "# In this example, y and z are broadcasted to match the shape of x.\n", 3063 | "# y is broadcasted along dim 1.\n", 3064 | "s = x + y\n", 3065 | "# z is broadcasted along dim 0.\n", 3066 | "p = x * z" 3067 | ] 3068 | }, 3069 | { 3070 | "cell_type": "code", 3071 | "execution_count": 123, 3072 | "id": "93cdfc8a", 3073 | "metadata": { 3074 | "colab": { 3075 | "base_uri": "https://localhost:8080/" 3076 | }, 3077 | "id": "93cdfc8a", 3078 | "outputId": "a350d379-ffc0-4366-d430-1e04af352fac" 3079 | }, 3080 | "outputs": [ 3081 | { 3082 | "name": "stdout", 3083 | "output_type": "stream", 3084 | "text": [ 3085 | "(3, 4)\n", 3086 | "\n", 3087 | "(3, 1)\n", 3088 | "(3, 4)\n" 3089 | ] 3090 | } 3091 | ], 3092 | "source": [ 3093 | "print(x.shape)\n", 3094 | "print()\n", 3095 | "print(y.shape)\n", 3096 | "print(s.shape)" 3097 | ] 3098 | }, 3099 | { 3100 | "cell_type": "code", 3101 | "execution_count": 124, 3102 | "id": "a77b76bc", 3103 | "metadata": { 3104 | "colab": { 3105 | "base_uri": "https://localhost:8080/" 3106 | }, 3107 | "id": "a77b76bc", 3108 | "outputId": "e7086c7a-51b8-45a7-838f-4d7f270e2bcd" 3109 | }, 3110 | "outputs": [ 3111 | { 3112 | "name": "stdout", 3113 | "output_type": "stream", 3114 | "text": [ 3115 | "(3, 4)\n", 3116 | "\n", 3117 | "(3, 4)\n", 3118 | "(3, 4)\n" 3119 | ] 3120 | } 3121 | ], 3122 | "source": [ 3123 | "print(x.shape)\n", 3124 | "print()\n", 3125 | "print(s.shape)\n", 3126 | "print(p.shape)" 3127 | ] 3128 | }, 3129 | { 3130 | "cell_type": "code", 3131 | "execution_count": 125, 3132 | "id": "FICMa8RiMR08", 3133 | "metadata": { 3134 | "colab": { 3135 | "base_uri": "https://localhost:8080/" 3136 | }, 3137 | "id": "FICMa8RiMR08", 3138 | "outputId": "38f90bfd-f567-4e14-d18e-d54ac7a23d79" 3139 | }, 3140 | "outputs": [ 3141 | { 3142 | "name": "stdout", 3143 | "output_type": "stream", 3144 | "text": [ 3145 | "[[0. 0. 0.]\n", 3146 | " [0. 0. 0.]\n", 3147 | " [0. 0. 0.]]\n", 3148 | "\n", 3149 | "[[1. 2. 3.]\n", 3150 | " [1. 2. 3.]\n", 3151 | " [1. 2. 3.]]\n" 3152 | ] 3153 | } 3154 | ], 3155 | "source": [ 3156 | "a = np.zeros((3, 3))\n", 3157 | "b = np.array([[1, 2, 3]])\n", 3158 | "print(a)\n", 3159 | "print()\n", 3160 | "print(a+b)" 3161 | ] 3162 | }, 3163 | { 3164 | "cell_type": "markdown", 3165 | "id": "fec8ae1e", 3166 | "metadata": { 3167 | "id": "fec8ae1e" 3168 | }, 3169 | "source": [ 3170 | "Let's look at a more complex example." 3171 | ] 3172 | }, 3173 | { 3174 | "cell_type": "code", 3175 | "execution_count": 126, 3176 | "id": "2b1b271d", 3177 | "metadata": { 3178 | "id": "2b1b271d" 3179 | }, 3180 | "outputs": [], 3181 | "source": [ 3182 | "a = np.random.random((3, 4))\n", 3183 | "b = np.random.random((3, 1))\n", 3184 | "c = np.random.random((3, ))" 3185 | ] 3186 | }, 3187 | { 3188 | "cell_type": "markdown", 3189 | "id": "972fda59", 3190 | "metadata": { 3191 | "id": "972fda59" 3192 | }, 3193 | "source": [ 3194 | "What is the expected broadcasting behavior for these operations? What do the following operations give us? What are the resulting shapes?" 3195 | ] 3196 | }, 3197 | { 3198 | "cell_type": "code", 3199 | "execution_count": 127, 3200 | "id": "ab0e1d5b", 3201 | "metadata": { 3202 | "colab": { 3203 | "base_uri": "https://localhost:8080/" 3204 | }, 3205 | "id": "ab0e1d5b", 3206 | "outputId": "95735143-16d4-4d23-994c-3220e7caa718" 3207 | }, 3208 | "outputs": [ 3209 | { 3210 | "name": "stdout", 3211 | "output_type": "stream", 3212 | "text": [ 3213 | "(3, 1)\n", 3214 | "(1, 3)\n", 3215 | "(3, 3)\n", 3216 | "[[0.91299353 1.10751165 0.93299771]\n", 3217 | " [1.10751165 1.30202977 1.12751583]\n", 3218 | " [0.93299771 1.12751583 0.95300189]]\n" 3219 | ] 3220 | } 3221 | ], 3222 | "source": [ 3223 | "result1 = b + b.T\n", 3224 | "\n", 3225 | "print(b.shape)\n", 3226 | "print(b.T.shape)\n", 3227 | "print(result1.shape)\n", 3228 | "print(result1)" 3229 | ] 3230 | }, 3231 | { 3232 | "cell_type": "code", 3233 | "execution_count": 128, 3234 | "id": "d7e113be", 3235 | "metadata": { 3236 | "colab": { 3237 | "base_uri": "https://localhost:8080/", 3238 | "height": 235 3239 | }, 3240 | "id": "d7e113be", 3241 | "outputId": "67f13069-0f4c-4230-a3e7-05ba480acb73", 3242 | "scrolled": true 3243 | }, 3244 | "outputs": [ 3245 | { 3246 | "ename": "ValueError", 3247 | "evalue": "operands could not be broadcast together with shapes (3,4) (3,) ", 3248 | "output_type": "error", 3249 | "traceback": [ 3250 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 3251 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 3252 | "Cell \u001b[1;32mIn[128], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m result2 \u001b[38;5;241m=\u001b[39m \u001b[43ma\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(a\u001b[38;5;241m.\u001b[39mshape)\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(c\u001b[38;5;241m.\u001b[39mshape)\n", 3253 | "\u001b[1;31mValueError\u001b[0m: operands could not be broadcast together with shapes (3,4) (3,) " 3254 | ] 3255 | } 3256 | ], 3257 | "source": [ 3258 | "result2 = a + c\n", 3259 | "\n", 3260 | "print(a.shape)\n", 3261 | "print(c.shape)\n", 3262 | "print(result2.shape)\n", 3263 | "print(result2)" 3264 | ] 3265 | }, 3266 | { 3267 | "cell_type": "code", 3268 | "execution_count": 131, 3269 | "id": "e91c0c70", 3270 | "metadata": { 3271 | "colab": { 3272 | "base_uri": "https://localhost:8080/" 3273 | }, 3274 | "id": "e91c0c70", 3275 | "outputId": "0a6f644c-9e73-43e9-9215-207a8f3f7dc2" 3276 | }, 3277 | "outputs": [ 3278 | { 3279 | "name": "stdout", 3280 | "output_type": "stream", 3281 | "text": [ 3282 | "(3, 1)\n", 3283 | "(3,)\n", 3284 | "(3, 3)\n", 3285 | "[[0.52781058 0.70460258 1.00787359]\n", 3286 | " [0.7223287 0.89912071 1.20239171]\n", 3287 | " [0.54781476 0.72460677 1.02787777]]\n" 3288 | ] 3289 | } 3290 | ], 3291 | "source": [ 3292 | "result3 = b + c\n", 3293 | "\n", 3294 | "print(b.shape)\n", 3295 | "print(c.shape)\n", 3296 | "print(result3.shape)\n", 3297 | "print(result3)" 3298 | ] 3299 | }, 3300 | { 3301 | "cell_type": "markdown", 3302 | "id": "0a845479", 3303 | "metadata": { 3304 | "id": "0a845479" 3305 | }, 3306 | "source": [ 3307 | "### Efficient NumPy Code" 3308 | ] 3309 | }, 3310 | { 3311 | "cell_type": "markdown", 3312 | "id": "55c8d74f", 3313 | "metadata": { 3314 | "id": "55c8d74f" 3315 | }, 3316 | "source": [ 3317 | "When working with numpy arrays, avoid explicit for-loops over indices/axes at all costs. For-loops will dramatically slow down your code (~10-100x)." 3318 | ] 3319 | }, 3320 | { 3321 | "cell_type": "markdown", 3322 | "id": "e1285d83", 3323 | "metadata": { 3324 | "id": "e1285d83" 3325 | }, 3326 | "source": [ 3327 | "We can time code using the %%timeit magic. Let's compare using explicit for-loop vs. using numpy operations." 3328 | ] 3329 | }, 3330 | { 3331 | "cell_type": "code", 3332 | "execution_count": 132, 3333 | "id": "ba02c912", 3334 | "metadata": { 3335 | "colab": { 3336 | "base_uri": "https://localhost:8080/" 3337 | }, 3338 | "id": "ba02c912", 3339 | "outputId": "62191287-3cdf-420a-c4e9-c7bcac31ad57" 3340 | }, 3341 | "outputs": [ 3342 | { 3343 | "name": "stdout", 3344 | "output_type": "stream", 3345 | "text": [ 3346 | "156 ms ± 2.37 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" 3347 | ] 3348 | } 3349 | ], 3350 | "source": [ 3351 | "%%timeit\n", 3352 | "x = np.random.rand(1000, 1000)\n", 3353 | "for i in range(100, 1000):\n", 3354 | " for j in range(x.shape[1]):\n", 3355 | " x[i, j] += 5" 3356 | ] 3357 | }, 3358 | { 3359 | "cell_type": "code", 3360 | "execution_count": 133, 3361 | "id": "3c96fc83", 3362 | "metadata": { 3363 | "colab": { 3364 | "base_uri": "https://localhost:8080/" 3365 | }, 3366 | "id": "3c96fc83", 3367 | "outputId": "95c8a7c3-638c-4c2a-8f86-51492f60d85f" 3368 | }, 3369 | "outputs": [ 3370 | { 3371 | "name": "stdout", 3372 | "output_type": "stream", 3373 | "text": [ 3374 | "7.27 ms ± 390 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n" 3375 | ] 3376 | } 3377 | ], 3378 | "source": [ 3379 | "%%timeit\n", 3380 | "x = np.random.rand(1000, 1000)\n", 3381 | "x[np.arange(100,1000), :] += 5" 3382 | ] 3383 | }, 3384 | { 3385 | "cell_type": "code", 3386 | "execution_count": null, 3387 | "id": "72b832dd", 3388 | "metadata": { 3389 | "id": "72b832dd" 3390 | }, 3391 | "outputs": [], 3392 | "source": [] 3393 | } 3394 | ], 3395 | "metadata": { 3396 | "colab": { 3397 | "provenance": [] 3398 | }, 3399 | "kernelspec": { 3400 | "display_name": "base", 3401 | "language": "python", 3402 | "name": "python3" 3403 | }, 3404 | "language_info": { 3405 | "codemirror_mode": { 3406 | "name": "ipython", 3407 | "version": 3 3408 | }, 3409 | "file_extension": ".py", 3410 | "mimetype": "text/x-python", 3411 | "name": "python", 3412 | "nbconvert_exporter": "python", 3413 | "pygments_lexer": "ipython3", 3414 | "version": "3.9.18" 3415 | } 3416 | }, 3417 | "nbformat": 4, 3418 | "nbformat_minor": 5 3419 | } 3420 | --------------------------------------------------------------------------------