├── .github └── FUNDING.yml ├── Actor.py ├── Hollywood.py ├── LICENSE ├── Python-Tutorial_01.ipynb ├── Python-Tutorial_02.ipynb ├── Python-Tutorial_03.ipynb ├── Python-Tutorial_04.ipynb ├── Python-Tutorial_05.ipynb ├── Python-Tutorial_06.ipynb ├── Python-Tutorial_07.ipynb ├── Python-Tutorial_08.ipynb ├── Python-Tutorial_09.ipynb ├── Python-Tutorial_10.ipynb ├── Python-Tutorial_11.ipynb ├── Python-Tutorial_12.ipynb ├── Python-Tutorial_13.ipynb ├── Python-Tutorial_14.ipynb ├── Python-Tutorial_15-Star_Wars_Quiz.ipynb ├── Python-Tutorial_16.ipynb ├── Quiz.py ├── README.md ├── Robot.py ├── movies.txt └── utils.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: gautam1858 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /Actor.py: -------------------------------------------------------------------------------- 1 | class Actor: 2 | 3 | def fight(self): 4 | print("He can fight") 5 | 6 | def comedy(self): 7 | print("He can joke") 8 | 9 | def romance(self): 10 | print("He can romance") -------------------------------------------------------------------------------- /Hollywood.py: -------------------------------------------------------------------------------- 1 | # Here we are inheriting functions from Actor to Hollywood 2 | 3 | from Actor import Actor 4 | 5 | class Hollywood(Actor): 6 | 7 | def drama(self): 8 | print("He makes dramatic movies") 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Python-Tutorial_01.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Basic Python" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 8, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "Test message\n", 20 | "5\n", 21 | "True\n" 22 | ] 23 | } 24 | ], 25 | "source": [ 26 | "# Display something on screen\n", 27 | "\n", 28 | "print(\"Test message\")\n", 29 | "\n", 30 | "# It also works with many data types\n", 31 | "\n", 32 | "print(5)\n", 33 | "print(True)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 9, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "name": "stdout", 43 | "output_type": "stream", 44 | "text": [ 45 | "\n", 46 | "\n" 47 | ] 48 | } 49 | ], 50 | "source": [ 51 | "# Variables in python\n", 52 | "\n", 53 | "new_variable = 5 # In python you don't need to specify the type of variable\n", 54 | "\n", 55 | "# Check the type of variable\n", 56 | "print(type(new_variable))\n", 57 | "\n", 58 | "float_variable = 5.0\n", 59 | "print(type(float_variable))" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "### Math operations\n", 67 | "\n", 68 | "- `a + b` - add\n", 69 | "- `a - b` - substract\n", 70 | "- `a * b` - multiply\n", 71 | "- `a / b` - division\n", 72 | "- `a // b` - floor division\n", 73 | "- `a % b` - modulus, remainder from division\n", 74 | "- `a ** b` - power\n", 75 | "\n" 76 | ] 77 | }, 78 | { 79 | "cell_type": "markdown", 80 | "metadata": {}, 81 | "source": [ 82 | "## Strings" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 13, 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "name": "stdout", 92 | "output_type": "stream", 93 | "text": [ 94 | "My name is Ram\n", 95 | "and I am awesome\n" 96 | ] 97 | } 98 | ], 99 | "source": [ 100 | "character_name = \"Ram\"\n", 101 | "\n", 102 | "print(\"My name is \" + character_name + \"\\nand I am awesome\") # '\\n' means end-of-line (see below)" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 14, 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "name": "stdout", 112 | "output_type": "stream", 113 | "text": [ 114 | "Harry Potter and J K Rowling\n", 115 | "My favourite Monty Python's movies are Holy Grail and Life of Brain\n" 116 | ] 117 | } 118 | ], 119 | "source": [ 120 | "# Concatenation\n", 121 | "\n", 122 | "phrase = \"Harry Potter\"\n", 123 | "print(phrase + \" and J K Rowling\")\n", 124 | "\n", 125 | "# If you want to print many variables in formatted way it's better to use `format` method\n", 126 | "\n", 127 | "print(\"My favourite {0}'s movies are {1} and {2}\".format(\"Monty Python\", \"Holy Grail\", \"Life of Brain\"))\n", 128 | "\n", 129 | "# `format` method has also more awesome features" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": 20, 135 | "metadata": {}, 136 | "outputs": [ 137 | { 138 | "name": "stdout", 139 | "output_type": "stream", 140 | "text": [ 141 | "HARRY POTTER\n", 142 | "True\n", 143 | "12\n" 144 | ] 145 | } 146 | ], 147 | "source": [ 148 | "## Converting to upper case\n", 149 | "\n", 150 | "print(phrase.upper())\n", 151 | "\n", 152 | "# And check if it so\n", 153 | "\n", 154 | "print(phrase.upper().isupper())\n", 155 | "\n", 156 | "# Length of the string\n", 157 | "\n", 158 | "print(len(phrase)) # You can use `len` method with many data type. But what if you pass an integer inside brackets?" 159 | ] 160 | }, 161 | { 162 | "cell_type": "markdown", 163 | "metadata": {}, 164 | "source": [ 165 | "If you checked result of len function with an integer you should have seen error message in Python. You should not be scared of this view, it mostly gives you a precise information what was wrong with code. You can see at the same bottom error message that there was a TypeError" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 4, 171 | "metadata": {}, 172 | "outputs": [ 173 | { 174 | "name": "stdout", 175 | "output_type": "stream", 176 | "text": [ 177 | "6\n" 178 | ] 179 | } 180 | ], 181 | "source": [ 182 | "# Print a particular letter\n", 183 | "# Indexing in python starts with zero\n", 184 | "\n", 185 | "print(phrase[0]) # At what index is letter 'e'?\n", 186 | "\n", 187 | "## To know where the index is starting from\n", 188 | "\n", 189 | "print(phrase.index(\"Pott\"))" 190 | ] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "execution_count": 5, 195 | "metadata": {}, 196 | "outputs": [ 197 | { 198 | "name": "stdout", 199 | "output_type": "stream", 200 | "text": [ 201 | "Sorry Potter\n" 202 | ] 203 | } 204 | ], 205 | "source": [ 206 | "# To replace a letter\n", 207 | "\n", 208 | "print(phrase.replace(\"Harry\",\"Sorry\"))" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": 6, 214 | "metadata": {}, 215 | "outputs": [ 216 | { 217 | "name": "stdout", 218 | "output_type": "stream", 219 | "text": [ 220 | "7.56\n" 221 | ] 222 | } 223 | ], 224 | "source": [ 225 | "# Adressing numbers \n", 226 | "\n", 227 | "print(3.0+4.56)" 228 | ] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "execution_count": 21, 233 | "metadata": {}, 234 | "outputs": [ 235 | { 236 | "name": "stdout", 237 | "output_type": "stream", 238 | "text": [ 239 | "\n", 240 | "\n" 241 | ] 242 | } 243 | ], 244 | "source": [ 245 | "# Convert number to string \n", 246 | "number = 5\n", 247 | "print(type(number))\n", 248 | "print(type(str(number)))" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": 10, 254 | "metadata": {}, 255 | "outputs": [ 256 | { 257 | "name": "stdout", 258 | "output_type": "stream", 259 | "text": [ 260 | "5 is my favourite number\n" 261 | ] 262 | } 263 | ], 264 | "source": [ 265 | "# Concatenating \n", 266 | "print(str(number)+\" is my favourite number\")" 267 | ] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": 1, 272 | "metadata": {}, 273 | "outputs": [ 274 | { 275 | "data": { 276 | "text/plain": [ 277 | "['__doc__',\n", 278 | " '__file__',\n", 279 | " '__loader__',\n", 280 | " '__name__',\n", 281 | " '__package__',\n", 282 | " '__spec__',\n", 283 | " 'acos',\n", 284 | " 'acosh',\n", 285 | " 'asin',\n", 286 | " 'asinh',\n", 287 | " 'atan',\n", 288 | " 'atan2',\n", 289 | " 'atanh',\n", 290 | " 'ceil',\n", 291 | " 'copysign',\n", 292 | " 'cos',\n", 293 | " 'cosh',\n", 294 | " 'degrees',\n", 295 | " 'e',\n", 296 | " 'erf',\n", 297 | " 'erfc',\n", 298 | " 'exp',\n", 299 | " 'expm1',\n", 300 | " 'fabs',\n", 301 | " 'factorial',\n", 302 | " 'floor',\n", 303 | " 'fmod',\n", 304 | " 'frexp',\n", 305 | " 'fsum',\n", 306 | " 'gamma',\n", 307 | " 'gcd',\n", 308 | " 'hypot',\n", 309 | " 'inf',\n", 310 | " 'isclose',\n", 311 | " 'isfinite',\n", 312 | " 'isinf',\n", 313 | " 'isnan',\n", 314 | " 'ldexp',\n", 315 | " 'lgamma',\n", 316 | " 'log',\n", 317 | " 'log10',\n", 318 | " 'log1p',\n", 319 | " 'log2',\n", 320 | " 'modf',\n", 321 | " 'nan',\n", 322 | " 'pi',\n", 323 | " 'pow',\n", 324 | " 'radians',\n", 325 | " 'remainder',\n", 326 | " 'sin',\n", 327 | " 'sinh',\n", 328 | " 'sqrt',\n", 329 | " 'tan',\n", 330 | " 'tanh',\n", 331 | " 'tau',\n", 332 | " 'trunc']" 333 | ] 334 | }, 335 | "execution_count": 1, 336 | "metadata": {}, 337 | "output_type": "execute_result" 338 | } 339 | ], 340 | "source": [ 341 | "# importing math library\n", 342 | "import math\n", 343 | "\n", 344 | "# Check what's inside of this library\n", 345 | "dir(math)" 346 | ] 347 | }, 348 | { 349 | "cell_type": "code", 350 | "execution_count": 22, 351 | "metadata": {}, 352 | "outputs": [ 353 | { 354 | "name": "stdout", 355 | "output_type": "stream", 356 | "text": [ 357 | "2.16794833886788\n" 358 | ] 359 | } 360 | ], 361 | "source": [ 362 | "# Taking sqaure root\n", 363 | "print(math.sqrt(4.7))" 364 | ] 365 | }, 366 | { 367 | "cell_type": "code", 368 | "execution_count": 23, 369 | "metadata": {}, 370 | "outputs": [ 371 | { 372 | "name": "stdout", 373 | "output_type": "stream", 374 | "text": [ 375 | "4\n" 376 | ] 377 | } 378 | ], 379 | "source": [ 380 | "# Rouding off number to its maximum\n", 381 | "print(math.ceil(3.4))" 382 | ] 383 | }, 384 | { 385 | "cell_type": "code", 386 | "execution_count": 24, 387 | "metadata": {}, 388 | "outputs": [ 389 | { 390 | "name": "stdout", 391 | "output_type": "stream", 392 | "text": [ 393 | "3\n" 394 | ] 395 | } 396 | ], 397 | "source": [ 398 | "# Rounding of number to its minimum\n", 399 | "print(math.floor(3.4))" 400 | ] 401 | } 402 | ], 403 | "metadata": { 404 | "kernelspec": { 405 | "display_name": "Python 3", 406 | "language": "python", 407 | "name": "python3" 408 | }, 409 | "language_info": { 410 | "codemirror_mode": { 411 | "name": "ipython", 412 | "version": 3 413 | }, 414 | "file_extension": ".py", 415 | "mimetype": "text/x-python", 416 | "name": "python", 417 | "nbconvert_exporter": "python", 418 | "pygments_lexer": "ipython3", 419 | "version": "3.7.1" 420 | } 421 | }, 422 | "nbformat": 4, 423 | "nbformat_minor": 2 424 | } 425 | -------------------------------------------------------------------------------- /Python-Tutorial_02.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Enter your name: Alex\n", 13 | "Enter your age: 10\n", 14 | "Hi Alex, You are 10, How are you doing ?\n" 15 | ] 16 | } 17 | ], 18 | "source": [ 19 | "# Giving Raw input \n", 20 | "name = input(\"Enter your name: \")\n", 21 | "age = input(\"Enter your age: \")\n", 22 | "print(\"Hi \" + name + \", You are \"+age+\", How are you doing ?\")" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 7, 28 | "metadata": {}, 29 | "outputs": [ 30 | { 31 | "name": "stdout", 32 | "output_type": "stream", 33 | "text": [ 34 | "Enter a number_1 :34\n", 35 | "Enter a number_2 :45\n", 36 | "79\n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "# Adding numbers\n", 42 | "# Note : You have to mention the input is real number in python i.e you have to convert the input\n", 43 | "# which is considered as strings to number\n", 44 | "\n", 45 | "num_1 = input(\"Enter a number_1 :\")\n", 46 | "num_2 = input(\"Enter a number_2 :\")\n", 47 | "\n", 48 | "# Convert to number\n", 49 | "result = int(num_1) + int(num_2)\n", 50 | "print(result)" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 8, 56 | "metadata": {}, 57 | "outputs": [ 58 | { 59 | "name": "stdout", 60 | "output_type": "stream", 61 | "text": [ 62 | "Enter a number_1 :65.56\n", 63 | "Enter a number_2 :5.34\n", 64 | "70.9\n" 65 | ] 66 | } 67 | ], 68 | "source": [ 69 | "# Adding decimal numbers\n", 70 | "# Note : You have to mention the input is real number in python i.e you have to convert the input\n", 71 | "# which is considered as strings to number\n", 72 | "\n", 73 | "num_1 = input(\"Enter a number_1 :\")\n", 74 | "num_2 = input(\"Enter a number_2 :\")\n", 75 | "\n", 76 | "# Convert to float for using decimal\n", 77 | "result = float(num_1) + float(num_2)\n", 78 | "print(result)" 79 | ] 80 | } 81 | ], 82 | "metadata": { 83 | "kernelspec": { 84 | "display_name": "Python 3", 85 | "language": "python", 86 | "name": "python3" 87 | }, 88 | "language_info": { 89 | "codemirror_mode": { 90 | "name": "ipython", 91 | "version": 3 92 | }, 93 | "file_extension": ".py", 94 | "mimetype": "text/x-python", 95 | "name": "python", 96 | "nbconvert_exporter": "python", 97 | "pygments_lexer": "ipython3", 98 | "version": "3.6.5" 99 | } 100 | }, 101 | "nbformat": 4, 102 | "nbformat_minor": 2 103 | } 104 | -------------------------------------------------------------------------------- /Python-Tutorial_03.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "['Tom Cruise', 'Leonardo Di Caprio', 'Jennifer Lawrence', 'Natalie Portman']\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "# Creating List\n", 18 | "\n", 19 | "celebrity = [\"Tom Cruise\",\"Leonardo Di Caprio\",\"Jennifer Lawrence\",\"Natalie Portman\"]\n", 20 | "print(celebrity)" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 4, 26 | "metadata": {}, 27 | "outputs": [ 28 | { 29 | "name": "stdout", 30 | "output_type": "stream", 31 | "text": [ 32 | "Tom Cruise\n", 33 | "Natalie Portman\n" 34 | ] 35 | } 36 | ], 37 | "source": [ 38 | "# Printing a particular name\n", 39 | "\n", 40 | "print(celebrity[0])\n", 41 | "print(celebrity[3])" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 6, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "name": "stdout", 51 | "output_type": "stream", 52 | "text": [ 53 | "Natalie Portman\n" 54 | ] 55 | } 56 | ], 57 | "source": [ 58 | "# printing the last name \n", 59 | "\n", 60 | "print(celebrity[-1])" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 9, 66 | "metadata": {}, 67 | "outputs": [ 68 | { 69 | "name": "stdout", 70 | "output_type": "stream", 71 | "text": [ 72 | "['Leonardo Di Caprio', 'Jennifer Lawrence', 'Natalie Portman']\n", 73 | "['Leonardo Di Caprio', 'Jennifer Lawrence']\n" 74 | ] 75 | } 76 | ], 77 | "source": [ 78 | "# Printing names together\n", 79 | "\n", 80 | "print(celebrity[1:])\n", 81 | "print(celebrity[1:3])" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 10, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "name": "stdout", 91 | "output_type": "stream", 92 | "text": [ 93 | "['Tom Cruise', 'Morgan Freeman', 'Jennifer Lawrence', 'Natalie Portman']\n" 94 | ] 95 | } 96 | ], 97 | "source": [ 98 | "# Modifying names\n", 99 | "\n", 100 | "celebrity[1] = \"Morgan Freeman\"\n", 101 | "print(celebrity)" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": 11, 107 | "metadata": {}, 108 | "outputs": [ 109 | { 110 | "name": "stdout", 111 | "output_type": "stream", 112 | "text": [ 113 | "['Tom Cruise', 'Morgan Freeman', 'Jennifer Lawrence', 'Natalie Portman', 'Mission Impossible', 'Shashawnk Redemption', 'X-Men', 'Star Wars']\n" 114 | ] 115 | } 116 | ], 117 | "source": [ 118 | "# Merging list\n", 119 | "\n", 120 | "movies = [\"Mission Impossible\",\"Shashawnk Redemption\", \"X-Men\",\"Star Wars\"]\n", 121 | "celebrity.extend(movies)\n", 122 | "print(celebrity)" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 14, 128 | "metadata": {}, 129 | "outputs": [ 130 | { 131 | "name": "stdout", 132 | "output_type": "stream", 133 | "text": [ 134 | "['Tom Cruise', 'Tom Hanks', 'Tom Hanks', 'Morgan Freeman', 'Jennifer Lawrence', 'Natalie Portman', 'Mission Impossible', 'Shashawnk Redemption', 'X-Men', 'Star Wars']\n" 135 | ] 136 | } 137 | ], 138 | "source": [ 139 | "# Insert new name\n", 140 | "celebrity.insert(1,\"Tom Hanks\")\n", 141 | "print(celebrity)" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 16, 147 | "metadata": {}, 148 | "outputs": [ 149 | { 150 | "name": "stdout", 151 | "output_type": "stream", 152 | "text": [ 153 | "['Tom Cruise', 'Morgan Freeman', 'Jennifer Lawrence', 'Natalie Portman', 'Mission Impossible', 'Shashawnk Redemption', 'X-Men', 'Star Wars']\n" 154 | ] 155 | } 156 | ], 157 | "source": [ 158 | "# Remove name \n", 159 | "celebrity.remove(\"Tom Hanks\")\n", 160 | "print(celebrity)" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 17, 166 | "metadata": {}, 167 | "outputs": [ 168 | { 169 | "name": "stdout", 170 | "output_type": "stream", 171 | "text": [ 172 | "['Tom Cruise', 'Morgan Freeman', 'Jennifer Lawrence', 'Natalie Portman', 'Mission Impossible', 'Shashawnk Redemption', 'X-Men', 'Star Wars', 'To Kill a Mocking Bird']\n" 173 | ] 174 | } 175 | ], 176 | "source": [ 177 | "# Appending name \n", 178 | "celebrity.append(\"To Kill a Mocking Bird\")\n", 179 | "print(celebrity)" 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": 18, 185 | "metadata": {}, 186 | "outputs": [ 187 | { 188 | "name": "stdout", 189 | "output_type": "stream", 190 | "text": [ 191 | "['Tom Cruise', 'Morgan Freeman', 'Jennifer Lawrence', 'Natalie Portman', 'Mission Impossible', 'Shashawnk Redemption', 'X-Men', 'Star Wars']\n" 192 | ] 193 | } 194 | ], 195 | "source": [ 196 | "# Pop\n", 197 | "# Removes an element\n", 198 | "celebrity.pop()\n", 199 | "print(celebrity)" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 20, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "name": "stdout", 209 | "output_type": "stream", 210 | "text": [ 211 | "7\n" 212 | ] 213 | } 214 | ], 215 | "source": [ 216 | "# Check if names exists\n", 217 | "print(celebrity.index(\"Star Wars\"))" 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": 21, 223 | "metadata": {}, 224 | "outputs": [ 225 | { 226 | "name": "stdout", 227 | "output_type": "stream", 228 | "text": [ 229 | "2\n" 230 | ] 231 | } 232 | ], 233 | "source": [ 234 | "# Count the number of same name\n", 235 | "\n", 236 | "# First will add same name i.e append\n", 237 | "celebrity.append(\"Morgan Freeman\")\n", 238 | "print(celebrity.count(\"Morgan Freeman\"))" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 23, 244 | "metadata": {}, 245 | "outputs": [ 246 | { 247 | "name": "stdout", 248 | "output_type": "stream", 249 | "text": [ 250 | "['Jennifer Lawrence', 'Mission Impossible', 'Morgan Freeman', 'Morgan Freeman', 'Natalie Portman', 'Shashawnk Redemption', 'Star Wars', 'Tom Cruise', 'X-Men']\n" 251 | ] 252 | } 253 | ], 254 | "source": [ 255 | "# Sort alphabetically\n", 256 | "\n", 257 | "celebrity.sort()\n", 258 | "print(celebrity)" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": 24, 264 | "metadata": {}, 265 | "outputs": [ 266 | { 267 | "name": "stdout", 268 | "output_type": "stream", 269 | "text": [ 270 | "['X-Men', 'Tom Cruise', 'Star Wars', 'Shashawnk Redemption', 'Natalie Portman', 'Morgan Freeman', 'Morgan Freeman', 'Mission Impossible', 'Jennifer Lawrence']\n" 271 | ] 272 | } 273 | ], 274 | "source": [ 275 | "# Reverse list\n", 276 | "\n", 277 | "celebrity.reverse()\n", 278 | "print(celebrity)" 279 | ] 280 | }, 281 | { 282 | "cell_type": "code", 283 | "execution_count": 25, 284 | "metadata": {}, 285 | "outputs": [ 286 | { 287 | "name": "stdout", 288 | "output_type": "stream", 289 | "text": [ 290 | "['X-Men', 'Tom Cruise', 'Star Wars', 'Shashawnk Redemption', 'Natalie Portman', 'Morgan Freeman', 'Morgan Freeman', 'Mission Impossible', 'Jennifer Lawrence']\n" 291 | ] 292 | } 293 | ], 294 | "source": [ 295 | "# Copy list\n", 296 | "\n", 297 | "celebrity_copy = celebrity.copy()\n", 298 | "print(celebrity_copy)" 299 | ] 300 | } 301 | ], 302 | "metadata": { 303 | "kernelspec": { 304 | "display_name": "Python 3", 305 | "language": "python", 306 | "name": "python3" 307 | }, 308 | "language_info": { 309 | "codemirror_mode": { 310 | "name": "ipython", 311 | "version": 3 312 | }, 313 | "file_extension": ".py", 314 | "mimetype": "text/x-python", 315 | "name": "python", 316 | "nbconvert_exporter": "python", 317 | "pygments_lexer": "ipython3", 318 | "version": "3.6.5" 319 | } 320 | }, 321 | "nbformat": 4, 322 | "nbformat_minor": 2 323 | } 324 | -------------------------------------------------------------------------------- /Python-Tutorial_04.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "(77.312, 33.412)\n", 13 | "77.312\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "# Tuple\n", 19 | "# Note : Tuples are immutable \n", 20 | "\n", 21 | "geo_coordinates = (77.312,33.412)\n", 22 | "print(geo_coordinates)\n", 23 | "\n", 24 | "# To print specific element\n", 25 | "print(geo_coordinates[0])" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 3, 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "name": "stdout", 35 | "output_type": "stream", 36 | "text": [ 37 | "[(77, 33), (44, 55), (66, 77), (88, 99)]\n" 38 | ] 39 | } 40 | ], 41 | "source": [ 42 | "# Tuples inside list \n", 43 | "\n", 44 | "geo_coordinates = [(77,33),(44,55),(66,77),(88,99)]\n", 45 | "print(geo_coordinates)" 46 | ] 47 | } 48 | ], 49 | "metadata": { 50 | "kernelspec": { 51 | "display_name": "Python 3", 52 | "language": "python", 53 | "name": "python3" 54 | }, 55 | "language_info": { 56 | "codemirror_mode": { 57 | "name": "ipython", 58 | "version": 3 59 | }, 60 | "file_extension": ".py", 61 | "mimetype": "text/x-python", 62 | "name": "python", 63 | "nbconvert_exporter": "python", 64 | "pygments_lexer": "ipython3", 65 | "version": "3.6.5" 66 | } 67 | }, 68 | "nbformat": 4, 69 | "nbformat_minor": 2 70 | } 71 | -------------------------------------------------------------------------------- /Python-Tutorial_05.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 8, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# Defining function\n", 12 | "# We define add function with two input a,b and later when we call add function it should print addition \n", 13 | "# a : Parameter\n", 14 | "# b : Parameter\n", 15 | "# C : output\n", 16 | "\n", 17 | "def add(a,b):\n", 18 | " c = a + b\n", 19 | " print(c)" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 9, 25 | "metadata": {}, 26 | "outputs": [ 27 | { 28 | "name": "stdout", 29 | "output_type": "stream", 30 | "text": [ 31 | "9\n" 32 | ] 33 | } 34 | ], 35 | "source": [ 36 | "# Calling the previously defined function\n", 37 | "\n", 38 | "add(4,5)" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 23, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "def hollywood(actor,movie):\n", 48 | " print (str(actor)+\" acted in the movie \"+ str(movie))" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 25, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "name": "stdout", 58 | "output_type": "stream", 59 | "text": [ 60 | "Gregory Peck acted in the movie To Kill a Mocking Bird\n" 61 | ] 62 | } 63 | ], 64 | "source": [ 65 | "hollywood(\"Gregory Peck\", \"To Kill a Mocking Bird\")" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 36, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "# Here we define a function containing return statement which returns the results\n", 75 | "# Return function breaks the code and returns the value back \n", 76 | "\n", 77 | "def cube(integer):\n", 78 | " result = integer * integer * integer\n", 79 | " return result" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 37, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "data": { 89 | "text/plain": [ 90 | "729" 91 | ] 92 | }, 93 | "execution_count": 37, 94 | "metadata": {}, 95 | "output_type": "execute_result" 96 | } 97 | ], 98 | "source": [ 99 | "cube(9)" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 38, 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "name": "stdout", 109 | "output_type": "stream", 110 | "text": [ 111 | "Watch Avengers\n" 112 | ] 113 | } 114 | ], 115 | "source": [ 116 | "# If statement \n", 117 | "\n", 118 | "Marvel_movie = True\n", 119 | "\n", 120 | "if Marvel_movie:\n", 121 | " print(\"Watch Avengers\")" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 41, 127 | "metadata": {}, 128 | "outputs": [ 129 | { 130 | "name": "stdout", 131 | "output_type": "stream", 132 | "text": [ 133 | "Watch Aquaman\n" 134 | ] 135 | } 136 | ], 137 | "source": [ 138 | "# If-else statement \n", 139 | "\n", 140 | "Marvel_movie = False\n", 141 | "\n", 142 | "if Marvel_movie:\n", 143 | " print(\"Watch Avengers\")\n", 144 | "else:\n", 145 | " print(\"Watch Aquaman\")" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 42, 151 | "metadata": {}, 152 | "outputs": [ 153 | { 154 | "name": "stdout", 155 | "output_type": "stream", 156 | "text": [ 157 | " Watch Avengers and Aquaman\n" 158 | ] 159 | } 160 | ], 161 | "source": [ 162 | "# If-else statement \n", 163 | "\n", 164 | "Marvel_movie = True\n", 165 | "DC_movie = True\n", 166 | "\n", 167 | "if Marvel_movie and DC_movie:\n", 168 | " print(\" Watch Avengers and Aquaman\")\n", 169 | "else:\n", 170 | " print(\"Watch Jurassic Park\")" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": 45, 176 | "metadata": {}, 177 | "outputs": [ 178 | { 179 | "name": "stdout", 180 | "output_type": "stream", 181 | "text": [ 182 | "Watch Doctor Strange\n" 183 | ] 184 | } 185 | ], 186 | "source": [ 187 | "# If-else-elif statement\n", 188 | "# Change the boolean of Marvel_movie and DC_movie\n", 189 | "\n", 190 | "Marvel_movie = True\n", 191 | "DC_movie = False\n", 192 | "\n", 193 | "if Marvel_movie and DC_movie:\n", 194 | " print(\"Watch Avengers and Aquaman\")\n", 195 | "elif Marvel_movie and not(DC_movie):\n", 196 | " print(\"Watch Doctor Strange\")\n", 197 | "elif not(Marvel_movie) and DC_movie:\n", 198 | " print(\"Watch Justice League\")\n", 199 | "else:\n", 200 | " print(\"Watch Jurassic Park\")" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 48, 206 | "metadata": { 207 | "collapsed": true 208 | }, 209 | "outputs": [], 210 | "source": [ 211 | "# Comparision operators \n", 212 | "# Here \"=\",\"<\",\">\",\"!=\" are comparision operators \n", 213 | "# Compare three integers \n", 214 | "\n", 215 | "def max_num(int1,int2,int3):\n", 216 | " if int1 >= int2 and int1 >= int3:\n", 217 | " return int1\n", 218 | " elif int2 >= int1 and int2 >= int3:\n", 219 | " return int2\n", 220 | " else:\n", 221 | " return int3" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 50, 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "8" 233 | ] 234 | }, 235 | "execution_count": 50, 236 | "metadata": {}, 237 | "output_type": "execute_result" 238 | } 239 | ], 240 | "source": [ 241 | "max_num(8,6,5)" 242 | ] 243 | } 244 | ], 245 | "metadata": { 246 | "kernelspec": { 247 | "display_name": "Python 3", 248 | "language": "python", 249 | "name": "python3" 250 | }, 251 | "language_info": { 252 | "codemirror_mode": { 253 | "name": "ipython", 254 | "version": 3 255 | }, 256 | "file_extension": ".py", 257 | "mimetype": "text/x-python", 258 | "name": "python", 259 | "nbconvert_exporter": "python", 260 | "pygments_lexer": "ipython3", 261 | "version": "3.6.5" 262 | } 263 | }, 264 | "nbformat": 4, 265 | "nbformat_minor": 2 266 | } 267 | -------------------------------------------------------------------------------- /Python-Tutorial_06.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Enter First number: 23.56\n", 13 | "Enter Operator: +\n", 14 | "Enter Second number: 56.78\n", 15 | "80.34\n" 16 | ] 17 | } 18 | ], 19 | "source": [ 20 | "# Designing a Calculator \n", 21 | "\n", 22 | "int1 = float(input(\"Enter First number: \"))\n", 23 | "op = input(\"Enter Operator: \")\n", 24 | "int2 = float(input(\"Enter Second number: \"))\n", 25 | "\n", 26 | "if op == \"+\":\n", 27 | " print(int1 + int2)\n", 28 | "elif op == \"-\":\n", 29 | " print(int1 - int2)\n", 30 | "elif op == \"/\":\n", 31 | " print(int1 / int2)\n", 32 | "elif op == \"*\":\n", 33 | " print(int1 * int2)\n", 34 | "else:\n", 35 | " print(\"come on I am still learning, please input only arithmetic operators\")" 36 | ] 37 | } 38 | ], 39 | "metadata": { 40 | "kernelspec": { 41 | "display_name": "Python 3", 42 | "language": "python", 43 | "name": "python3" 44 | }, 45 | "language_info": { 46 | "codemirror_mode": { 47 | "name": "ipython", 48 | "version": 3 49 | }, 50 | "file_extension": ".py", 51 | "mimetype": "text/x-python", 52 | "name": "python", 53 | "nbconvert_exporter": "python", 54 | "pygments_lexer": "ipython3", 55 | "version": "3.6.5" 56 | } 57 | }, 58 | "nbformat": 4, 59 | "nbformat_minor": 2 60 | } 61 | -------------------------------------------------------------------------------- /Python-Tutorial_07.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# Dictionary\n", 12 | "# Here we have key-value pairs\n", 13 | "\n", 14 | "month_numerics = {\n", 15 | " \"January\":\"01\",\n", 16 | " \"Februray\":\"02\",\n", 17 | " \"March\":\"03\",\n", 18 | " \"April\":\"04\",\n", 19 | " \"May\":\"05\",\n", 20 | " \"June\":\"06\",\n", 21 | " \"July\":\"07\",\n", 22 | " \"August\":\"08\",\n", 23 | " \"September\":\"09\",\n", 24 | " \"October\":\"10\",\n", 25 | " \"November\":\"11\",\n", 26 | " \"December\":\"12\"\n", 27 | " }" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 3, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "{'January': '01', 'Februray': '02', 'March': '03', 'April': '04', 'May': '05', 'June': '06', 'July': '07', 'August': '08', 'September': '09', 'October': '10', 'November': '11', 'December': '12'}\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "# Printing dicitonary key-value pairs\n", 45 | "\n", 46 | "print(month_numerics)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 5, 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "name": "stdout", 56 | "output_type": "stream", 57 | "text": [ 58 | "03\n", 59 | "09\n" 60 | ] 61 | } 62 | ], 63 | "source": [ 64 | "# Printing specifc value \n", 65 | "# Using get keyword will help you know whether its avai\n", 66 | "print(month_numerics[\"March\"])\n", 67 | "print(month_numerics.get(\"September\"))" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": { 74 | "collapsed": true 75 | }, 76 | "outputs": [], 77 | "source": [] 78 | } 79 | ], 80 | "metadata": { 81 | "kernelspec": { 82 | "display_name": "Python 3", 83 | "language": "python", 84 | "name": "python3" 85 | }, 86 | "language_info": { 87 | "codemirror_mode": { 88 | "name": "ipython", 89 | "version": 3 90 | }, 91 | "file_extension": ".py", 92 | "mimetype": "text/x-python", 93 | "name": "python", 94 | "nbconvert_exporter": "python", 95 | "pygments_lexer": "ipython3", 96 | "version": "3.6.5" 97 | } 98 | }, 99 | "nbformat": 4, 100 | "nbformat_minor": 2 101 | } 102 | -------------------------------------------------------------------------------- /Python-Tutorial_08.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "0\n", 13 | "10\n", 14 | "20\n", 15 | "30\n", 16 | "40\n", 17 | "50\n", 18 | "Program completed\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "# While loop \n", 24 | "\n", 25 | "i = 0\n", 26 | "while i <= 50:\n", 27 | " print(i)\n", 28 | " i += 10\n", 29 | " \n", 30 | "print(\"Program completed\")" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 13, 36 | "metadata": {}, 37 | "outputs": [ 38 | { 39 | "name": "stdout", 40 | "output_type": "stream", 41 | "text": [ 42 | "Enter answer: C++\n", 43 | "Enter answer: Javascript\n", 44 | "Enter answer: Go\n", 45 | "You have run out of chances\n" 46 | ] 47 | } 48 | ], 49 | "source": [ 50 | "# Find the secret word, interact with the program until you find the secret word\n", 51 | "\n", 52 | "answer = \"Python\"\n", 53 | "meta = \"\"\n", 54 | "chance = 0\n", 55 | "chance_limit = 3\n", 56 | "guess = False\n", 57 | " \n", 58 | "while meta != answer and not(guess):\n", 59 | " if chance < chance_limit:\n", 60 | " meta = input(\"Enter answer: \")\n", 61 | " chance += 1\n", 62 | " else:\n", 63 | " guess = True\n", 64 | "\n", 65 | "if guess:\n", 66 | " print(\"You have run out of chances\")\n", 67 | "else:\n", 68 | " print(\"You won!\")" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "Python 3", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.6.5" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 2 93 | } 94 | -------------------------------------------------------------------------------- /Python-Tutorial_09.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "S\n", 13 | "c\n", 14 | "h\n", 15 | "i\n", 16 | "n\n", 17 | "d\n", 18 | "l\n", 19 | "e\n", 20 | "r\n", 21 | " \n", 22 | "L\n", 23 | "i\n", 24 | "s\n", 25 | "t\n" 26 | ] 27 | } 28 | ], 29 | "source": [ 30 | "# For loop\n", 31 | "\n", 32 | "for i in \"Schindler List\":\n", 33 | " print(i)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 3, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "name": "stdout", 43 | "output_type": "stream", 44 | "text": [ 45 | "Tom Cruise\n", 46 | "Leonardo Di Caprio\n", 47 | "Jennifer Lawrence\n", 48 | "Natalie Portman\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "celebrity = [\"Tom Cruise\",\"Leonardo Di Caprio\",\"Jennifer Lawrence\",\"Natalie Portman\"]\n", 54 | "\n", 55 | "for actors in celebrity:\n", 56 | " print(actors)" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 4, 62 | "metadata": { 63 | "collapsed": true 64 | }, 65 | "outputs": [], 66 | "source": [ 67 | "# Writing a exponent function using for loop\n", 68 | "\n", 69 | "def exponent(int_num,power):\n", 70 | " result = 1\n", 71 | " for i in range(power):\n", 72 | " result = result * int_num\n", 73 | " return result" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": 6, 79 | "metadata": {}, 80 | "outputs": [ 81 | { 82 | "data": { 83 | "text/plain": [ 84 | "15625" 85 | ] 86 | }, 87 | "execution_count": 6, 88 | "metadata": {}, 89 | "output_type": "execute_result" 90 | } 91 | ], 92 | "source": [ 93 | "exponent(5,6)" 94 | ] 95 | } 96 | ], 97 | "metadata": { 98 | "kernelspec": { 99 | "display_name": "Python 3", 100 | "language": "python", 101 | "name": "python3" 102 | }, 103 | "language_info": { 104 | "codemirror_mode": { 105 | "name": "ipython", 106 | "version": 3 107 | }, 108 | "file_extension": ".py", 109 | "mimetype": "text/x-python", 110 | "name": "python", 111 | "nbconvert_exporter": "python", 112 | "pygments_lexer": "ipython3", 113 | "version": "3.6.5" 114 | } 115 | }, 116 | "nbformat": 4, 117 | "nbformat_minor": 2 118 | } 119 | -------------------------------------------------------------------------------- /Python-Tutorial_10.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "4\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "# List of list\n", 18 | "# Accessing a specific element from the list \n", 19 | "\n", 20 | "grid = [\n", 21 | " [1,2,3,4],\n", 22 | " [2,2,4,4],\n", 23 | " [3,5,6,7]\n", 24 | "]\n", 25 | "\n", 26 | "print(grid[0][3])" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 4, 32 | "metadata": { 33 | "scrolled": true 34 | }, 35 | "outputs": [ 36 | { 37 | "name": "stdout", 38 | "output_type": "stream", 39 | "text": [ 40 | "1\n", 41 | "2\n", 42 | "3\n", 43 | "4\n", 44 | "2\n", 45 | "2\n", 46 | "4\n", 47 | "4\n", 48 | "3\n", 49 | "5\n", 50 | "6\n", 51 | "7\n" 52 | ] 53 | } 54 | ], 55 | "source": [ 56 | "# Nested for loop\n", 57 | "# Printing every single element in the list \n", 58 | "\n", 59 | "for i in grid:\n", 60 | " for j in i:\n", 61 | " print(j)" 62 | ] 63 | } 64 | ], 65 | "metadata": { 66 | "kernelspec": { 67 | "display_name": "Python 3", 68 | "language": "python", 69 | "name": "python3" 70 | }, 71 | "language_info": { 72 | "codemirror_mode": { 73 | "name": "ipython", 74 | "version": 3 75 | }, 76 | "file_extension": ".py", 77 | "mimetype": "text/x-python", 78 | "name": "python", 79 | "nbconvert_exporter": "python", 80 | "pygments_lexer": "ipython3", 81 | "version": "3.6.5" 82 | } 83 | }, 84 | "nbformat": 4, 85 | "nbformat_minor": 2 86 | } 87 | -------------------------------------------------------------------------------- /Python-Tutorial_11.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 10, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# Desiging a a naive encryption program\n", 12 | "\n", 13 | "def encrypt(word):\n", 14 | " decrypt = \"\"\n", 15 | " for letter in word:\n", 16 | " if letter.upper() in \"AEIOU\":\n", 17 | " if letter.isupper():\n", 18 | " decrypt = decrypt + \"G\"\n", 19 | " else:\n", 20 | " decrypt = decrypt + \"g\"\n", 21 | " else:\n", 22 | " decrypt = decrypt + letter\n", 23 | " \n", 24 | " return decrypt" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 11, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "name": "stdout", 34 | "output_type": "stream", 35 | "text": [ 36 | "Enter a word: Exam\n", 37 | "Gxgm\n" 38 | ] 39 | } 40 | ], 41 | "source": [ 42 | "print(encrypt(input(\"Enter a word: \")))" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 14, 48 | "metadata": {}, 49 | "outputs": [ 50 | { 51 | "name": "stdout", 52 | "output_type": "stream", 53 | "text": [ 54 | "Enter a number: 3.34\n", 55 | "Invalid Input\n" 56 | ] 57 | } 58 | ], 59 | "source": [ 60 | "# Using except keyword in python\n", 61 | "# To catch specific errors, use things like valuerror, zerodivisionerror etc so that you can narrow down the possiblity\n", 62 | "# of an error\n", 63 | "\n", 64 | "try:\n", 65 | " integer = int(input(\"Enter a number: \"))\n", 66 | " print(integer)\n", 67 | "except ValueError:\n", 68 | " print(\"Invalid Input\")\n", 69 | "except ZeroDivisionError:\n", 70 | " print(\"Invalid\")\n", 71 | " " 72 | ] 73 | } 74 | ], 75 | "metadata": { 76 | "kernelspec": { 77 | "display_name": "Python 3", 78 | "language": "python", 79 | "name": "python3" 80 | }, 81 | "language_info": { 82 | "codemirror_mode": { 83 | "name": "ipython", 84 | "version": 3 85 | }, 86 | "file_extension": ".py", 87 | "mimetype": "text/x-python", 88 | "name": "python", 89 | "nbconvert_exporter": "python", 90 | "pygments_lexer": "ipython3", 91 | "version": "3.6.5" 92 | } 93 | }, 94 | "nbformat": 4, 95 | "nbformat_minor": 2 96 | } 97 | -------------------------------------------------------------------------------- /Python-Tutorial_12.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "True\n", 13 | "Morgan Freeman - Shashawnk Redemption\n", 14 | "Robert Downy Jr. - Iron Man\n", 15 | "Russel Crowe - A Beautiful Mind \n", 16 | "\n", 17 | "\n", 18 | "\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "# Handling files\n", 24 | "# \"w\" refers to write\n", 25 | "# \"a\" refers to add i.e you can append information\n", 26 | "# \"r\" refers to read\n", 27 | "# \"r+\" read and write \n", 28 | "# Note : After you open a file you need to close it \n", 29 | "\n", 30 | "movie_directory = open(\"movies.txt\",\"r\")\n", 31 | "\n", 32 | "# To know whether the text file is readable \n", 33 | "print(movie_directory.readable())\n", 34 | "\n", 35 | "# Print the data in the file\n", 36 | "print(movie_directory.read())\n", 37 | "\n", 38 | "# To read individual file \n", 39 | "print(movie_directory.readline())\n", 40 | "# To read the second line \n", 41 | "print(movie_directory.readline())\n", 42 | "\n", 43 | "# To read all the line and put into an array\n", 44 | "\n", 45 | "movie_directory.close()" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 8, 51 | "metadata": {}, 52 | "outputs": [ 53 | { 54 | "name": "stdout", 55 | "output_type": "stream", 56 | "text": [ 57 | "['Morgan Freeman - Shashawnk Redemption\\n', 'Robert Downy Jr. - Iron Man\\n', 'Russel Crowe - A Beautiful Mind \\n']\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "# Convert the movie.txt file into array \n", 63 | "\n", 64 | "movie_directory = open(\"movies.txt\",\"r\")\n", 65 | "print(movie_directory.readlines())\n", 66 | "movie_directory.close()" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 11, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "# Appending data to file\n", 76 | "# Note : Be careful, if you run append program multiple times, it keeps adding the data that you are writing multiple times\n", 77 | "# Use escape characters to insert data into next line\n", 78 | "# If you use \"w\" it will replace the entire data into your text file with the new data your writing into the file\n", 79 | "\n", 80 | "movie_directory = open(\"movies.txt\",\"a\")\n", 81 | "movie_directory.write(\"Gergory Peck - To Kill a Mocking Bird\")\n", 82 | "movie_directory.close()" 83 | ] 84 | } 85 | ], 86 | "metadata": { 87 | "kernelspec": { 88 | "display_name": "Python 3", 89 | "language": "python", 90 | "name": "python3" 91 | }, 92 | "language_info": { 93 | "codemirror_mode": { 94 | "name": "ipython", 95 | "version": 3 96 | }, 97 | "file_extension": ".py", 98 | "mimetype": "text/x-python", 99 | "name": "python", 100 | "nbconvert_exporter": "python", 101 | "pygments_lexer": "ipython3", 102 | "version": "3.6.5" 103 | } 104 | }, 105 | "nbformat": 4, 106 | "nbformat_minor": 2 107 | } 108 | -------------------------------------------------------------------------------- /Python-Tutorial_13.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "3\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "# Creating a .py and then importing them \n", 18 | "# Create a \"utils.py\" file with functions written on it and then import them \n", 19 | "# We are importing a fucntion from utils.py file\n", 20 | "\n", 21 | "import utils\n", 22 | "\n", 23 | "# Here we are importing a funciton from external python file \n", 24 | "print(utils.ran(6))" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 7, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "name": "stdout", 34 | "output_type": "stream", 35 | "text": [ 36 | "3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:14:23) \n", 37 | "[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]\n" 38 | ] 39 | }, 40 | { 41 | "data": { 42 | "text/plain": [ 43 | "'/Users/neutrino/anaconda3/bin/python3.6'" 44 | ] 45 | }, 46 | "execution_count": 7, 47 | "metadata": {}, 48 | "output_type": "execute_result" 49 | } 50 | ], 51 | "source": [ 52 | "# To know your python version and where python in installed\n", 53 | "\n", 54 | "import sys\n", 55 | "print(sys.version)\n", 56 | "sys.executable" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 8, 62 | "metadata": { 63 | "collapsed": true 64 | }, 65 | "outputs": [], 66 | "source": [ 67 | "# You can install various python libraries using \"pip install \"your package\"\"\n", 68 | "# Pip is a python package \n", 69 | "# Example to run a package, you need to go to your command line / terminal and type the following\n", 70 | "# pip install tensorflow\n", 71 | "# When you run this command tensorflow, the package would be installed in site-packages of python" 72 | ] 73 | } 74 | ], 75 | "metadata": { 76 | "kernelspec": { 77 | "display_name": "Python 3", 78 | "language": "python", 79 | "name": "python3" 80 | }, 81 | "language_info": { 82 | "codemirror_mode": { 83 | "name": "ipython", 84 | "version": 3 85 | }, 86 | "file_extension": ".py", 87 | "mimetype": "text/x-python", 88 | "name": "python", 89 | "nbconvert_exporter": "python", 90 | "pygments_lexer": "ipython3", 91 | "version": "3.6.5" 92 | } 93 | }, 94 | "nbformat": 4, 95 | "nbformat_minor": 2 96 | } 97 | -------------------------------------------------------------------------------- /Python-Tutorial_14.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Wall-E\n", 13 | "Pixar\n", 14 | "\n", 15 | "BB-8\n", 16 | "Star Wars\n" 17 | ] 18 | } 19 | ], 20 | "source": [ 21 | "# Classes and Objects\n", 22 | "# We create a class file named Robot.py and initialize a function with various attributes\n", 23 | "# We then create an object file here as shown below\n", 24 | "# Classes are used to create an overall template and objects are used to create an actual attribute\n", 25 | "# Create an Object using Class, we import a class file created using Robot.py python file\n", 26 | "\n", 27 | "from Robot import Robot\n", 28 | "\n", 29 | "robot1 = Robot(\"Wall-E\",\"Acting\",\"Pixar\", True, 8)\n", 30 | "robot2 = Robot(\"BB-8\",\"Acting\",\"Star Wars\", True, 9)\n", 31 | "\n", 32 | "print(robot1.name)\n", 33 | "print(robot1.company)\n", 34 | "print(\"\")\n", 35 | "print(robot2.name)\n", 36 | "print(robot2.company)" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": { 43 | "collapsed": true 44 | }, 45 | "outputs": [], 46 | "source": [] 47 | } 48 | ], 49 | "metadata": { 50 | "kernelspec": { 51 | "display_name": "Python 3", 52 | "language": "python", 53 | "name": "python3" 54 | }, 55 | "language_info": { 56 | "codemirror_mode": { 57 | "name": "ipython", 58 | "version": 3 59 | }, 60 | "file_extension": ".py", 61 | "mimetype": "text/x-python", 62 | "name": "python", 63 | "nbconvert_exporter": "python", 64 | "pygments_lexer": "ipython3", 65 | "version": "3.6.5" 66 | } 67 | }, 68 | "nbformat": 4, 69 | "nbformat_minor": 2 70 | } 71 | -------------------------------------------------------------------------------- /Python-Tutorial_15-Star_Wars_Quiz.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 15, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "# Building a Star Wars Quiz using what all we have learnt \n", 10 | "# We need to create a question class which we have done in Quiz.py file \n", 11 | "\n", 12 | "from Quiz import Question\n", 13 | "question_prompt = [\n", 14 | " \"What species is Jabba?\\n(a) Ithorian\\n(b) Jawa\\n(c) Jenet\\n(d) Hutt\\n\\n\",\n", 15 | " \"Which order brought about the death of the Jedi?\\n(a) Order55\\n(b) Order66\\n(c) Order77\\n(d) Order88\\n\\n\",\n", 16 | " \"On which planet do we first meet Rey in The Force Awakens?\\n(a) Farlax\\n(b) Tatooine\\n(c) Dantooine\\n(d) Jakku\\n\\n\"\n", 17 | "]\n", 18 | "\n", 19 | "questions = [\n", 20 | " Question(question_prompt[0], \"d\"),\n", 21 | " Question(question_prompt[1], \"b\"),\n", 22 | " Question(question_prompt[2], \"d\")\n", 23 | "]" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 18, 29 | "metadata": { 30 | "collapsed": true 31 | }, 32 | "outputs": [], 33 | "source": [ 34 | "def test(questions):\n", 35 | " correct_answers = 0\n", 36 | " for question in questions:\n", 37 | " answer = input(question.prompt)\n", 38 | " if answer == question.answer:\n", 39 | " correct_answers += 1\n", 40 | " print(\"\\nOnly \"+str(correct_answers)+\"/\"+str(len(questions))+\" Correct\")" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 19, 46 | "metadata": {}, 47 | "outputs": [ 48 | { 49 | "name": "stdout", 50 | "output_type": "stream", 51 | "text": [ 52 | "What species is Jabba?\n", 53 | "(a) Ithorian\n", 54 | "(b) Jawa\n", 55 | "(c) Jenet\n", 56 | "(d) Hutt\n", 57 | "\n", 58 | "d\n", 59 | "\n", 60 | "Only 1/3 Correct\n", 61 | "Which order brought about the death of the Jedi?\n", 62 | "(a) Order55\n", 63 | "(b) Order66\n", 64 | "(c) Order77\n", 65 | "(d) Order88\n", 66 | "\n", 67 | "b\n", 68 | "\n", 69 | "Only 2/3 Correct\n", 70 | "On which planet do we first meet Rey in The Force Awakens?\n", 71 | "(a) Farlax\n", 72 | "(b) Tatooine\n", 73 | "(c) Dantooine\n", 74 | "(d) Jakku\n", 75 | "\n", 76 | "d\n", 77 | "\n", 78 | "Only 3/3 Correct\n" 79 | ] 80 | } 81 | ], 82 | "source": [ 83 | "test(questions)" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": { 90 | "collapsed": true 91 | }, 92 | "outputs": [], 93 | "source": [] 94 | } 95 | ], 96 | "metadata": { 97 | "kernelspec": { 98 | "display_name": "Python 3", 99 | "language": "python", 100 | "name": "python3" 101 | }, 102 | "language_info": { 103 | "codemirror_mode": { 104 | "name": "ipython", 105 | "version": 3 106 | }, 107 | "file_extension": ".py", 108 | "mimetype": "text/x-python", 109 | "name": "python", 110 | "nbconvert_exporter": "python", 111 | "pygments_lexer": "ipython3", 112 | "version": "3.6.5" 113 | } 114 | }, 115 | "nbformat": 4, 116 | "nbformat_minor": 2 117 | } 118 | -------------------------------------------------------------------------------- /Python-Tutorial_16.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 4, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "True\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "# Create a function inside a class i.e we create a function named \"awesome\" inside Robot.py file\n", 18 | "\n", 19 | "from Robot import Robot\n", 20 | "\n", 21 | "robot1 = Robot(\"Wall-E\",\"Acting\",\"Pixar\", True, 8)\n", 22 | "robot2 = Robot(\"BB-8\",\"Acting\",\"Star Wars\", True, 9)\n", 23 | "\n", 24 | "print(robot2.awesome())" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 3, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "name": "stdout", 34 | "output_type": "stream", 35 | "text": [ 36 | "He can fight\n", 37 | "He can romance\n" 38 | ] 39 | } 40 | ], 41 | "source": [ 42 | "# Inheritance is basically inheriting all the funcitonality from one class to another class\n", 43 | "# We create a class named Actor and then inherit all the funtions of Actor class to myActor class\n", 44 | "# We are also inheriting functions from Actor to new class myHollywood\n", 45 | "\n", 46 | "from Actor import Actor\n", 47 | "from Hollywood import Hollywood\n", 48 | "\n", 49 | "myActor = Actor()\n", 50 | "myActor.fight()\n", 51 | "\n", 52 | "myHollywood = Hollywood()\n", 53 | "myHollywood.romance()" 54 | ] 55 | } 56 | ], 57 | "metadata": { 58 | "kernelspec": { 59 | "display_name": "Python 3", 60 | "language": "python", 61 | "name": "python3" 62 | }, 63 | "language_info": { 64 | "codemirror_mode": { 65 | "name": "ipython", 66 | "version": 3 67 | }, 68 | "file_extension": ".py", 69 | "mimetype": "text/x-python", 70 | "name": "python", 71 | "nbconvert_exporter": "python", 72 | "pygments_lexer": "ipython3", 73 | "version": "3.6.5" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 2 78 | } 79 | -------------------------------------------------------------------------------- /Quiz.py: -------------------------------------------------------------------------------- 1 | class Question: 2 | def __init__(self, prompt, answer): 3 | self.prompt = prompt 4 | self.answer = answer 5 | 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-awesome 2 | 3 | Learn Python, Easy to learn, Awesome 4 | 5 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/gautam1858/python-awesome) 6 | 7 | ![Python](https://user-images.githubusercontent.com/4949778/50740273-10ad1280-1212-11e9-8b84-0a82f5d02c2f.png) 8 | 9 | Welcome to python-awesome. These notebooks are part of my Machine Learning curriculum that I am teaching in an University as part of their Graduate Program. 10 | 11 | ## What are python notebooks? 12 | 13 | Python code is not compiled, it is interpreted. Thanks of that feature you can execute python commands as you type them. If you have python installed on your machine you can actually take a look. Python notebook (also called IPython or Jupyter notebook) is a document with python interpreter "in it". That means that you can write python code inside of text document and execute it! For more info and how to run it on your machine click [here](https://jupyter.org). 14 | 15 | ## Run notebooks 16 | 17 | If you want to run these notebooks but without installing jupyter on your machine you can use Google Colab. Just go in [here](https://colab.research.google.com/github/gautam1858/python-awesome) 18 | 19 | 20 | Author: [Gautam Ramachandra](http://gautam1858.github.io) 21 | Contact: [gmail](gautamrbharadwaj@gmail.com) 22 | -------------------------------------------------------------------------------- /Robot.py: -------------------------------------------------------------------------------- 1 | # Classes and object 2 | # Classes are used to create your own dataype 3 | 4 | class Robot: 5 | 6 | def __init__(self, name, use, company, is_working, points): 7 | self.name = name 8 | self.use = use 9 | self.company = company 10 | self.is_working = is_working 11 | self.points = points 12 | 13 | def awesome(self): 14 | if self.points >= 9: 15 | return True 16 | else: 17 | return False -------------------------------------------------------------------------------- /movies.txt: -------------------------------------------------------------------------------- 1 | Morgan Freeman - Shashawnk Redemption 2 | Robert Downy Jr. - Iron Man 3 | Russel Crowe - A Beautiful Mind 4 | Gergory Peck - To Kill a Mocking BirdGergory Peck - To Kill a Mocking Bird -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def ran(int): 4 | return random.randint(1,int) --------------------------------------------------------------------------------