├── 00-00-python-pycharm-installation.md ├── 00-01-course-guide.md ├── 00-02-all-code.md ├── 00-03-course-overview.png ├── 00-python-shell ├── Section1.py ├── Section10 - Tips.py ├── Section2.py ├── Section3.py ├── Section4 String and Text - End.py ├── Section5 - Loops - Start to End.py ├── Section6 - OOPS Basics - Start to End.py ├── Section7 - Data Structures - Done.py ├── Section8 - OOPS Advanced - Done.py └── Section9 - Exception Handling - Done.py ├── 01-first-python-project ├── elif_examples.py ├── for_exercises.py ├── hello_world.py ├── if_puzzles.py ├── input.py ├── loop_puzzles.py ├── multiplication_table.py ├── number_menu.py ├── number_menu_loop.py ├── simple_interest.py ├── temp.txt └── while_exercises.py ├── 02-oops ├── Student.py ├── book.py ├── country.py ├── motor_bike.py ├── planet.py └── word_count.py ├── 04-exception-handling ├── currency.py ├── exception_handling_basics.py └── exception_handling_puzzles.py ├── 05-tips ├── all_about_methods.py ├── module_1.py └── module_2.py ├── 06-oops-advanced ├── amphibian.py ├── animal.py ├── book_reviews.py ├── fan.py ├── person_inheritance.py ├── recipe.py └── test.py ├── LICENSE └── README.md /00-00-python-pycharm-installation.md: -------------------------------------------------------------------------------- 1 | ## Installing Python 2 | 3 | https://www.python.org/downloads/ 4 | 5 | #### Google for "java 9 jdk download" 6 | ![Image](/images/01_Java9JDKDownload.png) 7 | --- 8 | #### Land on the Oracle JDK Download Site 9 | ![Image](/images/02_Oracle_Site.png) 10 | --- 11 | #### Accept License Agreement 12 | ![Image](/images/03_AcceptLicenseAgreement_Error.png) 13 | ![Image](/images/04_AcceptLicenseAgreement.png) 14 | --- 15 | #### Download JDK for Your Specific Operating System 16 | ![Image](/images/05_Download_JDK_9.png) 17 | --- 18 | #### Launch the Downloaded file 19 | ![Image](/images/06_DoubleClick_And_Start_Installation.png) 20 | --- 21 | #### Java Installation Screens 22 | ![Image](/images/10_Installation_First_Screen.png) 23 | --- 24 | ![Image](/images/11_Installation_Ready_Screen.png) 25 | --- 26 | #### Choose Defaults and Copy Install Location 27 | ![Image](/images/12_Installation_Features_Select_Screen.png) 28 | --- 29 | ![Image](/images/13_Installation_Status_Screen.png) 30 | --- 31 | #### Choose Defaults and Copy Install Location 32 | ![Image](/images/14_Installation_Choose_Custom_Setup.png) 33 | --- 34 | ![Image](/images/15_Installation_Status_Screen.png) 35 | --- 36 | #### Congratulations 37 | ![Image](/images/16_Congratulations.png) 38 | --- 39 | 40 | ## Verify Java and JShell Installation 41 | 42 | #### Launch Terminal or Command Prompt 43 | ![Image](/images/21_Launch_Command_Prompt_Windows.png) 44 | --- 45 | ![Image](/images/21_Launch_Terminal_Mac.png) 46 | --- 47 | ##### Detailed Instructions 48 | 1. If you are on Windows : Open the Command Prompt window by 49 | * Click the Start button 50 | * Select All Programs -> Accessories > Command Prompt. 51 | * Or use Ctrl + Esc, and type in cmd and launch up command. 52 | 2. If you are on Mac or other OS, launch up Terminal. 53 | * cmd + space -> Type terminal -> Press enter 54 | 55 | #### Java Version Successful 56 | ![Image](/images/22_Java_Version_Mac.png) 57 | --- 58 | ![Image](/images/22_Java_Version_Windows.png) 59 | --- 60 | #### JShell Version Successful 61 | ![Image](/images/23_JShell_Version_Success_Windows.png) 62 | --- 63 | ![Image](/images/24_JShell_Version_Success_Mac_1.png) 64 | --- 65 | #### Launching JShell 66 | ![Image](/images/26_JShell_Launch_Screen.png) 67 | --- 68 | ![Image](/images/25_JShell_Example_Command.png) 69 | --- 70 | #### Error In Launching JShell 71 | ![Image](/images/24_JShell_Version_Error.png) 72 | --- 73 | > If you are in windows, ```java -version``` is working and ```jshell -version``` is not working, directly jump to the section ```Setting PATH environment variable in Windows``` 74 | 75 | ### Troubleshooting 76 | 1. Check if there are any pre-existing Java installs. Uninstall them and reinstall again. 77 | 2. Temporarily turn off firewalls and antivirus software. 78 | 3. If you get file corrupt message, download the installation file again. 79 | 4. Check if you are on 32-bit OS or 64-bit OS. Remember, Java 9 is not supported on 32 bit windows. 80 | 5. Check if you need PATH variable to point to right Java Version - https://www.java.com/en/download/help/path.xml 81 | 82 | ### More Help 83 | - Windows - https://docs.oracle.com/javase/9/install/installation-jdk-and-jre-microsoft-windows-platforms.htm 84 | - Mac - https://docs.oracle.com/javase/9/install/installation-jdk-and-jre-macos.htm#JSJIG-GUID-2FE451B0-9572-4E38-A1A5-568B77B146DE 85 | - Linux - https://docs.oracle.com/javase/9/install/installation-jdk-and-jre-linux-platforms.htm#JSJIG-GUID-737A84E4-2EFF-4D38-8E60-3E29D1B884B8 86 | 87 | 88 | ## Setting PATH environment variable in Windows 89 | 90 | #### Goal - What we want to do? 91 | ![Image](/images/30_JShell_In_JDK_Bin_Folder.png) 92 | --- 93 | #### More Help 94 | - https://www.java.com/en/download/help/path.xml 95 | - https://www.computerhope.com/issues/ch000549.htm 96 | --- 97 | 98 | #### Browsing to Java Folder 99 | ![Image](/images/31_Browsing_To_Java_Folder.png) 100 | --- 101 | #### Browsing to JDK Bin Folder 102 | ![Image](/images/32_Browsing_To_JDK_Bin_Folder.png) 103 | --- 104 | #### Launch Environment Variables 105 | Two Options 106 | - Short Route - ```Click``` Start Button or ```Ctrl + Esc``` to launch start menu and type in ```Env```. Choose ```Edit System Environment Variables```. 107 | - Long Route - Select ```Control Panel``` and then ```System```. Click ```Advanced``` and then ```Environment Variables```. 108 | ![Image](/images/33_Windows_Environment_Variables.png) 109 | --- 110 | ![Image](/images/34_Click_Environment_Variables.png) 111 | --- 112 | #### Select and Edit Path Variable 113 | ![Image](/images/35_Scroll_And_Select_Path_And_Edit.png) 114 | --- 115 | ![Image](/images/36_Default_Path_value.png) 116 | --- 117 | #### Add JDK Bin Folder To Path 118 | ![Image](/images/37_Add_JDK_Bin_Folder_To_Path.png) 119 | --- 120 | ![Image](/images/38_Click_ok.png) 121 | --- 122 | ![Image](/images/39_Click_ok.png) 123 | --- 124 | ![Image](/images/40_Click_ok.png) 125 | --- 126 | 127 | ## Installing Eclipse 128 | 129 | Eclipse is the most popular open source Java IDE. 130 | 131 | Choose the latest available version of Eclipse - Eclipse Oxygen (4.7) or Later. 132 | 133 | > Tip : Do not use an old eclipse version! 134 | 135 | ### Prerequisites 136 | - Java JDK 9 137 | 138 | ### Installation 139 | 140 | 1. Search google for “download eclipse” and choose the first result. The direct link is http://www.eclipse.org/downloads/eclipse-packages/. 141 | ![Image](/images/51_google-search-download-eclipse.png) 142 | 143 | 2. Choose the right Operation System. 144 | ![Image](/images/52_eclipse-choose-installation.png) 145 | 146 | 3. We recommend to choose “Eclipse IDE for Java EE Developers”. Choose 32 bit or 64 bit based on your operating system. (Right-click My Computer, and then click Properties. If "x64 Edition" is listed under System, your processor is capable of running a 64-bit version of Windows.) 147 | 148 | 4. Wait for the download to complete. Extract the zip file to a folder (Example : c:\eclipse). 149 | 5. When you unzip Eclipse, the directory layout looks something like this: 150 | 151 | ``` 152 | eclipse/ 153 | features/ ''the directory containing Eclipse features'' 154 | plugins/ ''the directory containing Eclipse plugins'' 155 | eclipse.exe ''platform executable'' 156 | eclipse.ini 157 | eclipsec.exe ''(windows only) console executable'' 158 | epl-v10.html ''the EPL license'' 159 | jre/ ''the JRE to run Eclipse with'' 160 | notice.html 161 | readme 162 | ``` 163 | 6. You can start Eclipse by running eclipse.exe on Windows or eclipse on other platforms. This small launcher essentially finds and loads the JVM. On Windows, the eclipsec.exe console executable can be used for improved command line behavior. 164 | 165 | > More Details - https://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F 166 | 167 | ### Troubleshooting 168 | - Use 7Zip instead of windows built-in decompression utility. 169 | - Unzip to root folder (e.g. c:\) compared to a long directory path (e.g. c:\Program Files\Eclipse). 170 | - Reference - https://wiki.eclipse.org/Eclipse/Installation#Troubleshooting 171 | -------------------------------------------------------------------------------- /00-03-course-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/in28minutes/learn-programming-with-python-/fbe79ba59fbc850d91c5bd10765fdfbc8d0d1fee/00-03-course-overview.png -------------------------------------------------------------------------------- /00-python-shell/Section1.py: -------------------------------------------------------------------------------- 1 | Last login: Mon May 14 10:20:03 on ttys002 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ 5 X 5 3 | -bash: 5: command not found 4 | Rangas-MacBook-Pro:~ rangaraokaranam$ clear 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 24 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 25 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 26 | Type "help", "copyright", "credits" or "license" for more information. 27 | >>> 5 X 5 28 | File "", line 1 29 | 5 X 5 30 | ^ 31 | SyntaxError: invalid syntax 32 | >>> 5 * 6 33 | 30 34 | >>> 5 + 6 35 | 11 36 | >>> 5 - 6 37 | -1 38 | >>> 10 / 2 39 | 5.0 40 | >>> 10 ** 3 41 | 1000 42 | >>> 5 + 5 + 5 43 | 15 44 | >>> 5 + 5 * 5 45 | 30 46 | >>> import os 47 | >>> os.system('clear') 48 | 49 | 0 50 | >>> 24 * 60 51 | 1440 52 | >>> 24 * 60 * 60 53 | 86400 54 | >>> os.system('clear') 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 0 72 | >>> 5 + 6 + 10 73 | 21 74 | >>> 5 *$ 2 75 | File "", line 1 76 | 5 *$ 2 77 | ^ 78 | SyntaxError: invalid syntax 79 | >>> 5$2 80 | File "", line 1 81 | 5$2 82 | ^ 83 | SyntaxError: invalid syntax 84 | >>> 5+6+10 85 | 21 86 | >>> 5/2 87 | 2.5 88 | >>> 5 + 5 * 6 89 | 35 90 | >>> 5 - 2 * 2 91 | 1 92 | >>> (5 - 2) * 2 93 | 6 94 | >>> 5 - ( 2 * 2 ) 95 | 1 96 | >>> os.system('clear') 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 0 108 | >>> 5 * 6 109 | 30 110 | >>> 5 * 6 = 30 111 | File "", line 1 112 | SyntaxError: can't assign to operator 113 | >>> Hello 114 | Traceback (most recent call last): 115 | File "", line 1, in 116 | NameError: name 'Hello' is not defined 117 | >>> 5 * 6 118 | 30 119 | >>> Hello 120 | Traceback (most recent call last): 121 | File "", line 1, in 122 | NameError: name 'Hello' is not defined 123 | >>> print Hello 124 | File "", line 1 125 | print Hello 126 | ^ 127 | SyntaxError: Missing parentheses in call to 'print'. Did you mean print(Hello)? 128 | >>> print (Hello) 129 | Traceback (most recent call last): 130 | File "", line 1, in 131 | NameError: name 'Hello' is not defined 132 | >>> print ("Hello") 133 | Hello 134 | >>> print("Hello") 135 | Hello 136 | >>> print("5 * 6 = 30") 137 | 5 * 6 = 30 138 | >>> os.system('clear') 139 | 140 | 0 141 | >>> print("5 * 6 = 30") 142 | 5 * 6 = 30 143 | >>> print("5*6") 144 | 5*6 145 | >>> print(5*6) 146 | 30 147 | >>> print('5*6') 148 | 5*6 149 | >>> abs 10.5 150 | File "", line 1 151 | abs 10.5 152 | ^ 153 | SyntaxError: invalid syntax 154 | >>> abs(10.5) 155 | 10.5 156 | >>> abs("10.5") 157 | Traceback (most recent call last): 158 | File "", line 1, in 159 | TypeError: bad operand type for abs(): 'str' 160 | >>> pow 2 5 161 | File "", line 1 162 | pow 2 5 163 | ^ 164 | SyntaxError: invalid syntax 165 | >>> pow(2 5) 166 | File "", line 1 167 | pow(2 5) 168 | ^ 169 | SyntaxError: invalid syntax 170 | >>> pow(2, 5) 171 | 32 172 | >>> pow(10, 3) 173 | 1000 174 | >>> 10 ** 3 175 | 1000 176 | >>> max(34, 45, 67) 177 | 67 178 | >>> min(34, 45, 67) 179 | 34 180 | >>> pow(2,5) 181 | 32 182 | >>> Pow(2,5) 183 | Traceback (most recent call last): 184 | File "", line 1, in 185 | NameError: name 'Pow' is not defined 186 | >>> print("Hello") 187 | Hello 188 | >>> print("hello") 189 | hello 190 | >>> print("hellO") 191 | hellO 192 | >>> print ( "hellO" ) 193 | hellO 194 | >>> print ( "hellO World" ) 195 | hellO World 196 | >>> print ( "hellO World" ) 197 | hellO World 198 | >>> print("Hello"") 199 | File "", line 1 200 | print("Hello"") 201 | ^ 202 | SyntaxError: EOL while scanning string literal 203 | >>> print("Hello\"") 204 | Hello" 205 | >>> print("Hello\nWorld") 206 | Hello 207 | World 208 | >>> print("Hello\tWorld") 209 | Hello World 210 | >>> print("Hello\\World") 211 | Hello\World 212 | >>> print("Hello\\\\\\World") 213 | Hello\\\World 214 | >>> print('Hello"') 215 | Hello" 216 | >>> print("Hello'World") 217 | Hello'World 218 | >>> print("Hello\"World") 219 | Hello"World 220 | >>> print("Hello\"World") 221 | Hello"World 222 | >>> os.system('clear') 223 | 224 | 0 225 | >>> print("5 * 6 = 30") 226 | 5 * 6 = 30 227 | >>> print("VALUE".format(5*2)) 228 | VALUE 229 | >>> print("VALUE {0}".format(5*2)) 230 | VALUE 10 231 | >>> print("VALUE {0}".format(10,20,30)) 232 | VALUE 10 233 | >>> print("VALUE {1}".format(10,20,30)) 234 | VALUE 20 235 | >>> print("VALUE {2}".format(10,20,30)) 236 | VALUE 30 237 | >>> print("5 * 6 = {2}".format(5,6,5*6)) 238 | 5 * 6 = 30 239 | >>> print("{0} * {1} = {2}".format(5,6,5*6)) 240 | 5 * 6 = 30 241 | >>> print("{0} * {1} = {2}".format(5,7,5*7)) 242 | 5 * 7 = 35 243 | >>> print("{0} * {1} = {2}".format(5,8,5*8)) 244 | 5 * 8 = 40 245 | >>> print("{0} * {1} = {2}".format(5,8,5*8)) 246 | 5 * 8 = 40 247 | >>> print("{0} * {1} = {2}".format(5,8,5*8,5*9,5*10)) 248 | 5 * 8 = 40 249 | >>> print("{0} * {1} = {4}".format(5,8,5*8,5*9,5*10)) 250 | 5 * 8 = 50 251 | >>> print("{0} * {1} = {4}".format(5,8)) 252 | Traceback (most recent call last): 253 | File "", line 1, in 254 | IndexError: tuple index out of range 255 | >>> print("{0} * {1} = {2}".format(2.5,2,2.5*2)) 256 | 2.5 * 2 = 5.0 257 | >>> print("My name is {0}".format("Ranga")) 258 | My name is Ranga 259 | >>> os.system('clear') 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 0 271 | >>> print("{0} * {1} = {2}".format(5,7,5*7)) 272 | 5 * 7 = 35 273 | >>> print("{0} * {1} = {2}".format(5,1,5*1)) 274 | 5 * 1 = 5 275 | >>> print("{0} * {1} = {2}".format(5,2,5*2)) 276 | 5 * 2 = 10 277 | >>> print("{0} * {1} = {2}".format(5,3,5*3)) 278 | 5 * 3 = 15 279 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 280 | Traceback (most recent call last): 281 | File "", line 1, in 282 | NameError: name 'index' is not defined 283 | >>> index = 2 284 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 285 | 5 * 2 = 10 286 | >>> index = 3 287 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 288 | 5 * 3 = 15 289 | >>> index 290 | 3 291 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 292 | 5 * 3 = 15 293 | >>> index = 5 294 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 295 | 5 * 5 = 25 296 | >>> index = 1 297 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 298 | 5 * 1 = 5 299 | >>> index = 2 300 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 301 | 5 * 2 = 10 302 | >>> index = 3 303 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 304 | 5 * 3 = 15 305 | >>> a = 5 306 | >>> b = 6 307 | >>> c = 7 308 | >>> print("5 + 6 + 7 = 18") 309 | 5 + 6 + 7 = 18 310 | >>> print("5 + 6 + 7 = 18".format(a,b,c,a+b+c)) 311 | 5 + 6 + 7 = 18 312 | >>> print("{0} + {1} + {2} = {3}".format(a,b,c,a+b+c)) 313 | 5 + 6 + 7 = 18 314 | >>> a = 6 315 | >>> b = 7 316 | >>> c = 8 317 | >>> print("{0} + {1} + {2} = {3}".format(a,b,c,a+b+c)) 318 | 6 + 7 + 8 = 21 319 | >>> os.system('clear') 320 | 321 | 0 322 | >>> i = 1 323 | >>> i 324 | 1 325 | >>> print(i*2) 326 | 2 327 | >>> i = 4 328 | >>> print(i*2) 329 | 8 330 | >>> count 331 | Traceback (most recent call last): 332 | File "", line 1, in 333 | NameError: name 'count' is not defined 334 | >>> print(count) 335 | Traceback (most recent call last): 336 | File "", line 1, in 337 | NameError: name 'count' is not defined 338 | >>> count = 4 339 | >>> print(count) 340 | 4 341 | >>> Count 342 | Traceback (most recent call last): 343 | File "", line 1, in 344 | NameError: name 'Count' is not defined 345 | >>> count 346 | 4 347 | >>> Count 348 | Traceback (most recent call last): 349 | File "", line 1, in 350 | NameError: name 'Count' is not defined 351 | >>> 1count = 5 352 | File "", line 1 353 | 1count = 5 354 | ^ 355 | SyntaxError: invalid syntax 356 | >>> count = 5 357 | >>> _count = 5 358 | >>> 1count 359 | File "", line 1 360 | 1count 361 | ^ 362 | SyntaxError: invalid syntax 363 | >>> 2count 364 | File "", line 1 365 | 2count 366 | ^ 367 | SyntaxError: invalid syntax 368 | >>> c12345 = 5 369 | >>> os.system('clear') 370 | 371 | 0 372 | >>> i = 5 373 | >>> j = i 374 | >>> j 375 | 5 376 | >>> j = 2 * i 377 | >>> j 378 | 10 379 | >>> j = i 380 | >>> j = 2 * i 381 | >>> j = 3 * i 382 | >>> j 383 | 15 384 | >>> 5 = j 385 | File "", line 1 386 | SyntaxError: can't assign to literal 387 | >>> j = 10 388 | >>> j 389 | 10 390 | >>> num1 = 5 391 | >>> num2 = 3 392 | >>> sum = num1 + num2 393 | >>> sum 394 | 8 395 | >>> a = 5 396 | >>> b = 6 397 | >>> c = 7 398 | >>> sum = a + b + c 399 | >>> sum 400 | 18 401 | >>> print("5 + 6 + 7 = 18") 402 | 5 + 6 + 7 = 18 403 | >>> print("{0} + {1} + {2} = {3}", a, b, c ,sum) 404 | {0} + {1} + {2} = {3} 5 6 7 18 405 | >>> print("{0} + {1} + {2} = {3}".format(a, b, c ,sum)) 406 | 5 + 6 + 7 = 18 407 | >>> num1 408 | 5 409 | >>> num1 = 10 410 | >>> num1 411 | 10 412 | >>> number_1 413 | Traceback (most recent call last): 414 | File "", line 1, in 415 | NameError: name 'number_1' is not defined 416 | >>> number_1 = 15 417 | >>> number_1 418 | 15 419 | >>> os.system('clear') 420 | 421 | 0 422 | >>> a = 1 423 | >>> b = 2 424 | >>> c = 3 425 | >>> sum = a + b + c 426 | >>> print("{0} + {1} + {2} = {3}".format(a, b, c ,sum)) 427 | 1 + 2 + 3 = 6 428 | >>> print(f"") 429 | 430 | >>> print(f"value of a is {a}") 431 | value of a is 1 432 | >>> print(f"value of b is {b}") 433 | value of b is 2 434 | >>> print(f"sum of a and b is {a + b}") 435 | sum of a and b is 3 436 | >>> print(f"{a} + {b} + {c} = {sum}") 437 | 1 + 2 + 3 = 6 438 | >>> os.system('clear') 439 | 440 | 441 | 442 | 443 | 0 444 | >>> index = 1 445 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 446 | 5 * 1 = 5 447 | >>> index = 2 448 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 449 | 5 * 2 = 10 450 | >>> index = 3 451 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 452 | 5 * 3 = 15 453 | >>> index = 4 454 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 455 | 5 * 4 = 20 456 | >>> index = index + 1 457 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 458 | 5 * 5 = 25 459 | >>> index = index + 1 460 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 461 | 5 * 6 = 30 462 | >>> index = index + 1 463 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 464 | 5 * 7 = 35 465 | >>> os.system('clear') 466 | 467 | 0 468 | >>> range(1,10) 469 | range(1, 10) 470 | >>> for i in range(1,10): 471 | ... print(i) 472 | ... 473 | 1 474 | 2 475 | 3 476 | 4 477 | 5 478 | 6 479 | 7 480 | 8 481 | 9 482 | >>> print("{0} * {1} = {2}".format(5,index,5*index)) 483 | 5 * 7 = 35 484 | >>> print(f"{5} * {index} = {5*index}") 485 | 5 * 7 = 35 486 | >>> for i in range(1,11): 487 | ... print(f"{i}") 488 | ... 489 | 1 490 | 2 491 | 3 492 | 4 493 | 5 494 | 6 495 | 7 496 | 8 497 | 9 498 | 10 499 | >>> for i in range(1,11): 500 | ... print(f"5 * {i}") 501 | ... 502 | 5 * 1 503 | 5 * 2 504 | 5 * 3 505 | 5 * 4 506 | 5 * 5 507 | 5 * 6 508 | 5 * 7 509 | 5 * 8 510 | 5 * 9 511 | 5 * 10 512 | >>> for i in range(1,11): 513 | ... print(f"5 * {i} = {5 * i}") 514 | ... 515 | 5 * 1 = 5 516 | 5 * 2 = 10 517 | 5 * 3 = 15 518 | 5 * 4 = 20 519 | 5 * 5 = 25 520 | 5 * 6 = 30 521 | 5 * 7 = 35 522 | 5 * 8 = 40 523 | 5 * 9 = 45 524 | 5 * 10 = 50 525 | >>> 5 * 4 * 50 526 | 1000 527 | >>> os.system('clear') 528 | 529 | 0 530 | >>> for i in range(1,10): 531 | ... print(i) 532 | ... 533 | 1 534 | 2 535 | 3 536 | 4 537 | 5 538 | 6 539 | 7 540 | 8 541 | 9 542 | >>> for i in range(1,10) 543 | File "", line 1 544 | for i in range(1,10) 545 | ^ 546 | SyntaxError: invalid syntax 547 | >>> for i in range(1,10): 548 | ... print(i) 549 | File "", line 2 550 | print(i) 551 | ^ 552 | IndentationError: expected an indented block 553 | >>> for i in range(1,10): 554 | ... print(i) 555 | ... 556 | 1 557 | 2 558 | 3 559 | 4 560 | 5 561 | 6 562 | 7 563 | 8 564 | 9 565 | >>> for i in range(1,10): 566 | ... print(i) 567 | ... print(2*i) 568 | ... 569 | 1 570 | 2 571 | 2 572 | 4 573 | 3 574 | 6 575 | 4 576 | 8 577 | 5 578 | 10 579 | 6 580 | 12 581 | 7 582 | 14 583 | 8 584 | 16 585 | 9 586 | 18 587 | >>> for i in range(2,5): print(i) 588 | ... 589 | 2 590 | 3 591 | 4 592 | >>> for i in range(2,5): 593 | ... print(i) 594 | ... 595 | 2 596 | 3 597 | 4 598 | >>> for i in range(2,5): 599 | ... print(i) 600 | ... 601 | 2 602 | 3 603 | 4 604 | >>> for i in range(1,11): 605 | ... print(i) 606 | ... 607 | 1 608 | 2 609 | 3 610 | 4 611 | 5 612 | 6 613 | 7 614 | 8 615 | 9 616 | 10 617 | >>> for i in range (1,11,2): 618 | ... print(i) 619 | ... 620 | 1 621 | 3 622 | 5 623 | 7 624 | 9 625 | >>> for i in range (2,11,2): 626 | ... print(i) 627 | ... 628 | 2 629 | 4 630 | 6 631 | 8 632 | 10 633 | >>> for i in range (10,0,-1): 634 | ... print(i) 635 | ... 636 | 10 637 | 9 638 | 8 639 | 7 640 | 6 641 | 5 642 | 4 643 | 3 644 | 2 645 | 1 646 | >>> for i in range (1,11): 647 | ... print(i * i) 648 | ... 649 | 1 650 | 4 651 | 9 652 | 16 653 | 25 654 | 36 655 | 49 656 | 64 657 | 81 658 | 100 659 | >>> for i in range (10,0,-1): 660 | ... print(i*i) 661 | ... 662 | 100 663 | 81 664 | 64 665 | 49 666 | 36 667 | 25 668 | 16 669 | 9 670 | 4 671 | 1 672 | >>> for i in range (10,0,-2): 673 | ... 674 | File "", line 2 675 | 676 | ^ 677 | IndentationError: expected an indented block 678 | >>> for i in range (10,0,-2): 679 | ... print(i*i) 680 | ... 681 | 100 682 | 64 683 | 36 684 | 16 685 | 4 686 | >>> for i in range(1,11): 687 | ... print(f"5 * {i} = {5 * i}") 688 | ... 689 | 5 * 1 = 5 690 | 5 * 2 = 10 691 | 5 * 3 = 15 692 | 5 * 4 = 20 693 | 5 * 5 = 25 694 | 5 * 6 = 30 695 | 5 * 7 = 35 696 | 5 * 8 = 40 697 | 5 * 9 = 45 698 | 5 * 10 = 50 699 | >>> for i in range (1,11): 700 | ... print(f"6 * {i} = {6 * i}") 701 | ... 702 | 6 * 1 = 6 703 | 6 * 2 = 12 704 | 6 * 3 = 18 705 | 6 * 4 = 24 706 | 6 * 5 = 30 707 | 6 * 6 = 36 708 | 6 * 7 = 42 709 | 6 * 8 = 48 710 | 6 * 9 = 54 711 | 6 * 10 = 60 712 | >>> for i in range (1,11): 713 | ... print(f"8 * {i} = {8 * i}") 714 | ... 715 | 8 * 1 = 8 716 | 8 * 2 = 16 717 | 8 * 3 = 24 718 | 8 * 4 = 32 719 | 8 * 5 = 40 720 | 8 * 6 = 48 721 | 8 * 7 = 56 722 | 8 * 8 = 64 723 | 8 * 9 = 72 724 | 8 * 10 = 80 725 | >>> 726 | -------------------------------------------------------------------------------- /00-python-shell/Section10 - Tips.py: -------------------------------------------------------------------------------- 1 | Last login: Sat May 19 09:06:12 on ttys001 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> print(4.5 - 3.2) 7 | 1.2999999999999998 8 | >>> value1 = Decimal('4.5') 9 | Traceback (most recent call last): 10 | File "", line 1, in 11 | NameError: name 'Decimal' is not defined 12 | >>> import decimal 13 | >>> from decimal import Decimal 14 | >>> value1 = Decimal('4.5') 15 | >>> value2 = Decimal('3.2') 16 | >>> value1 - value2 17 | Decimal('1.3') 18 | >>> import math 19 | >>> math. 20 | math.acos( math.erf( math.inf math.pi 21 | math.acosh( math.erfc( math.isclose( math.pow( 22 | math.asin( math.exp( math.isfinite( math.radians( 23 | math.asinh( math.expm1( math.isinf( math.sin( 24 | math.atan( math.fabs( math.isnan( math.sinh( 25 | math.atan2( math.factorial( math.ldexp( math.sqrt( 26 | math.atanh( math.floor( math.lgamma( math.tan( 27 | math.ceil( math.fmod( math.log( math.tanh( 28 | math.copysign( math.frexp( math.log10( math.tau 29 | math.cos( math.fsum( math.log1p( math.trunc( 30 | math.cosh( math.gamma( math.log2( 31 | math.degrees( math.gcd( math.modf( 32 | math.e math.hypot( math.nan 33 | >>> math.pi 34 | 3.141592653589793 35 | >>> math.e 36 | 2.718281828459045 37 | >>> help(math.factorial) 38 | 39 | >>> help(math.ceil) 40 | 41 | >>> math.ceil(5.5) 42 | 6 43 | >>> math.ceil(-5.5) 44 | -5 45 | >>> import os 46 | >>> os.system('clear') 47 | 48 | 0 49 | >>> import statistics 50 | >>> statistics. 51 | statistics.Decimal( statistics.mean( 52 | statistics.Fraction( statistics.median( 53 | statistics.StatisticsError( statistics.median_grouped( 54 | statistics.bisect_left( statistics.median_high( 55 | statistics.bisect_right( statistics.median_low( 56 | statistics.chain( statistics.mode( 57 | statistics.collections statistics.numbers 58 | statistics.decimal statistics.pstdev( 59 | statistics.groupby( statistics.pvariance( 60 | statistics.harmonic_mean( statistics.stdev( 61 | statistics.math statistics.variance( 62 | >>> marks = [1, 6, 9, 23, 2] 63 | >>> statistics.mean(marks) 64 | 8.2 65 | >>> statistics.median(marks) 66 | 6 67 | >>> marks = [1, 6, 9, 23, 2, 7] 68 | >>> statistics.median(marks) 69 | 6.5 70 | >>> statistics.median_high(marks) 71 | 7 72 | >>> statistics.median_low(marks) 73 | 6 74 | >>> statistics.variance(marks) 75 | 63.2 76 | >>> os.system('clear') 77 | 78 | 0 79 | >>> from collections import deque 80 | >>> queue = deque(['Zero','One','Two']) 81 | >>> queue.pop() 82 | 'Two' 83 | >>> queue.append('Three') 84 | >>> queue 85 | deque(['Zero', 'One', 'Three']) 86 | >>> queue.append('Four') 87 | >>> queue.append('Five') 88 | >>> queue.appendLeft('Minus One') 89 | Traceback (most recent call last): 90 | File "", line 1, in 91 | AttributeError: 'collections.deque' object has no attribute 'appendLeft' 92 | >>> queue.append 93 | queue.append( queue.appendleft( 94 | >>> queue.appendleft('Minus One') 95 | >>> queue 96 | deque(['Minus One', 'Zero', 'One', 'Three', 'Four', 'Five']) 97 | >>> queue.pop() 98 | 'Five' 99 | >>> queue.popleft() 100 | 'Minus One' 101 | >>> os.system('clear') 102 | 103 | 0 104 | >>> import datetime 105 | >>> datetime.datetime.today() 106 | datetime.datetime(2018, 5, 21, 9, 59, 57, 450683) 107 | >>> today_date = datetime.datetime.today() 108 | >>> today_date 109 | datetime.datetime(2018, 5, 21, 10, 0, 39, 732463) 110 | >>> today_date.year 111 | 2018 112 | >>> today_date.month 113 | 5 114 | >>> today_date.day 115 | 21 116 | >>> today_date.hour 117 | 10 118 | >>> today_date.minute 119 | 0 120 | >>> today_date.second 121 | 39 122 | >>> some_date = datetime.datetime(2019, 5, 27) 123 | >>> some_date 124 | datetime.datetime(2019, 5, 27, 0, 0) 125 | >>> some_date = datetime.datetime(2019, 5, 27, 9, 5,25) 126 | >>> some_date 127 | datetime.datetime(2019, 5, 27, 9, 5, 25) 128 | >>> some_date = datetime.datetime(2019, 5, 27, 9, 5,25, 234567) 129 | >>> some_date 130 | datetime.datetime(2019, 5, 27, 9, 5, 25, 234567) 131 | >>> some_date.date() 132 | datetime.date(2019, 5, 27) 133 | >>> some_date.time() 134 | datetime.time(9, 5, 25, 234567) 135 | >>> some_date 136 | datetime.datetime(2019, 5, 27, 9, 5, 25, 234567) 137 | >>> day = some_date 138 | >>> day 139 | datetime.datetime(2019, 5, 27, 9, 5, 25, 234567) 140 | >>> day + time.timedelta(day=90) 141 | Traceback (most recent call last): 142 | File "", line 1, in 143 | NameError: name 'time' is not defined 144 | >>> day + datetime.timedelta(day=90) 145 | Traceback (most recent call last): 146 | File "", line 1, in 147 | TypeError: 'day' is an invalid keyword argument for this function 148 | >>> day + datetime.timedelta(days=90) 149 | datetime.datetime(2019, 8, 25, 9, 5, 25, 234567) 150 | >>> day 151 | datetime.datetime(2019, 5, 27, 9, 5, 25, 234567) 152 | >>> day + datetime.timedelta(days=90) 153 | datetime.datetime(2019, 8, 25, 9, 5, 25, 234567) 154 | >>> day + datetime.timedelta(weeks=3) 155 | datetime.datetime(2019, 6, 17, 9, 5, 25, 234567) 156 | >>> day + datetime.timedelta(hours=48) 157 | datetime.datetime(2019, 5, 29, 9, 5, 25, 234567) 158 | >>> os.system('clear') 159 | 160 | 0 161 | >>> import math 162 | >>> math. 163 | math.acos( math.erf( math.inf math.pi 164 | math.acosh( math.erfc( math.isclose( math.pow( 165 | math.asin( math.exp( math.isfinite( math.radians( 166 | math.asinh( math.expm1( math.isinf( math.sin( 167 | math.atan( math.fabs( math.isnan( math.sinh( 168 | math.atan2( math.factorial( math.ldexp( math.sqrt( 169 | math.atanh( math.floor( math.lgamma( math.tan( 170 | math.ceil( math.fmod( math.log( math.tanh( 171 | math.copysign( math.frexp( math.log10( math.tau 172 | math.cos( math.fsum( math.log1p( math.trunc( 173 | math.cosh( math.gamma( math.log2( 174 | math.degrees( math.gcd( math.modf( 175 | math.e math.hypot( math.nan 176 | >>> math.floor(4.5) 177 | 4 178 | >>> help(math.floor) 179 | 180 | >>> help(math) 181 | 182 | >>> 183 | >>> from math import * 184 | >>> floor(5) 185 | 5 186 | >>> gcd(34,56) 187 | 2 188 | >>> from math import gcd 189 | >>> gcd(56,68) 190 | 4 191 | >>> os.system('clear') 192 | 193 | 194 | 195 | 196 | 197 | 0 198 | >>> numbers = [1,4,6,3,4] 199 | >>> for number in numbers: 200 | ... print(number) 201 | ... 202 | 1 203 | 4 204 | 6 205 | 3 206 | 4 207 | >>> for index,number in enumerate(numbers): 208 | ... print(f'{index} - {number}') 209 | ... 210 | 0 - 1 211 | 1 - 4 212 | 2 - 6 213 | 3 - 3 214 | 4 - 4 215 | >>> values = list('aeiou') 216 | >>> values 217 | ['a', 'e', 'i', 'o', 'u'] 218 | >>> for index, vowel in enumerate(values): 219 | ... printf(f'{index} - {vowel}') 220 | ... 221 | Traceback (most recent call last): 222 | File "", line 2, in 223 | NameError: name 'printf' is not defined 224 | >>> for index, vowel in enumerate(values): 225 | ... print(f'{index} - {vowel}') 226 | ... 227 | 0 - a 228 | 1 - e 229 | 2 - i 230 | 3 - o 231 | 4 - u 232 | >>> import os 233 | >>> os.system('clear') 234 | 235 | 0 236 | >>> number = 5 237 | >>> if(number%2==0): 238 | ... isEven = True 239 | ... else: 240 | ... isEven = False 241 | ... 242 | >>> isEven = True if number%2==0 else False 243 | >>> isEven 244 | False 245 | >>> number = 6 246 | >>> isEven = True if number%2==0 else False 247 | >>> isEven 248 | True 249 | >>> isEven = number%2==0 250 | >>> isEven = "Yes" if number%2==0 else "No" 251 | >>> isEven 252 | 'Yes' 253 | >>> os.system('clear') 254 | 255 | 256 | 257 | 0 258 | >>> a = 1 259 | >>> len(1) 260 | Traceback (most recent call last): 261 | File "", line 1, in 262 | TypeError: object of type 'int' has no len() 263 | >>> type(a) 264 | 265 | >>> str = "Value" 266 | >>> str.upper() 267 | 'VALUE' 268 | >>> a.upper() 269 | Traceback (most recent call last): 270 | File "", line 1, in 271 | AttributeError: 'int' object has no attribute 'upper' 272 | >>> type(1) 273 | 274 | >>> type(1.5) 275 | 276 | >>> type("1.5") 277 | 278 | >>> type(True) 279 | 280 | >>> type(str) 281 | 282 | >>> str = 1 283 | >>> type(str) 284 | 285 | >>> str = True 286 | >>> type(str) 287 | 288 | >>> str = [1,2] 289 | >>> type(str) 290 | 291 | >>> os.system('clear') 292 | 293 | 0 294 | >>> def create_ranga(): 295 | ... return 'Ranga',1981,'India' 296 | ... 297 | >>> ranga = create_ranga() 298 | >>> type(ranga) 299 | 300 | >>> name, year, country = ranga 301 | >>> ranga 302 | ('Ranga', 1981, 'India') 303 | >>> name 304 | 'Ranga' 305 | >>> year 306 | 1981 307 | >>> country 308 | 'India' 309 | >>> len(ranga) 310 | 3 311 | >>> ranga[0] 312 | 'Ranga' 313 | >>> ranga[1] 314 | 1981 315 | >>> ranga[2] 316 | 'India' 317 | >>> ranga[1] = 1991 318 | Traceback (most recent call last): 319 | File "", line 1, in 320 | TypeError: 'tuple' object does not support item assignment 321 | >>> person = ('Ranga', 5, 'India') 322 | >>> person = 'Ranga', 5, 'India' 323 | >>> type(person) 324 | 325 | >>> name, age, country = person 326 | >>> name, age = person 327 | Traceback (most recent call last): 328 | File "", line 1, in 329 | ValueError: too many values to unpack (expected 2) 330 | >>> x = 0 331 | >>> y = 1 332 | >>> x, y = 0, 1 333 | >>> x, y = y, x 334 | >>> x 335 | 1 336 | >>> y 337 | 0 338 | >>> x = (0) 339 | >>> type(x) 340 | 341 | >>> x = (0,) 342 | >>> x = 1, 343 | >>> type(x) 344 | 345 | >>> os.system('clear') 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 0 357 | >>> 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | >>> sum 371 | 372 | >>> sum([12,34,56]) 373 | 102 374 | >>> number1 = 10 375 | >>> number2 = 20 376 | >>> sum = number1 + number2 377 | >>> sum 378 | 30 379 | >>> sum([12,34,56]) 380 | Traceback (most recent call last): 381 | File "", line 1, in 382 | TypeError: 'int' object is not callable 383 | >>> sum_ = number1 + number2 384 | >>> del sum 385 | >>> sum 386 | 387 | >>> sum([12,34,56]) 388 | 102 389 | >>> os.system('clear') 390 | Traceback (most recent call last): 391 | File "", line 1, in 392 | NameError: name 'os' is not defined 393 | >>> import os 394 | >>> os.system('clear') 395 | 396 | 0 397 | >>> None 398 | >>> type(None) 399 | 400 | >>> def email(subject, content, to , cc , bcc): 401 | ... print(f" {subject}, {content}, {to}, {cc}, " 402 | ... ) 403 | ... 404 | >>> email("subject", "great work", in28minutes@gmail.com) 405 | Traceback (most recent call last): 406 | File "", line 1, in 407 | NameError: name 'in28minutes' is not defined 408 | >>> email("subject", "great work", "in28minutes@gmail.com") 409 | Traceback (most recent call last): 410 | File "", line 1, in 411 | TypeError: email() missing 2 required positional arguments: 'cc' and 'bcc' 412 | >>> def email(subject, content, to , cc=None , bcc=None): 413 | ... print(f" {subject}, {content}, {to}, {cc}, {bcc}"); 414 | ... 415 | >>> email("subject", "great work", "in28minutes@gmail.com") 416 | subject, great work, in28minutes@gmail.com, None, None 417 | >>> email("subject", "great work", "in28minutes@gmail.com", None, None) 418 | subject, great work, in28minutes@gmail.com, None, None 419 | >>> email(None, "great work", "in28minutes@gmail.com", None, None) 420 | None, great work, in28minutes@gmail.com, None, None 421 | >>> var = "123" 422 | >>> if var is None : print ("do something"); 423 | ... 424 | >>> var = None 425 | >>> if var is None : print ("do something"); 426 | ... 427 | do something 428 | >>> os.system('clear') 429 | 430 | 0 431 | >>> class Student: pass 432 | ... 433 | >>> student1 = Student() 434 | >>> student2 = Student() 435 | >>> id(student1) 436 | 4554811768 437 | >>> id(student2) 438 | 4554811992 439 | >>> student1 is student2 440 | False 441 | >>> student3 = student1 442 | >>> id(student3) 443 | 4554811768 444 | >>> student1 is student3 445 | True 446 | >>> student1 == student2 447 | False 448 | >>> student1 == student3 449 | True 450 | >>> class Student: 451 | ... def __init__(self, id): 452 | ... self.id = id 453 | ... 454 | >>> student1 = Student(1) 455 | >>> student2 = Student(2) 456 | >>> student3 = Student(1) 457 | >>> student4 = student1 458 | >>> id(student1) 459 | 4554812160 460 | >>> id(student4) 461 | 4554812160 462 | >>> student1 is student4 463 | True 464 | >>> student1 is student2 465 | False 466 | >>> student1 is student3 467 | False 468 | >>> student1 == student3 469 | False 470 | >>> class Student: 471 | ... def __init__(self, id): 472 | ... self.id = id 473 | ... def __eq__(self, other): 474 | ... return self.id == other.id 475 | ... 476 | >>> student1 = Student(1) 477 | >>> student2 = Student(2) 478 | >>> student3 = Student(1) 479 | >>> student4 = student1 480 | >>> student4 == student1 481 | True 482 | >>> student2 == student1 483 | False 484 | >>> student3 == student1 485 | True 486 | >>> os.system('clear') 487 | 488 | 0 489 | >>> i=1 490 | File "", line 1 491 | i=1 492 | ^ 493 | IndentationError: unexpected indent 494 | >>> i=3 495 | File "", line 1 496 | i=3 497 | ^ 498 | IndentationError: unexpected indent 499 | >>> i=1 500 | >>> if(i==3): 501 | ... print('somethin') 502 | File "", line 2 503 | print('somethin') 504 | ^ 505 | IndentationError: expected an indented block 506 | >>> if(i==3): 507 | ... print('something') 508 | ... print('') 509 | File "", line 3 510 | print('') 511 | ^ 512 | IndentationError: unindent does not match any outer indentation level 513 | >>> os.system('clear') 514 | 515 | 0 516 | >>> import this 517 | The Zen of Python, by Tim Peters 518 | 519 | Beautiful is better than ugly. 520 | Explicit is better than implicit. 521 | Simple is better than complex. 522 | Complex is better than complicated. 523 | Flat is better than nested. 524 | Sparse is better than dense. 525 | Readability counts. 526 | Special cases aren't special enough to break the rules. 527 | Although practicality beats purity. 528 | Errors should never pass silently. 529 | Unless explicitly silenced. 530 | In the face of ambiguity, refuse the temptation to guess. 531 | There should be one-- and preferably only one --obvious way to do it. 532 | Although that way may not be obvious at first unless you're Dutch. 533 | Now is better than never. 534 | Although never is often better than *right* now. 535 | If the implementation is hard to explain, it's a bad idea. 536 | If the implementation is easy to explain, it may be a good idea. 537 | Namespaces are one honking great idea -- let's do more of those! 538 | >>> 539 | -------------------------------------------------------------------------------- /00-python-shell/Section2.py: -------------------------------------------------------------------------------- 1 | Last login: Mon May 14 15:45:09 on ttys003 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> for i in range (1,11): 7 | ... print(f"8 * {i} = {8 * i}") 8 | ... 9 | 8 * 1 = 8 10 | 8 * 2 = 16 11 | 8 * 3 = 24 12 | 8 * 4 = 32 13 | 8 * 5 = 40 14 | 8 * 6 = 48 15 | 8 * 7 = 56 16 | 8 * 8 = 64 17 | 8 * 9 = 72 18 | 8 * 10 = 80 19 | >>> for i in range (1,11): 20 | ... print(f"7 * {i} = {7 * i}") 21 | ... 22 | 7 * 1 = 7 23 | 7 * 2 = 14 24 | 7 * 3 = 21 25 | 7 * 4 = 28 26 | 7 * 5 = 35 27 | 7 * 6 = 42 28 | 7 * 7 = 49 29 | 7 * 8 = 56 30 | 7 * 9 = 63 31 | 7 * 10 = 70 32 | >>> print_multiplication_table(7) 33 | Traceback (most recent call last): 34 | File "", line 1, in 35 | NameError: name 'print_multiplication_table' is not defined 36 | >>> print_multiplication_table(8) 37 | Traceback (most recent call last): 38 | File "", line 1, in 39 | NameError: name 'print_multiplication_table' is not defined 40 | >>> import os 41 | >>> os.system('clear') 42 | 43 | 0 44 | >>> print("Hello World") 45 | Hello World 46 | >>> print("Hello World") 47 | Hello World 48 | >>> def print_hello_world_twice(): 49 | ... print("Hello World") 50 | ... print("Hello World") 51 | ... 52 | >>> print_hello_world_twice 53 | 54 | >>> print_hello_world_twice() 55 | Hello World 56 | Hello World 57 | >>> print_hello_world_twice() 58 | Hello World 59 | Hello World 60 | >>> def print_hello_world_thrice(): 61 | ... print("Hello World") 62 | ... print("Hello World") 63 | ... print("Hello World") 64 | ... 65 | >>> print_hello_world_thrice() 66 | Hello World 67 | Hello World 68 | Hello World 69 | >>> def print_your_progress(): 70 | ... print("Statement 1") 71 | ... print("Statement 2") 72 | ... print("Statement 3") 73 | ... print("Statement 4") 74 | ... 75 | >>> print_your_progress() 76 | Statement 1 77 | Statement 2 78 | Statement 3 79 | Statement 4 80 | >>> def print_your_progress(): 81 | ... print("Statement 1\nStatement 2\nStatement 3\nStatement 4") 82 | ... 83 | >>> print_your_progress() 84 | Statement 1 85 | Statement 2 86 | Statement 3 87 | Statement 4 88 | >>> os.system('clear') 89 | 90 | 0 91 | >>> print_hello_world_twice() 92 | Hello World 93 | Hello World 94 | >>> def print_hello_world_twice(): 95 | ... print("Hello World") 96 | ... print("Hello World") 97 | ... 98 | >>> os.system('clear') 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 0 112 | >>> print_hello_world_twice() 113 | Hello World 114 | Hello World 115 | >>> print_hello_world_thrice() 116 | Hello World 117 | Hello World 118 | Hello World 119 | >>> def print_hello_world(no_of_times): 120 | ... print("Hello World") 121 | ... print(no_of_times) 122 | ... 123 | >>> print_hello_world() 124 | Traceback (most recent call last): 125 | File "", line 1, in 126 | TypeError: print_hello_world() missing 1 required positional argument: 'no_of_times' 127 | >>> print_hello_world(5) 128 | Hello World 129 | 5 130 | >>> print_hello_world(10) 131 | Hello World 132 | 10 133 | >>> print_hello_world(100) 134 | Hello World 135 | 100 136 | >>> def print_hello_world(no_of_times): 137 | ... for i in Range(1,10) 138 | File "", line 2 139 | for i in Range(1,10) 140 | ^ 141 | SyntaxError: invalid syntax 142 | >>> def print_hello_world(no_of_times): 143 | ... for i in Range(1,10): 144 | ... print("Hello World") 145 | ... 146 | >>> print_hello_world(5) 147 | Traceback (most recent call last): 148 | File "", line 1, in 149 | File "", line 2, in print_hello_world 150 | NameError: name 'Range' is not defined 151 | >>> def print_hello_world(no_of_times): 152 | ... for i in range(1,10): 153 | ... print("Hello World") 154 | ... 155 | >>> print_hello_world(5) 156 | Hello World 157 | Hello World 158 | Hello World 159 | Hello World 160 | Hello World 161 | Hello World 162 | Hello World 163 | Hello World 164 | Hello World 165 | >>> def print_hello_world(no_of_times): 166 | ... for i in range(1,no_of_times): 167 | ... print("Hello World") 168 | ... 169 | >>> print_hello_world(5) 170 | Hello World 171 | Hello World 172 | Hello World 173 | Hello World 174 | >>> def print_hello_world(no_of_times): 175 | ... for i in range(1,no_of_times+1): 176 | ... print("Hello World") 177 | ... 178 | >>> print_hello_world(5) 179 | Hello World 180 | Hello World 181 | Hello World 182 | Hello World 183 | Hello World 184 | >>> print_hello_world(7) 185 | Hello World 186 | Hello World 187 | Hello World 188 | Hello World 189 | Hello World 190 | Hello World 191 | Hello World 192 | >>> os.system('clear') 193 | 194 | 0 195 | >>> def print_numbers(n): 196 | ... for i in range(1, n+1) 197 | File "", line 2 198 | for i in range(1, n+1) 199 | ^ 200 | SyntaxError: invalid syntax 201 | >>> def print_numbers(n): 202 | ... for i in range(1, n+1): 203 | ... print(i) 204 | ... 205 | >>> print_numbers(5) 206 | 1 207 | 2 208 | 3 209 | 4 210 | 5 211 | >>> def print_squares_of_numbers(n): 212 | ... for i in range(1, n+1): 213 | ... print(i*i) 214 | ... 215 | >>> print_squares_of_numbers(5) 216 | 1 217 | 4 218 | 9 219 | 16 220 | 25 221 | >>> def print_hello_world(no_of_times): 222 | ... for i in range(1,no_of_times+1): 223 | ... print("Hello World") 224 | ... 225 | >>> def print_string(str, no_of_times): 226 | ... for i in range(1,no_of_times+1): 227 | ... print(str) 228 | ... 229 | >>> print_string("Hello World", 3) 230 | Hello World 231 | Hello World 232 | Hello World 233 | >>> print_string("Welcome to Python", 3) 234 | Welcome to Python 235 | Welcome to Python 236 | Welcome to Python 237 | >>> print_string("Welcome to Python") 238 | Traceback (most recent call last): 239 | File "", line 1, in 240 | TypeError: print_string() missing 1 required positional argument: 'no_of_times' 241 | >>> print_string("Welcome to Python", 4) 242 | Welcome to Python 243 | Welcome to Python 244 | Welcome to Python 245 | Welcome to Python 246 | >>> def print_string(str="Hello World", no_of_times=5): 247 | ... for i in range(1,no_of_times+1): 248 | ... print(str) 249 | ... 250 | >>> print_string() 251 | Hello World 252 | Hello World 253 | Hello World 254 | Hello World 255 | Hello World 256 | >>> print_string("Welcome to Python") 257 | Welcome to Python 258 | Welcome to Python 259 | Welcome to Python 260 | Welcome to Python 261 | Welcome to Python 262 | >>> print_string("Welcome to Python", 8) 263 | Welcome to Python 264 | Welcome to Python 265 | Welcome to Python 266 | Welcome to Python 267 | Welcome to Python 268 | Welcome to Python 269 | Welcome to Python 270 | Welcome to Python 271 | >>> os.system('clear') 272 | 273 | 0 274 | >>> for i in range (1,11): 275 | ... print(f"8 * {i} = {8 * i}") 276 | ... 277 | 8 * 1 = 8 278 | 8 * 2 = 16 279 | 8 * 3 = 24 280 | 8 * 4 = 32 281 | 8 * 5 = 40 282 | 8 * 6 = 48 283 | 8 * 7 = 56 284 | 8 * 8 = 64 285 | 8 * 9 = 72 286 | 8 * 10 = 80 287 | >>> for i in range (1,11): 288 | ... print(f"7 * {i} = {7 * i}") 289 | ... 290 | 7 * 1 = 7 291 | 7 * 2 = 14 292 | 7 * 3 = 21 293 | 7 * 4 = 28 294 | 7 * 5 = 35 295 | 7 * 6 = 42 296 | 7 * 7 = 49 297 | 7 * 8 = 56 298 | 7 * 9 = 63 299 | 7 * 10 = 70 300 | >>> def print_multiplication_table(table): 301 | ... for i in range(1,11) 302 | File "", line 2 303 | for i in range(1,11) 304 | ^ 305 | SyntaxError: invalid syntax 306 | >>> def print_multiplication_table(table): 307 | ... for i in range(1,11): 308 | ... print(f"table * {i} = {table * i}") 309 | ... 310 | >>> print_multiplication_table(7) 311 | table * 1 = 7 312 | table * 2 = 14 313 | table * 3 = 21 314 | table * 4 = 28 315 | table * 5 = 35 316 | table * 6 = 42 317 | table * 7 = 49 318 | table * 8 = 56 319 | table * 9 = 63 320 | table * 10 = 70 321 | >>> def print_multiplication_table(table): 322 | ... for i in range(1,11): 323 | ... print(f"{table} * {i} = {table * i}") 324 | ... 325 | >>> print_multiplication_table(7) 326 | 7 * 1 = 7 327 | 7 * 2 = 14 328 | 7 * 3 = 21 329 | 7 * 4 = 28 330 | 7 * 5 = 35 331 | 7 * 6 = 42 332 | 7 * 7 = 49 333 | 7 * 8 = 56 334 | 7 * 9 = 63 335 | 7 * 10 = 70 336 | >>> def print_multiplication_table(table, start, end): 337 | ... for i in range(start, end+1): 338 | ... print(f"{table} * {i} = {table * i}") 339 | ... 340 | >>> print_multiplication_table(7, 1 , 6) 341 | 7 * 1 = 7 342 | 7 * 2 = 14 343 | 7 * 3 = 21 344 | 7 * 4 = 28 345 | 7 * 5 = 35 346 | 7 * 6 = 42 347 | >>> def print_multiplication_table(table, start=1, end=10): 348 | ... for i in range(start, end+1): 349 | ... print(f"{table} * {i} = {table * i}") 350 | ... 351 | >>> print_multiplication_table(7, 1 , 6) 352 | 7 * 1 = 7 353 | 7 * 2 = 14 354 | 7 * 3 = 21 355 | 7 * 4 = 28 356 | 7 * 5 = 35 357 | 7 * 6 = 42 358 | >>> print_multiplication_table(7) 359 | 7 * 1 = 7 360 | 7 * 2 = 14 361 | 7 * 3 = 21 362 | 7 * 4 = 28 363 | 7 * 5 = 35 364 | 7 * 6 = 42 365 | 7 * 7 = 49 366 | 7 * 8 = 56 367 | 7 * 9 = 63 368 | 7 * 10 = 70 369 | >>> os.system('clear') 370 | 371 | 0 372 | >>> def method_to_understand_indentation(): 373 | ... for i in range(1,11) : 374 | ... print(i) 375 | ... 376 | >>> method_to_understand_indentation() 377 | 1 378 | 2 379 | 3 380 | 4 381 | 5 382 | 6 383 | 7 384 | 8 385 | 9 386 | 10 387 | >>> def method_to_understand_indentation(): 388 | ... for i in range(1,11) : 389 | ... print(i) 390 | ... print(5) 391 | ... 392 | >>> method_to_understand_indentation() 393 | 1 394 | 2 395 | 3 396 | 4 397 | 5 398 | 6 399 | 7 400 | 8 401 | 9 402 | 10 403 | 5 404 | >>> def method_to_understand_indentation(): 405 | ... for i in range(1,11) : 406 | ... print(i) 407 | ... print(5) 408 | ... 409 | >>> method_to_understand_indentation() 410 | 1 411 | 5 412 | 2 413 | 5 414 | 3 415 | 5 416 | 4 417 | 5 418 | 5 419 | 5 420 | 6 421 | 5 422 | 7 423 | 5 424 | 8 425 | 5 426 | 9 427 | 5 428 | 10 429 | 5 430 | >>> os.system('clear') 431 | 432 | 0 433 | >>> def print_string(str="Hello World", no_of_times=5): 434 | ... for i in range(1,no_of_times+1): 435 | ... print(str) 436 | ... 437 | >>> print_string() 438 | Hello World 439 | Hello World 440 | Hello World 441 | Hello World 442 | Hello World 443 | >>> print_string(6) 444 | 6 445 | 6 446 | 6 447 | 6 448 | 6 449 | >>> print_string(no_of_times=6) 450 | Hello World 451 | Hello World 452 | Hello World 453 | Hello World 454 | Hello World 455 | Hello World 456 | >>> print_string(7, 8) 457 | 7 458 | 7 459 | 7 460 | 7 461 | 7 462 | 7 463 | 7 464 | 7 465 | >>> print_string(7.5, 8) 466 | 7.5 467 | 7.5 468 | 7.5 469 | 7.5 470 | 7.5 471 | 7.5 472 | 7.5 473 | 7.5 474 | >>> print_string(7.5, "eight") 475 | Traceback (most recent call last): 476 | File "", line 1, in 477 | File "", line 2, in print_string 478 | TypeError: must be str, not int 479 | >>> print_string(7.5, 8) 480 | 7.5 481 | 7.5 482 | 7.5 483 | 7.5 484 | 7.5 485 | 7.5 486 | 7.5 487 | 7.5 488 | >>> print_string(7.5, "8") 489 | Traceback (most recent call last): 490 | File "", line 1, in 491 | File "", line 2, in print_string 492 | TypeError: must be str, not int 493 | >>> def 1_print(): 494 | File "", line 1 495 | def 1_print(): 496 | ^ 497 | SyntaxError: invalid token 498 | >>> def _1print(): 499 | ... 500 | File "", line 2 501 | 502 | ^ 503 | IndentationError: expected an indented block 504 | >>> def _1print(): 505 | ... print("test") 506 | ... 507 | >>> for i in range(1,11) 508 | File "", line 1 509 | for i in range(1,11) 510 | ^ 511 | SyntaxError: invalid syntax 512 | >>> for i in range(1,11): 513 | ... print(i) 514 | ... 515 | 1 516 | 2 517 | 3 518 | 4 519 | 5 520 | 6 521 | 7 522 | 8 523 | 9 524 | 10 525 | >>> def def(): 526 | File "", line 1 527 | def def(): 528 | ^ 529 | SyntaxError: invalid syntax 530 | >>> def in(): 531 | File "", line 1 532 | def in(): 533 | ^ 534 | SyntaxError: invalid syntax 535 | >>> def for(): 536 | File "", line 1 537 | def for(): 538 | ^ 539 | SyntaxError: invalid syntax 540 | >>> os.system('clear') 541 | 542 | 0 543 | >>> def product_of_two_numbers(a,b) 544 | File "", line 1 545 | def product_of_two_numbers(a,b) 546 | ^ 547 | SyntaxError: invalid syntax 548 | >>> def product_of_two_numbers(a,b): 549 | ... print(a * b) 550 | ... 551 | >>> product_of_two_numbers(1,2) 552 | 2 553 | >>> product = product_of_two_numbers(1,2) 554 | 2 555 | >>> product 556 | >>> max(1,2,3) 557 | 3 558 | >>> max(1,2,3,4) 559 | 4 560 | >>> maximum = max(1,2,3,4) 561 | >>> maximum 562 | 4 563 | >>> maximum * 5 564 | 20 565 | >>> def product_of_two_numbers(a,b): 566 | ... product = a * b; 567 | ... return product 568 | ... 569 | >>> product_of_two_numbers(2,3) 570 | 6 571 | >>> product_result = product_of_two_numbers(2,3) 572 | >>> product_result 573 | 6 574 | >>> product_result * 10 575 | 60 576 | >>> def sum_of_three_numbers(a, b, c) 577 | File "", line 1 578 | def sum_of_three_numbers(a, b, c) 579 | ^ 580 | SyntaxError: invalid syntax 581 | >>> def sum_of_three_numbers(a, b, c): 582 | ... sum = a + b + c 583 | ... return sum 584 | ... 585 | >>> sum_of_three_numbers(1,2,3) 586 | 6 587 | >>> something = sum_of_three_numbers(1,2,3) 588 | >>> something * 5 589 | 30 590 | >>> def sum_of_three_numbers(a, b, c): 591 | ... return a + b + c 592 | ... 593 | >>> something = sum_of_three_numbers(1,2,3) 594 | >>> something * 5 595 | 30 596 | >>> def calculate_third_angle(first, second) : 597 | ... return 180 - ( first + second ) 598 | ... 599 | >>> calculate_third_angle(50, 20) 600 | 110 601 | >>> 602 | -------------------------------------------------------------------------------- /00-python-shell/Section3.py: -------------------------------------------------------------------------------- 1 | Last login: Wed May 16 14:30:51 on ttys001 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> number = 5 7 | >>> value = 2.5 8 | >>> type(number) 9 | 10 | >>> type(5) 11 | 12 | >>> type(2.5) 13 | 14 | >>> type(2.55) 15 | 16 | >>> type(5/2) 17 | 18 | >>> type(4/2) 19 | 20 | >>> 4/2 21 | 2.0 22 | >>> 1 + 2 23 | 3 24 | >>> i = 10 25 | >>> j = 2 26 | >>> i + j 27 | 12 28 | >>> i - j 29 | 8 30 | >>> i / j 31 | 5.0 32 | >>> i * j 33 | 20 34 | >>> i % 2 35 | 0 36 | >>> value1 = 4.5 37 | >>> value2 = 3.2 38 | >>> value1 + value2 39 | 7.7 40 | >>> value1 - value2 41 | 1.2999999999999998 42 | >>> value1 / value2 43 | 1.40625 44 | >>> value1 % value2 45 | 1.2999999999999998 46 | >>> i + value1 47 | 14.5 48 | >>> i - value1 49 | 5.5 50 | >>> i / value1 51 | 2.2222222222222223 52 | >>> 53 | >>> import os 54 | >>> os.system('clear') 55 | 56 | 0 57 | >>> i = 1 58 | >>> i = i + 1 59 | >>> i 60 | 2 61 | >>> i += 1 62 | >>> i 63 | 3 64 | >>> i++ 65 | File "", line 1 66 | i++ 67 | ^ 68 | SyntaxError: invalid syntax 69 | >>> ++i 70 | 3 71 | >>> i += 1 72 | >>> i 73 | 4 74 | >>> i -= 1 75 | >>> i 76 | 3 77 | >>> i /= 1 78 | >>> i *= 2 79 | >>> i 80 | 6.0 81 | >>> type(i) 82 | 83 | >>> number1 = 5 84 | >>> number2 = 2 85 | >>> number1/number2 86 | 2.5 87 | >>> number1//number2 88 | 2 89 | >>> number1 //= 2 90 | >>> number1 91 | 2 92 | >>> 5 ** 3 93 | 125 94 | >>> pow(5,3) 95 | 125 96 | >>> 5.6 97 | 5.6 98 | >>> int(5.6) 99 | 5 100 | >>> round(5.6) 101 | 6 102 | >>> round(5.4) 103 | 5 104 | >>> round(5.5) 105 | 6 106 | >>> round(5.67, 1) 107 | 5.7 108 | >>> round(5.678, 2) 109 | 5.68 110 | >>> float(5) 111 | 5.0 112 | >>> os.clear('system') 113 | Traceback (most recent call last): 114 | File "", line 1, in 115 | AttributeError: module 'os' has no attribute 'clear' 116 | >>> os.system('clear') 117 | 118 | 0 119 | >>> True 120 | True 121 | >>> False 122 | False 123 | >>> true 124 | Traceback (most recent call last): 125 | File "", line 1, in 126 | NameError: name 'true' is not defined 127 | >>> false 128 | Traceback (most recent call last): 129 | File "", line 1, in 130 | NameError: name 'false' is not defined 131 | >>> is_even = True 132 | >>> is_odd = False 133 | >>> i = 10 134 | >>> i > 15 135 | False 136 | >>> i < 15 137 | True 138 | >>> i >= 15 139 | False 140 | >>> i >= 10 141 | True 142 | >>> i > 10 143 | False 144 | >>> i <= 10 145 | True 146 | >>> i < 10 147 | False 148 | >>> i == 10 149 | True 150 | >>> i == 11 151 | False 152 | >>> os.system('clear') 153 | 154 | 0 155 | >>> i = 5 156 | >>> if i>3: 157 | ... print(f"{i} is greater than 3") 158 | ... 159 | 5 is greater than 3 160 | >>> i = 2 161 | >>> if i>3: 162 | ... print(f"{i} is greater than 3") 163 | ... 164 | >>> if i<10: 165 | ... print(f"{i} is less than 10") 166 | ... 167 | 2 is less than 10 168 | >>> i = 15 169 | >>> if i<10: 170 | ... print(f"{i} is less than 10") 171 | ... 172 | >>> if(False): 173 | ... print("False") 174 | ... 175 | >>> if(True): 176 | ... print("True") 177 | ... 178 | True 179 | >>> a = 5 180 | >>> b = 7 181 | >>> if(a>b): 182 | ... print("a is greater than b") 183 | ... 184 | >>> a = 9 185 | >>> if(a>b): 186 | ... print("a is greater than b") 187 | ... 188 | a is greater than b 189 | >>> os.system('clear') 190 | 191 | 0 192 | >>> a = 1 193 | >>> b = 2 194 | >>> c = 3 195 | >>> d = 5 196 | >>> if a+b > c+d : 197 | ... print("a+b > c +d") 198 | ... 199 | >>> a = 9 200 | >>> if a+b > c+d : 201 | ... print("a+b > c +d") 202 | ... 203 | a+b > c +d 204 | >>> angle1 = 30 205 | >>> angle2 = 20 206 | >>> angle3 = 60 207 | >>> if(angle1 + angle2 + angle3 = 180): 208 | File "", line 1 209 | if(angle1 + angle2 + angle3 = 180): 210 | ^ 211 | SyntaxError: invalid syntax 212 | >>> if(angle1 + angle2 + angle3 == 180): 213 | ... print("Valid Triangle") 214 | ... 215 | >>> angle2 = 90 216 | >>> if(angle1 + angle2 + angle3 == 180): 217 | ... print("Valid Triangle") 218 | ... 219 | Valid Triangle 220 | >>> i = 2 221 | >>> if(i%2==0): 222 | ... print("i is even") 223 | ... 224 | i is even 225 | >>> i = 3 226 | >>> if(i%2==0): 227 | ... print("i is even") 228 | ... 229 | >>> os.system('clear') 230 | 231 | 0 232 | >>> True and False 233 | False 234 | >>> True and True 235 | True 236 | >>> True and False 237 | False 238 | >>> False and True 239 | False 240 | >>> False and False 241 | False 242 | >>> True or False 243 | True 244 | >>> False or True 245 | True 246 | >>> True or True 247 | True 248 | >>> False or False 249 | False 250 | >>> not True 251 | False 252 | >>> not(True) 253 | False 254 | >>> not False 255 | True 256 | >>> not(False) 257 | True 258 | >>> True ^ True 259 | False 260 | >>> True ^ False 261 | True 262 | >>> False ^ True 263 | True 264 | >>> False ^ False 265 | False 266 | >>> os.system('clear') 267 | 268 | 0 269 | >>> i = 10 270 | >>> j = 15 271 | >>> if i%2==0 and j%2==0: 272 | ... print("i and j are even") 273 | ... 274 | >>> j = 14 275 | >>> if i%2==0 and j%2==0: 276 | ... print("i and j are even") 277 | ... 278 | i and j are even 279 | >>> if i%2==0 or j%2==0: 280 | ... 281 | File "", line 2 282 | 283 | ^ 284 | IndentationError: expected an indented block 285 | >>> if i%2==0 or j%2==0: 286 | ... print("atleast one of i and j are even") 287 | ... 288 | atleast one of i and j are even 289 | >>> i = 15 290 | >>> j 291 | 14 292 | >>> if i%2==0 or j%2==0: 293 | ... print("atleast one of i and j are even") 294 | ... 295 | atleast one of i and j are even 296 | >>> j = 23 297 | >>> if i%2==0 or j%2==0: 298 | ... print("atleast one of i and j are even") 299 | ... 300 | >>> i 301 | 15 302 | >>> if(True ^ False) 303 | File "", line 1 304 | if(True ^ False) 305 | ^ 306 | SyntaxError: invalid syntax 307 | >>> if(True ^ False): 308 | ... print("This will Print") 309 | ... 310 | This will Print 311 | >>> if(False ^ True): 312 | ... print("This will Print") 313 | ... 314 | This will Print 315 | >>> if(True ^ True): 316 | ... print("This will Print") 317 | ... 318 | >>> x = 5 319 | >>> if not x == 6: 320 | ... print("This") 321 | ... 322 | This 323 | >>> x = 6 324 | >>> if not x == 6: 325 | ... print("This") 326 | ... 327 | >>> if x!=6: 328 | ... print("This") 329 | ... 330 | >>> x=5 331 | >>> if x!=6: 332 | ... print("This") 333 | ... 334 | This 335 | >>> if x=6: 336 | File "", line 1 337 | if x=6: 338 | ^ 339 | SyntaxError: invalid syntax 340 | >>> int(True) 341 | 1 342 | >>> int(False) 343 | 0 344 | >>> x = -6 345 | >>> if x: 346 | ... print("something") 347 | ... 348 | something 349 | >>> bool(6) 350 | True 351 | >>> bool(-6) 352 | True 353 | >>> bool(0) 354 | False 355 | >>> os.system('clear') 356 | 357 | 0 358 | >>> i = 2 359 | >>> if i%2 == 0: 360 | ... print("i is even"); 361 | ... else: 362 | ... print("i is odd"); 363 | ... 364 | i is even 365 | >>> i = 3 366 | >>> if i%2 == 0: 367 | ... print("i is even"); 368 | ... else: 369 | ... print("i is odd"); 370 | ... 371 | i is odd 372 | >>> if i==1: 373 | ... print("i is 1") 374 | ... elif i==2: 375 | ... print("i is 2") 376 | ... else: 377 | ... print("i is not 1 or 2") 378 | ... 379 | i is not 1 or 2 380 | >>> 381 | 382 | -------------------------------------------------------------------------------- /00-python-shell/Section4 String and Text - End.py: -------------------------------------------------------------------------------- 1 | Last login: Thu May 17 09:41:15 on ttys002 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> message = "Hello World" 7 | >>> message = 'Hello World' 8 | >>> message = 'Hello World" 9 | File "", line 1 10 | message = 'Hello World" 11 | ^ 12 | SyntaxError: EOL while scanning string literal 13 | >>> message = "Hello World" 14 | >>> type(message) 15 | 16 | >>> message.upper() 17 | 'HELLO WORLD' 18 | >>> message.lower() 19 | 'hello world' 20 | >>> message = "hello" 21 | >>> message.capitalize() 22 | 'Hello' 23 | >>> "hello".capitalize() 24 | 'Hello' 25 | >>> 'hello'.capitalize() 26 | 'Hello' 27 | >>> 'hello'.islower() 28 | True 29 | >>> 'Hello'.islower() 30 | False 31 | >>> 'Hello'.istitle() 32 | True 33 | >>> 'hello'.istitle() 34 | False 35 | >>> 'hello'.isupper() 36 | False 37 | >>> 'Hello'.isupper() 38 | False 39 | >>> 'HELLO'.isupper() 40 | True 41 | >>> '123'.isdigit() 42 | True 43 | >>> 'A23'.isdigit() 44 | False 45 | >>> '2 3'.isdigit() 46 | False 47 | >>> '23'.isdigit() 48 | True 49 | >>> '23'.isalpha() 50 | False 51 | >>> '2A'.isalpha() 52 | False 53 | >>> 'ABC'.isalpha() 54 | True 55 | >>> 'ABC123'.isalnum() 56 | True 57 | >>> 'ABC 123'.isalnum() 58 | False 59 | >>> 'Hello World'.endswith('World') 60 | True 61 | >>> 'Hello World'.endswith('ld') 62 | True 63 | >>> 'Hello World'.endswith('old') 64 | False 65 | >>> 'Hello World'.endswith('Wo') 66 | False 67 | >>> 'Hello World'.startswith('Wo') 68 | False 69 | >>> 'Hello World'.startswith('He') 70 | True 71 | >>> 'Hello World'.startswith('Hell0') 72 | False 73 | >>> 'Hello World'.startswith('Hello') 74 | True 75 | >>> 'Hello World'.find('Hello') 76 | 0 77 | >>> 'Hello World'.find('ello') 78 | 1 79 | >>> 'Hello World'.find('Ello') 80 | -1 81 | >>> 'Hello World'.find('bello') 82 | -1 83 | >>> 'Hello World'.find('Ello') 84 | -1 85 | >>> os.system('clear') 86 | Traceback (most recent call last): 87 | File "", line 1, in 88 | NameError: name 'os' is not defined 89 | >>> import os 90 | >>> os.system('clear') 91 | 92 | 0 93 | >>> str(True) 94 | 'True' 95 | >>> bool('True') 96 | True 97 | >>> bool('true') 98 | True 99 | >>> bool('tru') 100 | True 101 | >>> bool('false') 102 | True 103 | >>> bool('False') 104 | True 105 | >>> bool('') 106 | False 107 | >>> str(123) 108 | '123' 109 | >>> str(12345) 110 | '12345' 111 | >>> str(12345.45678) 112 | '12345.45678' 113 | >>> int('45') 114 | 45 115 | >>> int('45.56') 116 | Traceback (most recent call last): 117 | File "", line 1, in 118 | ValueError: invalid literal for int() with base 10: '45.56' 119 | >>> int('45dfsafk') 120 | Traceback (most recent call last): 121 | File "", line 1, in 122 | ValueError: invalid literal for int() with base 10: '45dfsafk' 123 | >>> int('45abc',16) 124 | 285372 125 | >>> int('a',16) 126 | 10 127 | >>> int('b',16) 128 | 11 129 | >>> int('c',16) 130 | 12 131 | >>> int('f',16) 132 | 15 133 | >>> int('g',16) 134 | Traceback (most recent call last): 135 | File "", line 1, in 136 | ValueError: invalid literal for int() with base 16: 'g' 137 | >>> float("34.43") 138 | 34.43 139 | >>> float("34.43rer") 140 | Traceback (most recent call last): 141 | File "", line 1, in 142 | ValueError: could not convert string to float: '34.43rer' 143 | >>> os.system('clear') 144 | 145 | 0 146 | >>> message = "Hello" 147 | >>> message.upper() 148 | 'HELLO' 149 | >>> message 150 | 'Hello' 151 | >>> message = message.upper() 152 | >>> message 153 | 'HELLO' 154 | >>> message = "Hello" 155 | >>> message.upper() 156 | 'HELLO' 157 | >>> message_upper = message.upper() 158 | >>> message = "ABC" 159 | >>> message = message.lowercase() 160 | Traceback (most recent call last): 161 | File "", line 1, in 162 | AttributeError: 'str' object has no attribute 'lowercase' 163 | >>> message = message.lower() 164 | >>> os.system('clear') 165 | 166 | 167 | 0 168 | >>> message = "Hello World" 169 | >>> message[0] 170 | 'H' 171 | >>> type(message[0]) 172 | 173 | >>> type(message) 174 | 175 | >>> message[0] 176 | 'H' 177 | >>> message[1] 178 | 'e' 179 | >>> message[2] 180 | 'l' 181 | >>> message[3] 182 | 'l' 183 | >>> message[100] 184 | Traceback (most recent call last): 185 | File "", line 1, in 186 | IndexError: string index out of range 187 | >>> for ch in message: 188 | ... print(ch) 189 | ... 190 | H 191 | e 192 | l 193 | l 194 | o 195 | 196 | W 197 | o 198 | r 199 | l 200 | d 201 | >>> os.system('clear') 202 | 203 | 0 204 | >>> import string 205 | >>> string. 206 | string.Formatter( string.ascii_uppercase string.octdigits 207 | string.Template( string.capwords( string.printable 208 | string.ascii_letters string.digits string.punctuation 209 | string.ascii_lowercase string.hexdigits string.whitespace 210 | >>> string.ascii_letters 211 | 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 212 | >>> string.ascii_lowercase 213 | 'abcdefghijklmnopqrstuvwxyz' 214 | >>> string.ascii_uppercase 215 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 216 | >>> string.digits 217 | '0123456789' 218 | >>> string.hexdigits 219 | '0123456789abcdefABCDEF' 220 | >>> string.punctuation 221 | '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' 222 | >>> 'a' in string.ascii_letters 223 | True 224 | >>> string.ascii_letters 225 | 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 226 | >>> 'ab' in string.ascii_letters 227 | True 228 | >>> 'abc' in string.ascii_letters 229 | True 230 | >>> 'a' in string.ascii_letters 231 | True 232 | >>> '1' in '13579' 233 | True 234 | >>> '2' in '13579' 235 | False 236 | >>> '4' in '13579' 237 | False 238 | >>> char = 'a' 239 | >>> vowel_string = 'aeiouAEIOU' 240 | >>> char in vowel_string 241 | True 242 | >>> char = 'b' 243 | >>> char in vowel_string 244 | False 245 | >>> vowel_string = 'AEIOU' 246 | >>> char.upper() in vowel_string 247 | False 248 | >>> char = 'a' 249 | >>> char.upper() in vowel_string 250 | True 251 | >>> vowel_string = 'aeiou' 252 | >>> char.lower() in vowel_string 253 | True 254 | >>> char = 'A' 255 | >>> char.lower() in vowel_string 256 | True 257 | >>> import string 258 | >>> string. 259 | string.Formatter( string.ascii_uppercase string.octdigits 260 | string.Template( string.capwords( string.printable 261 | string.ascii_letters string.digits string.punctuation 262 | string.ascii_lowercase string.hexdigits string.whitespace 263 | >>> string.ascii_uppercase 264 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 265 | >>> for char in string.ascii_uppercase: 266 | ... print(char) 267 | ... 268 | A 269 | B 270 | C 271 | D 272 | E 273 | F 274 | G 275 | H 276 | I 277 | J 278 | K 279 | L 280 | M 281 | N 282 | O 283 | P 284 | Q 285 | R 286 | S 287 | T 288 | U 289 | V 290 | W 291 | X 292 | Y 293 | Z 294 | >>> for char in string.ascii_lowercase: 295 | ... print(char) 296 | ... 297 | a 298 | b 299 | c 300 | d 301 | e 302 | f 303 | g 304 | h 305 | i 306 | j 307 | k 308 | l 309 | m 310 | n 311 | o 312 | p 313 | q 314 | r 315 | s 316 | t 317 | u 318 | v 319 | w 320 | x 321 | y 322 | z 323 | >>> for char in string. 324 | string.Formatter( string.ascii_uppercase string.octdigits 325 | string.Template( string.capwords( string.printable 326 | string.ascii_letters string.digits string.punctuation 327 | string.ascii_lowercase string.hexdigits string.whitespace 328 | >>> for char in string.digits: 329 | ... print(char) 330 | ... 331 | 0 332 | 1 333 | 2 334 | 3 335 | 4 336 | 5 337 | 6 338 | 7 339 | 8 340 | 9 341 | >>> vowel_string = 'aeiou' 342 | >>> char.lower() in vowel_string 343 | False 344 | >>> 'b'.lower() not in vowel_string 345 | True 346 | >>> 'a'.lower() not in vowel_string 347 | False 348 | >>> '1'.lower() not in vowel_string 349 | True 350 | >>> '1'.isalpha() and '1'.lower() not in vowel_string 351 | False 352 | >>> char.isalpha() and char.lower() not in vowel_string 353 | True 354 | >>> char 355 | 'b' 356 | >>> char = '1' 357 | >>> char.isalpha() and char.lower() not in vowel_string 358 | False 359 | >>> os.system('clear') 360 | 361 | 0 362 | >>> string_example = "This is a great thing" 363 | >>> string_example. 364 | string_example.capitalize( string_example.join( 365 | string_example.casefold( string_example.ljust( 366 | string_example.center( string_example.lower( 367 | string_example.count( string_example.lstrip( 368 | string_example.encode( string_example.maketrans( 369 | string_example.endswith( string_example.partition( 370 | string_example.expandtabs( string_example.replace( 371 | string_example.find( string_example.rfind( 372 | string_example.format( string_example.rindex( 373 | string_example.format_map( string_example.rjust( 374 | string_example.index( string_example.rpartition( 375 | string_example.isalnum( string_example.rsplit( 376 | string_example.isalpha( string_example.rstrip( 377 | string_example.isdecimal( string_example.split( 378 | string_example.isdigit( string_example.splitlines( 379 | string_example.isidentifier( string_example.startswith( 380 | string_example.islower( string_example.strip( 381 | string_example.isnumeric( string_example.swapcase( 382 | string_example.isprintable( string_example.title( 383 | string_example.isspace( string_example.translate( 384 | string_example.istitle( string_example.upper( 385 | string_example.isupper( string_example.zfill( 386 | >>> string_example.split() 387 | ['This', 'is', 'a', 'great', 'thing'] 388 | >>> for word in string_example.split(): 389 | ... print(word) 390 | ... 391 | This 392 | is 393 | a 394 | great 395 | thing 396 | >>> string_example = "This\nis\n\ngreat\nthing" 397 | >>> print(string_example) 398 | This 399 | is 400 | 401 | great 402 | thing 403 | >>> string_example = "This\nis\na\ngreat\nthing" 404 | >>> print(string_example) 405 | This 406 | is 407 | a 408 | great 409 | thing 410 | >>> string_example.split 411 | string_example.split( string_example.splitlines( 412 | >>> string_example.splitlines() 413 | ['This', 'is', 'a', 'great', 'thing'] 414 | >>> 1 + 2 415 | 3 416 | >>> "1" + "2" 417 | '12' 418 | >>> "1" + 1 419 | Traceback (most recent call last): 420 | File "", line 1, in 421 | TypeError: must be str, not int 422 | >>> "ABC" + "DEF" 423 | 'ABCDEF' 424 | >>> 1 * 20 425 | 20 426 | >>> '1' * 20 427 | '11111111111111111111' 428 | >>> 'A' * 10 429 | 'AAAAAAAAAA' 430 | >>> str = "test" 431 | >>> str2 = "test1" 432 | >>> str == str2 433 | False 434 | >>> str2 = "test" 435 | >>> str == str2 436 | True 437 | >>> 438 | -------------------------------------------------------------------------------- /00-python-shell/Section5 - Loops - Start to End.py: -------------------------------------------------------------------------------- 1 | Last login: Thu May 17 09:53:08 on ttys002 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> for i in range(1,11): 7 | ... print(i) 8 | ... 9 | 1 10 | 2 11 | 3 12 | 4 13 | 5 14 | 6 15 | 7 16 | 8 17 | 9 18 | 10 19 | >>> for ch in "Hello World": 20 | ... print(ch) 21 | ... 22 | H 23 | e 24 | l 25 | l 26 | o 27 | 28 | W 29 | o 30 | r 31 | l 32 | d 33 | >>> for word in "Hello World".split(): 34 | ... print(word) 35 | ... 36 | Hello 37 | World 38 | >>> for item in (3, 6, 9): 39 | ... print(item) 40 | ... 41 | 3 42 | 6 43 | 9 44 | >>> os.system('clear') 45 | Traceback (most recent call last): 46 | File "", line 1, in 47 | NameError: name 'os' is not defined 48 | >>> import os 49 | >>> os.system('clear') 50 | 51 | 0 52 | >>> i = 5 53 | >>> if i == 5: 54 | ... print("i is 5") 55 | ... 56 | i is 5 57 | >>> i = 0 58 | >>> while i < 5: 59 | ... print(i) 60 | ... 61 | 0 62 | 0 63 | 0 64 | 0 65 | 0 66 | 0 67 | 0 68 | 0 69 | ^CTraceback (most recent call last): 70 | File "", line 2, in 71 | KeyboardInterrupt 72 | >>> 73 | KeyboardInterrupt 74 | >>> while i < 5: 75 | ... print(i) 76 | ... i = i + 1 77 | ... 78 | 0 79 | 1 80 | 2 81 | 3 82 | 4 83 | >>> i = 0 84 | >>> while i < 5: 85 | ... print(i, end=" ") 86 | ... i = i + 1 87 | ... 88 | 0 1 2 3 4 >>> for i in range(0,5): print(i) 89 | ... 90 | 0 91 | 1 92 | 2 93 | 3 94 | 4 95 | >>> os.system('clear') 96 | 97 | 0 98 | >>> 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /00-python-shell/Section6 - OOPS Basics - Start to End.py: -------------------------------------------------------------------------------- 1 | >>> class Country: 2 | ... pass 3 | ... 4 | >>> india = Country() 5 | >>> usa = Country() 6 | >>> netherlands = Country() 7 | >>> india.name = 'India' 8 | >>> india.capital = 'New Delhi' 9 | >>> usa.name = 'USA' 10 | >>> usa.capital = 'Washington' 11 | >>> netherlands.name = 'Netherlands' 12 | >>> netherlands.capital = 'Amsterdam' 13 | >>> india.name 14 | 'India' 15 | >>> class Planet: pass 16 | ... 17 | >>> earth = Planet() 18 | >>> earth = new Planet() 19 | File "", line 1 20 | earth = new Planet() 21 | ^ 22 | SyntaxError: invalid syntax 23 | >>> earth = Planet('Earth') 24 | Traceback (most recent call last): 25 | File "", line 1, in 26 | TypeError: object() takes no parameters 27 | >>> earth.name 28 | Traceback (most recent call last): 29 | File "", line 1, in 30 | AttributeError: 'Planet' object has no attribute 'name' 31 | >>> earth.name = 'The Earth' 32 | >>> earth.name 33 | 'The Earth' 34 | >>> venus = Planet() 35 | >>> venus.name 36 | Traceback (most recent call last): 37 | File "", line 1, in 38 | AttributeError: 'Planet' object has no attribute 'name' 39 | >>> venus.name = 'Venus' 40 | >>> venus.name 41 | 'Venus' 42 | >>> venus.do_something() 43 | Traceback (most recent call last): 44 | File "", line 1, in 45 | AttributeError: 'Planet' object has no attribute 'do_something' 46 | >>> os.system('clear') 47 | Traceback (most recent call last): 48 | File "", line 1, in 49 | NameError: name 'os' is not defined 50 | >>> import os 51 | >>> os.system('clear') 52 | 53 | 0 54 | >>> class Planet: 55 | ... def __init__(): pass 56 | ... 57 | >>> Planet() 58 | Traceback (most recent call last): 59 | File "", line 1, in 60 | TypeError: __init__() takes 0 positional arguments but 1 was given 61 | >>> class Planet: 62 | ... def __init__(self): pass 63 | ... 64 | >>> Planet() 65 | <__main__.Planet object at 0x10426bc88> 66 | >>> class Planet: 67 | ... def __init__(self): pass 68 | ... def __init__(self, name): pass 69 | ... 70 | >>> Planet() 71 | Traceback (most recent call last): 72 | File "", line 1, in 73 | TypeError: __init__() missing 1 required positional argument: 'name' 74 | >>> class Planet: 75 | ... def __init__(self, name): pass 76 | ... def __init__(self): pass 77 | ... 78 | >>> Planet() 79 | <__main__.Planet object at 0x10426bdd8> 80 | >>> Planet("Jupiter") 81 | Traceback (most recent call last): 82 | File "", line 1, in 83 | TypeError: __init__() takes 1 positional argument but 2 were given 84 | >>> class Planet: 85 | ... def __init__(self, name="Earth"): pass 86 | ... 87 | >>> Planet() 88 | <__main__.Planet object at 0x10426beb8> 89 | >>> Planet("Jupiter") 90 | <__main__.Planet object at 0x10426bef0> 91 | >>> class Planet: 92 | ... def __init__(self, name="Earth"): 93 | ... self.speed = 10 94 | ... self.name = name 95 | ... self.distance_from_sun = 10000 96 | ... 97 | >>> earth = Planet() 98 | >>> earth.name 99 | 'Earth' 100 | >>> earth.speed 101 | 10 102 | >>> earth.distance_from_sun 103 | 10000 104 | >>> os.system('clear') 105 | 106 | 0 107 | >>> class Planet: 108 | ... def revolve(): pass 109 | ... 110 | >>> earth = Planet() 111 | >>> earth.revolve() 112 | Traceback (most recent call last): 113 | File "", line 1, in 114 | TypeError: revolve() takes 0 positional arguments but 1 was given 115 | >>> class Planet: 116 | ... def revolve(self): pass 117 | ... 118 | >>> earth = Planet() 119 | >>> earth.revolve() 120 | Revolve 121 | >>> os.system('clear') 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 0 138 | >>> 5 139 | 5 140 | >>> type(5) 141 | 142 | >>> type(True) 143 | 144 | >>> type('Hello') 145 | 146 | >>> 'Hello'.upper() 147 | 'HELLO' 148 | >>> type(5.5) 149 | 150 | >>> def do_something(): pass 151 | ... 152 | >>> do_something 153 | 154 | >>> def do_something(): 155 | ... print("something") 156 | ... 157 | >>> do_something 158 | 159 | >>> do_something() 160 | something 161 | >>> test = do_something 162 | >>> test 163 | 164 | >>> test() 165 | something 166 | >>> 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /00-python-shell/Section7 - Data Structures - Done.py: -------------------------------------------------------------------------------- 1 | Last login: Fri May 18 14:08:00 on ttys004 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> mark1 = 45 7 | >>> mark2 = 54 8 | >>> mark3 = 80 9 | >>> mark1 + mark2 + mark3 10 | 179 11 | >>> (mark1 + mark2 + mark3)/3 12 | 59.666666666666664 13 | >>> mark4 = 43 14 | >>> (mark1 + mark2 + mark3 + mark4)/3 15 | 74.0 16 | >>> (mark1 + mark2 + mark3 + mark4)/4 17 | 55.5 18 | >>> marks = [45, 54, 80] 19 | >>> sum(marks) 20 | 179 21 | >>> sum(marks)/len(marks) 22 | 59.666666666666664 23 | >>> marks.append(43) 24 | >>> sum(marks)/len(marks) 25 | 55.5 26 | >>> type(marks) 27 | 28 | >>> import os 29 | >>> os.system('clear') 30 | 31 | 0 32 | >>> marks = [23,56,67] 33 | >>> sum(marks) 34 | 146 35 | >>> max(marks) 36 | 67 37 | >>> min(marks) 38 | 23 39 | >>> len(marks) 40 | 3 41 | >>> marks.append(76) 42 | >>> marks 43 | [23, 56, 67, 76] 44 | >>> marks.insert(2, 60) 45 | >>> marks 46 | [23, 56, 60, 67, 76] 47 | >>> marks.remove(60) 48 | >>> 55 in marks 49 | False 50 | >>> 56 in marks 51 | True 52 | >>> marks.index(67) 53 | 2 54 | >>> marks 55 | [23, 56, 67, 76] 56 | >>> marks.index(69) 57 | Traceback (most recent call last): 58 | File "", line 1, in 59 | ValueError: 69 is not in list 60 | >>> for mark in marks: 61 | ... print(mark) 62 | ... 63 | 23 64 | 56 65 | 67 66 | 76 67 | >>> os.system('clear') 68 | 69 | 0 70 | >>> animals = ['Cat', 'Dog','Elephant'] 71 | >>> len(animals) 72 | 3 73 | >>> sum(animals) 74 | Traceback (most recent call last): 75 | File "", line 1, in 76 | TypeError: unsupported operand type(s) for +: 'int' and 'str' 77 | >>> animals.append('Fish') 78 | >>> animals 79 | ['Cat', 'Dog', 'Elephant', 'Fish'] 80 | >>> animals.remove('Dog') 81 | >>> animals 82 | ['Cat', 'Elephant', 'Fish'] 83 | >>> animals[2] 84 | 'Fish' 85 | >>> animals[1] 86 | 'Elephant' 87 | >>> animals[0] 88 | 'Cat' 89 | >>> animals[4] 90 | Traceback (most recent call last): 91 | File "", line 1, in 92 | IndexError: list index out of range 93 | >>> del animals[2] 94 | >>> animals 95 | ['Cat', 'Elephant'] 96 | >>> animals.extend('Fish') 97 | >>> animals 98 | ['Cat', 'Elephant', 'F', 'i', 's', 'h'] 99 | >>> animals.append('Fish') 100 | >>> animals 101 | ['Cat', 'Elephant', 'F', 'i', 's', 'h', 'Fish'] 102 | >>> animals.extend(['Giraffe', 'Horse']) 103 | >>> animals 104 | ['Cat', 'Elephant', 'F', 'i', 's', 'h', 'Fish', 'Giraffe', 'Horse'] 105 | >>> animals = animals + ['Jackal','Kangaroo'] 106 | >>> animals 107 | ['Cat', 'Elephant', 'F', 'i', 's', 'h', 'Fish', 'Giraffe', 'Horse', 'Jackal', 'Kangaroo'] 108 | >>> animals += ['Lion','Monkey'] 109 | >>> animals 110 | ['Cat', 'Elephant', 'F', 'i', 's', 'h', 'Fish', 'Giraffe', 'Horse', 'Jackal', 'Kangaroo', 'Lion', 'Monkey'] 111 | >>> animals.append(10) 112 | >>> animals 113 | ['Cat', 'Elephant', 'F', 'i', 's', 'h', 'Fish', 'Giraffe', 'Horse', 'Jackal', 'Kangaroo', 'Lion', 'Monkey', 10] 114 | >>> os.system('clear') 115 | 116 | 0 117 | >>> numbers = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] 118 | >>> len(numbers) 119 | 10 120 | >>> number[2] 121 | Traceback (most recent call last): 122 | File "", line 1, in 123 | NameError: name 'number' is not defined 124 | >>> numbers[2] 125 | 'Two' 126 | >>> numbers[2:6] 127 | ['Two', 'Three', 'Four', 'Five'] 128 | >>> numbers[:6] 129 | ['Zero', 'One', 'Two', 'Three', 'Four', 'Five'] 130 | >>> numbers[3:] 131 | ['Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] 132 | >>> numbers[1:8:2] 133 | ['One', 'Three', 'Five', 'Seven'] 134 | >>> numbers[1:8:3] 135 | ['One', 'Four', 'Seven'] 136 | >>> numbers[::3] 137 | ['Zero', 'Three', 'Six', 'Nine'] 138 | >>> numbers[::-1] 139 | ['Nine', 'Eight', 'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'One', 'Zero'] 140 | >>> numbers[::-3] 141 | ['Nine', 'Six', 'Three', 'Zero'] 142 | >>> del numbers[3:] 143 | >>> numbers 144 | ['Zero', 'One', 'Two'] 145 | >>> numbers = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] 146 | >>> del numbers[5:7] 147 | >>> numbers = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] 148 | >>> numbers[3:7] = [3,4,5,6] 149 | >>> numbers 150 | ['Zero', 'One', 'Two', 3, 4, 5, 6, 'Seven', 'Eight', 'Nine'] 151 | >>> os.system('clear') 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 0 160 | >>> numbers = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] 161 | >>> numbers.reverse() 162 | >>> numbers 163 | ['Nine', 'Eight', 'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'One', 'Zero'] 164 | >>> numbers = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] 165 | >>> numbers 166 | ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] 167 | >>> reversed(numbers) 168 | 169 | >>> for number in reversed(numbers): 170 | ... print(number) 171 | ... 172 | Nine 173 | Eight 174 | Seven 175 | Six 176 | Five 177 | Four 178 | Three 179 | Two 180 | One 181 | Zero 182 | >>> numbers 183 | ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] 184 | >>> numbers.sort() 185 | >>> numbers 186 | ['Eight', 'Five', 'Four', 'Nine', 'One', 'Seven', 'Six', 'Three', 'Two', 'Zero'] 187 | >>> numbers = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] 188 | >>> for number in sorted(numbers): 189 | ... print(number) 190 | ... 191 | Eight 192 | Five 193 | Four 194 | Nine 195 | One 196 | Seven 197 | Six 198 | Three 199 | Two 200 | Zero 201 | >>> numbers 202 | ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] 203 | >>> for number in sorted(numbers, key=len): 204 | ... print(number) 205 | ... 206 | One 207 | Two 208 | Six 209 | Zero 210 | Four 211 | Five 212 | Nine 213 | Three 214 | Seven 215 | Eight 216 | >>> for number in sorted(numbers, key=len, reverse=True): 217 | ... print(number) 218 | ... 219 | Three 220 | Seven 221 | Eight 222 | Zero 223 | Four 224 | Five 225 | Nine 226 | One 227 | Two 228 | Six 229 | >>> numbers.sort(key=len) 230 | >>> numbers 231 | ['One', 'Two', 'Six', 'Zero', 'Four', 'Five', 'Nine', 'Three', 'Seven', 'Eight'] 232 | >>> numbers.sort(key=len, reverse=True) 233 | >>> numbers 234 | ['Three', 'Seven', 'Eight', 'Zero', 'Four', 'Five', 'Nine', 'One', 'Two', 'Six'] 235 | >>> os.system('clear') 236 | 237 | 0 238 | >>> numbers = [] 239 | >>> numbers.append(1) 240 | >>> numbers.append(2) 241 | >>> numbers.append(3) 242 | >>> numbers.append(4) 243 | >>> numbers.pop() 244 | 4 245 | >>> numbers 246 | [1, 2, 3] 247 | >>> numbers.pop() 248 | 3 249 | >>> numbers 250 | [1, 2] 251 | >>> numbers.append(10) 252 | >>> numbers.pop() 253 | 10 254 | >>> numbers 255 | [1, 2] 256 | >>> numbers = [] 257 | >>> numbers.append(1) 258 | >>> numbers.append(2) 259 | >>> numbers.append(3) 260 | >>> numbers.append(4) 261 | >>> numbers.pop(0) 262 | 1 263 | >>> numbers 264 | [2, 3, 4] 265 | >>> numbers.pop(0) 266 | 2 267 | >>> numbers 268 | [3, 4] 269 | >>> numbers.append(10) 270 | >>> numbers.pop(0) 271 | 3 272 | >>> numbers.pop(0) 273 | 4 274 | >>> numbers.pop(0) 275 | 10 276 | >>> numbers 277 | [] 278 | >>> os.system('clear') 279 | 280 | 0 281 | >>> numbers = ['Zero', 'One','Two','Three','Four','Five','Six','Seven', 'Eight','Nine'] 282 | >>> numbers_length_four=[] 283 | >>> for number in numbers: 284 | ... if len(number)== 4: 285 | ... numbers_length_four.append(number) 286 | ... 287 | >>> numbers_length_four 288 | ['Zero', 'Four', 'Five', 'Nine'] 289 | >>> numbers_length_four = [ number for number in numbers ] 290 | >>> numbers_length_four 291 | ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] 292 | >>> numbers_length_four = [ len(number) for number in numbers ] 293 | >>> numbers_length_four 294 | [4, 3, 3, 5, 4, 4, 3, 5, 5, 4] 295 | >>> numbers_length_four = [ number.upper() for number in numbers ] 296 | >>> numbers_length_four 297 | ['ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE'] 298 | >>> numbers_length_four = [ number for number in numbers if len(number)==4 ] 299 | >>> numbers_length_four 300 | ['Zero', 'Four', 'Five', 'Nine'] 301 | >>> values = [3, 6, 9, 1, 4, 15, 6, 3] 302 | >>> values_even = [ value for value in values if value%2==0] 303 | >>> values_even 304 | [6, 4, 6] 305 | >>> values_odd = [ value for value in values if value%2==1] 306 | >>> values_odd 307 | [3, 9, 1, 15, 3] 308 | >>> os.system('clear') 309 | 310 | 0 311 | >>> numbers = [1,2,3,2,1] 312 | >>> numbers 313 | [1, 2, 3, 2, 1] 314 | >>> numbers_set = set(numbers) 315 | >>> numbers_set 316 | {1, 2, 3} 317 | >>> numbers_set.add(3) 318 | >>> numbers_set 319 | {1, 2, 3} 320 | >>> numbers_set.add(4) 321 | >>> numbers_set 322 | {1, 2, 3, 4} 323 | >>> numbers_set.add(0) 324 | >>> numbers_set 325 | {0, 1, 2, 3, 4} 326 | >>> numbers_set.remove(0) 327 | >>> numbers_set 328 | {1, 2, 3, 4} 329 | >>> numbers_set[0] 330 | Traceback (most recent call last): 331 | File "", line 1, in 332 | TypeError: 'set' object does not support indexing 333 | >>> 1 in numbers_set 334 | True 335 | >>> 5 in numbers_set 336 | False 337 | >>> min(numbers_set) 338 | 1 339 | >>> max(numbers_set) 340 | 4 341 | >>> sum(numbers_set) 342 | 10 343 | >>> len(numbers_set) 344 | 4 345 | >>> numbers_1_to_5_set = set(range(1,6)) 346 | >>> numbers_1_to_5_set 347 | {1, 2, 3, 4, 5} 348 | >>> numbers_4_to_10_set = set(range(4,11)) 349 | >>> numbers_4_to_10_set 350 | {4, 5, 6, 7, 8, 9, 10} 351 | >>> numbers_1_to_5_set + numbers_4_to_10_set 352 | Traceback (most recent call last): 353 | File "", line 1, in 354 | TypeError: unsupported operand type(s) for +: 'set' and 'set' 355 | >>> numbers_1_to_5_set | numbers_4_to_10_set 356 | {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 357 | >>> numbers_1_to_5_set & numbers_4_to_10_set 358 | {4, 5} 359 | >>> numbers_1_to_5_set - numbers_4_to_10_set 360 | {1, 2, 3} 361 | >>> numbers_4_to_10_set - numbers_1_to_5_set 362 | {6, 7, 8, 9, 10} 363 | >>> os.system('clear') 364 | 365 | 0 366 | >>> occurances = dict(a=5 b=6 c=8) 367 | File "", line 1 368 | occurances = dict(a=5 b=6 c=8) 369 | ^ 370 | SyntaxError: invalid syntax 371 | >>> occurances = dict(a=5,b=6,c=8) 372 | >>> occurances 373 | {'a': 5, 'b': 6, 'c': 8} 374 | >>> type(occurances) 375 | 376 | >>> occurances['d'] = 15 377 | >>> occurances 378 | {'a': 5, 'b': 6, 'c': 8, 'd': 15} 379 | >>> occurances['d'] = 10 380 | >>> occurances 381 | {'a': 5, 'b': 6, 'c': 8, 'd': 10} 382 | >>> occurances['d'] 383 | 10 384 | >>> occurances['e'] 385 | Traceback (most recent call last): 386 | File "", line 1, in 387 | KeyError: 'e' 388 | >>> occurances.get('d') 389 | 10 390 | >>> occurances.get('e') 391 | >>> occurances.get('e', 10) 392 | 10 393 | >>> occurances 394 | {'a': 5, 'b': 6, 'c': 8, 'd': 10} 395 | >>> occurances.keys() 396 | dict_keys(['a', 'b', 'c', 'd']) 397 | >>> occurances.values() 398 | dict_values([5, 6, 8, 10]) 399 | >>> occurances.items() 400 | dict_items([('a', 5), ('b', 6), ('c', 8), ('d', 10)]) 401 | >>> for (key,value) in occurances.items(): 402 | ... print(f"{key} {value}") 403 | ... 404 | a 5 405 | b 6 406 | c 8 407 | d 10 408 | >>> occurances['a']=0 409 | >>> occurances 410 | {'a': 0, 'b': 6, 'c': 8, 'd': 10} 411 | >>> del occurances['a'] 412 | >>> occurances 413 | {'b': 6, 'c': 8, 'd': 10} 414 | >>> os.system('clear' 415 | ... ) 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 0 426 | >>> str = "This is an awesome occasion. This has never happened before." 427 | >>> squares_first_ten_numbers = [ i*i for i in range(1,11) ] 428 | >>> type(squares_first_ten_numbers) 429 | 430 | >>> squares_first_ten_numbers_set = set(squares_of_first_10_numbers) 431 | >>> squares_first_ten_numbers_set = { i*i for i in range(1,11)} 432 | >>> type(squares_first_ten_numbers_set) 433 | 434 | >>> squares_first_ten_numbers_dict = { i:i*i for i in range(1,11)} 435 | >>> type(squares_first_ten_numbers_dict) 436 | 437 | >>> squares_first_ten_numbers_dict 438 | {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100} 439 | >>> type([]) 440 | 441 | >>> type({}) 442 | 443 | >>> type(set()) 444 | 445 | >>> type({1}) 446 | 447 | >>> type({'A':5}) 448 | 449 | >>> type(()) 450 | 451 | >>> type((1,2,3)) 452 | 453 | >>> 454 | -------------------------------------------------------------------------------- /00-python-shell/Section8 - OOPS Advanced - Done.py: -------------------------------------------------------------------------------- 1 | Last login: Fri May 18 15:27:46 on ttys003 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> class Animal: 7 | ... def bark(): 8 | ... print("bark") 9 | ... 10 | >>> animal = Animal() 11 | >>> animal.bark() 12 | Traceback (most recent call last): 13 | File "", line 1, in 14 | TypeError: bark() takes 0 positional arguments but 1 was given 15 | >>> class Animal: 16 | ... def bark(self): 17 | ... print("bark") 18 | ... 19 | >>> animal = Animal() 20 | >>> animal.bark() 21 | bark 22 | >>> class Pet: 23 | ... def bark(self): 24 | ... print("bark") 25 | ... def groom(self): 26 | ... print("groom") 27 | ... 28 | >>> pet = Pet() 29 | >>> pet.bark() 30 | bark 31 | >>> pet.groom() 32 | groom 33 | >>> class Pet(Animal): 34 | ... def groom(self): 35 | ... print("groom") 36 | ... 37 | >>> dog = Pet() 38 | >>> os.system('clear') 39 | Traceback (most recent call last): 40 | File "", line 1, in 41 | NameError: name 'os' is not defined 42 | >>> import os 43 | >>> os.system('clear') 44 | 45 | 46 | 47 | 48 | 49 | 0 50 | >>> 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /00-python-shell/Section9 - Exception Handling - Done.py: -------------------------------------------------------------------------------- 1 | Last login: Sat May 19 09:06:10 on ttys000 2 | Rangas-MacBook-Pro:~ rangaraokaranam$ python3 3 | Python 3.6.5 (default, Mar 30 2018, 06:42:10) 4 | [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin 5 | Type "help", "copyright", "credits" or "license" for more information. 6 | >>> 1/0 7 | Traceback (most recent call last): 8 | File "", line 1, in 9 | ZeroDivisionError: division by zero 10 | >>> i = 0 11 | >>> j = 10/i 12 | Traceback (most recent call last): 13 | File "", line 1, in 14 | ZeroDivisionError: division by zero 15 | >>> 2 + '2' 16 | Traceback (most recent call last): 17 | File "", line 1, in 18 | TypeError: unsupported operand type(s) for +: 'int' and 'str' 19 | >>> values = [1,'2'] 20 | >>> sum(values) 21 | Traceback (most recent call last): 22 | File "", line 1, in 23 | TypeError: unsupported operand type(s) for +: 'int' and 'str' 24 | >>> value 25 | Traceback (most recent call last): 26 | File "", line 1, in 27 | NameError: name 'value' is not defined 28 | >>> values.non_existing 29 | Traceback (most recent call last): 30 | File "", line 1, in 31 | AttributeError: 'list' object has no attribute 'non_existing' 32 | >>> values.non_existing() 33 | Traceback (most recent call last): 34 | File "", line 1, in 35 | AttributeError: 'list' object has no attribute 'non_existing' 36 | >>> import builtins 37 | >>> help(builtins) 38 | 39 | >>> help(builtins) 40 | 41 | >>> k = 10/non_existing_variable 42 | Traceback (most recent call last): 43 | File "", line 1, in 44 | NameError: name 'non_existing_variable' is not defined 45 | >>> 10/0 46 | Traceback (most recent call last): 47 | File "", line 1, in 48 | ZeroDivisionError: division by zero 49 | >>> values = [1,'1'] 50 | File "", line 1 51 | values = [1,'1'] 52 | ^ 53 | IndentationError: unexpected indent 54 | >>> sum(values) 55 | File "", line 1 56 | sum(values) 57 | ^ 58 | IndentationError: unexpected indent 59 | >>> values = [1,'1'] 60 | >>> sum(values) 61 | Traceback (most recent call last): 62 | File "", line 1, in 63 | TypeError: unsupported operand type(s) for +: 'int' and 'str' 64 | >>> import builtins 65 | >>> help(builtins) 66 | 67 | >>> 68 | -------------------------------------------------------------------------------- /01-first-python-project/elif_examples.py: -------------------------------------------------------------------------------- 1 | i = 2 2 | if i==1: 3 | print("i is 1") 4 | elif i==2: 5 | print("i is 2") 6 | elif i == 3: 7 | print("i is 3") 8 | else: 9 | print("i is not 1 or 2 or 3") -------------------------------------------------------------------------------- /01-first-python-project/for_exercises.py: -------------------------------------------------------------------------------- 1 | # is_prime(9); //Is a number Prime? 2 | # //H: 5 => True, 7 => True, 11 => True, 6 => False 3 | def is_prime(number): 4 | 5 | if(number < 2): 6 | return False 7 | 8 | # check if number is divisible by 2 to number - 1 9 | for divisor in range(2,number): 10 | if number % divisor == 0: 11 | return False 12 | 13 | return True 14 | 15 | # print(is_prime(15)); 16 | 17 | # sum_upto_n(6) 18 | # Sum of numbers upto n? 19 | # 1 + 2 + 3 + 4 + 5 + 6 20 | 21 | def sum_upto_n(number): 22 | 23 | sum = 0 24 | 25 | for i in range(1, number+1): 26 | sum = sum + i 27 | 28 | return sum 29 | 30 | # print(sum_upto_n(6)) 31 | # print(sum_upto_n(10)) 32 | 33 | def calculate_sum_of_divisors(number): 34 | sum = 0 35 | 36 | if(number < 2): 37 | return sum 38 | 39 | 40 | for divisor in range(1,number+1): 41 | if number % divisor == 0: 42 | sum = sum + divisor 43 | 44 | return sum 45 | 46 | # print(calculate_sum_of_divisors(6)) 47 | # print(calculate_sum_of_divisors(15)) 48 | 49 | def print_a_number_triangle(number): 50 | for j in range(1, number + 1): 51 | for i in range(1, j + 1): 52 | print(i, end=' ') 53 | print() 54 | 55 | 56 | print_a_number_triangle(6) -------------------------------------------------------------------------------- /01-first-python-project/hello_world.py: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | 3 | # TODO : Make sure I learn about for in depth -------------------------------------------------------------------------------- /01-first-python-project/if_puzzles.py: -------------------------------------------------------------------------------- 1 | number = 5 2 | if number < 0: 3 | number = number + 10 4 | number = number + 5 5 | print(number) 6 | 7 | # m = 15 8 | # 9 | # if m>20: 10 | # if m<20: 11 | # print("m>20") 12 | # else: 13 | # print("Who am I?") 14 | 15 | # l = 15 16 | # 17 | # if (l < 20): 18 | # print("l<20") 19 | # 20 | # if (l > 20): 21 | # print("l>20") 22 | # else: 23 | # print("Who am I?") 24 | 25 | 26 | 27 | # k = 15 28 | # if (k > 20): 29 | # print(1) 30 | # elif (k > 10): 31 | # print(2) 32 | # elif (k < 20): 33 | # print(3) 34 | # else: 35 | # print(4) -------------------------------------------------------------------------------- /01-first-python-project/input.py: -------------------------------------------------------------------------------- 1 | value = input("Enter a Value: ") 2 | integer_value = int(value) 3 | print("you entered ", integer_value) 4 | print(type(integer_value)) -------------------------------------------------------------------------------- /01-first-python-project/loop_puzzles.py: -------------------------------------------------------------------------------- 1 | # for i in range(1,11,2): 2 | # print(i, end=' ') 3 | 4 | # for i in range(11,0,-1): 5 | # print(i, end=' ') 6 | 7 | # 8 | # i = 5 9 | # while i*i < 10: 10 | # print(i) 11 | # print("done") 12 | # 13 | # 14 | # i = 2 15 | # while i*i < 10: 16 | # print(i, end=' ') 17 | # i = i + 1 18 | # print("done") 19 | 20 | # for i in range(1,11): 21 | # if i==5: 22 | # break 23 | # print(i, end=' ') 24 | # print("done") 25 | 26 | 27 | # for i in range(2,11): 28 | # if i%2: 29 | # break 30 | # print(i , end=' ') 31 | # 32 | # print("done") 33 | 34 | 35 | # for i in range(1,11): 36 | # if i%2: 37 | # continue 38 | # print(i , end=' ') 39 | # 40 | # print("done") 41 | 42 | for i in range(1,11): 43 | if i%2!=0: 44 | continue 45 | print(i , end=' ') 46 | print("done") -------------------------------------------------------------------------------- /01-first-python-project/multiplication_table.py: -------------------------------------------------------------------------------- 1 | def print_multiplication_table(table, start, end): 2 | for i in range(start, end + 1): 3 | print(f"{table} * {i} = {table * i}") 4 | 5 | # print multiplication table 5 6 | print_multiplication_table(5, 1, 10) 7 | 8 | # TODO : Make sure I learn about if 9 | -------------------------------------------------------------------------------- /01-first-python-project/number_menu.py: -------------------------------------------------------------------------------- 1 | number1 = int(input("Enter Number1: ")) 2 | number2 = int(input("Enter Number2: ")) 3 | 4 | print("\n\n1 - Add") 5 | print("2 - Subtract") 6 | print("3 - Divide") 7 | print("4 - Multiply") 8 | 9 | choice = int(input("Choose Operation: ")) 10 | 11 | # print(number1 + number2) 12 | # print(choice) 13 | if choice==1: 14 | result = number1 + number2 15 | elif choice==2: 16 | result = number1 - number2 17 | elif choice==3: 18 | result = number1 / number2 19 | elif choice==4: 20 | result = number1 * number2 21 | else: 22 | result = "Invalid Choice" 23 | 24 | print(result) 25 | -------------------------------------------------------------------------------- /01-first-python-project/number_menu_loop.py: -------------------------------------------------------------------------------- 1 | number1 = int(input("Enter Number1: ")) 2 | number2 = int(input("Enter Number2: ")) 3 | 4 | print("\n\n1 - Add") 5 | print("2 - Subtract") 6 | print("3 - Divide") 7 | print("4 - Multiply") 8 | print("5 - Exit") 9 | 10 | choice = int(input("Choose Operation: ")) 11 | 12 | while(choice != 5): 13 | 14 | # print(number1 + number2) 15 | # print(choice) 16 | if choice==1: 17 | result = number1 + number2 18 | elif choice==2: 19 | result = number1 - number2 20 | elif choice==3: 21 | result = number1 / number2 22 | elif choice==4: 23 | result = number1 * number2 24 | else: 25 | result = "Invalid Choice" 26 | 27 | print(result) 28 | 29 | choice = int(input("Choose Operation: ")) 30 | 31 | print("Thank You") -------------------------------------------------------------------------------- /01-first-python-project/simple_interest.py: -------------------------------------------------------------------------------- 1 | def calculate_simple_interest(principal, interest, duration) : 2 | return principal * (1 + interest * 0.01 * duration) 3 | 4 | print(calculate_simple_interest(10000,5,5)) 5 | -------------------------------------------------------------------------------- /01-first-python-project/temp.txt: -------------------------------------------------------------------------------- 1 | Simple Interest 2 | 3 | simple_interest(principal, interest, duration_in_years) 4 | 5 | simple_interest(10000,5,5) = 12500 6 | -------------------------------------------------------------------------------- /01-first-python-project/while_exercises.py: -------------------------------------------------------------------------------- 1 | # print_squares_upto_limit(30) 2 | # //For limit = 30, output would be 1 4 9 16 25 3 | # 4 | # print_cubes_upto_limit(30) 5 | # //For limit = 30, output would be 1 8 27 6 | 7 | def print_squares_upto_limit(limit): 8 | i = 1 9 | while i * i < limit: 10 | print(i*i, end = " ") 11 | i = i + 1 12 | 13 | def print_cubes_upto_limit(limit): 14 | i = 1 15 | while i * i * i < limit: 16 | print(i*i*i, end = " ") 17 | i = i + 1 18 | 19 | print_cubes_upto_limit(80) -------------------------------------------------------------------------------- /02-oops/Student.py: -------------------------------------------------------------------------------- 1 | class Student: 2 | 3 | def __init__(self, name, marks): 4 | self.name = name 5 | self.marks = marks 6 | 7 | def get_number_of_marks(self): 8 | return len(self.marks) 9 | 10 | def get_total_sum_of_marks(self): 11 | return sum(self.marks) 12 | 13 | def determine_maximum_mark(self): 14 | return max(self.marks) 15 | 16 | def determine_minimum_mark(self): 17 | return min(self.marks) 18 | 19 | def determine_average(self): 20 | return self.get_total_sum_of_marks()/self.get_number_of_marks() 21 | 22 | def add_new_mark(self, new_mark): 23 | self.marks.append(new_mark) 24 | 25 | def remove_mark_at_index(self, index): 26 | del self.marks[index] 27 | 28 | 29 | student = Student ("Ranga", [23, 45, 56, 75]) 30 | number = student.get_number_of_marks() 31 | 32 | sum_of_marks = student.get_total_sum_of_marks() 33 | maximum_mark = student.determine_maximum_mark() 34 | minimum_mark = student.determine_minimum_mark() 35 | average = student.determine_average() 36 | student.add_new_mark(35) 37 | student.remove_mark_at_index(2) 38 | print(student.marks) 39 | print(f"""Student[ 40 | number_of_marks-{number} 41 | sum_of_marks-{sum_of_marks} 42 | max-{maximum_mark} 43 | min-{minimum_mark} 44 | avg-{average} ] """) 45 | -------------------------------------------------------------------------------- /02-oops/book.py: -------------------------------------------------------------------------------- 1 | class Book: 2 | def __init__(self, name, copies=0): 3 | self.name = name 4 | self.copies = copies 5 | 6 | def increase_copies(self, how_much): 7 | self.copies += how_much 8 | 9 | def decrease_copies(self, how_much): 10 | self.copies -= how_much 11 | 12 | 13 | # copies 14 | # increase_copies 15 | # decrease_copies 16 | 17 | the_art_of_computer_programming = Book('The Art of Computer Programming') 18 | learning_python = Book('Learning Python in 100 Steps', 100) 19 | learning_restful_services = Book('Learning RestFul Service in 50 Steps') 20 | 21 | # print(the_art_of_computer_programming.name) 22 | # print(learning_python.name) 23 | # print(learning_restful_services.name) 24 | 25 | learning_python.increase_copies(25) 26 | learning_python.decrease_copies(10) 27 | learning_python.copies = 50 28 | 29 | print(learning_python.copies) -------------------------------------------------------------------------------- /02-oops/country.py: -------------------------------------------------------------------------------- 1 | from operator import attrgetter 2 | 3 | class Country: 4 | 5 | def __init__(self, name, population, area): 6 | self.name = name 7 | self.population = population 8 | self.area = area 9 | 10 | def __repr__(self): 11 | return repr((self.name,self.population,self.area)) 12 | 13 | 14 | countries = [Country('India',1200,100), 15 | Country('China', 1400, 200), 16 | Country('USA', 120, 300)] 17 | 18 | countries.append(Country('Russia',80,900)) 19 | 20 | countries.sort(key=attrgetter('population'), reverse=True) 21 | print(max(countries, key=attrgetter('population'))) 22 | print(min(countries, key=attrgetter('population'))) 23 | print(min(countries, key=attrgetter('area'))) 24 | print(max(countries, key=attrgetter('area'))) 25 | 26 | print(countries) -------------------------------------------------------------------------------- /02-oops/motor_bike.py: -------------------------------------------------------------------------------- 1 | # Class 2 | class MotorBike: 3 | def __init__(self, speed): 4 | self.speed = speed #State 5 | 6 | # Behavior 7 | def increase_speed(self, how_much): 8 | self.speed += how_much 9 | 10 | # Behavior 11 | def decrease_speed(self, how_much): 12 | if(self.speed-how_much>0): 13 | self.speed -= how_much 14 | else: 15 | print("Get a life") 16 | 17 | 18 | # instance 1 or object 1 19 | honda = MotorBike(50) 20 | 21 | # instance 2 or object 2 22 | ducati = MotorBike(250) 23 | 24 | # print(honda) 25 | # print(ducati) 26 | # 27 | 28 | # State changes through behavior of the object 29 | honda.increase_speed(150) 30 | ducati.increase_speed(25) 31 | 32 | # State changes through behavior of the object 33 | honda.decrease_speed(50) 34 | ducati.decrease_speed(25) 35 | 36 | honda.decrease_speed(350) 37 | 38 | print(honda.speed) 39 | print(ducati.speed) 40 | 41 | # 42 | # honda.speed = 150 43 | # print(honda.speed) 44 | # print(ducati.speed) -------------------------------------------------------------------------------- /02-oops/planet.py: -------------------------------------------------------------------------------- 1 | class Planet(object): 2 | def rotate(self): 3 | print("rotate") 4 | 5 | def revolve(self): 6 | print("revolve") 7 | 8 | def rotate_and_revolve(self): 9 | self.rotate() 10 | self.revolve() 11 | 12 | 13 | earth = Planet() 14 | earth.rotate_and_revolve() 15 | -------------------------------------------------------------------------------- /02-oops/word_count.py: -------------------------------------------------------------------------------- 1 | str = "This is an awesome occasion. This has never happened before." 2 | 3 | # key:value 4 | 5 | char_occurances = {} #[] 6 | 7 | for char in str: 8 | char_occurances[char] = char_occurances.get(char, 0) + 1 9 | 10 | print(char_occurances) 11 | 12 | word_occurances = {} #[] 13 | 14 | for word in str.split(): 15 | word_occurances[word] = word_occurances.get(word, 0) + 1 16 | 17 | print(word_occurances) -------------------------------------------------------------------------------- /04-exception-handling/currency.py: -------------------------------------------------------------------------------- 1 | #USD 20 2 | #USD 30 3 | #USD 50 4 | #INR 500 5 | 6 | 7 | class CurrenciesDoNotMatchError(Exception): 8 | def __init__(self,message): 9 | super().__init__(message) 10 | 11 | 12 | class Currency: 13 | def __init__(self, currency, amount): 14 | self.currency = currency 15 | self.amount = amount 16 | 17 | def __repr__(self): 18 | return repr((self.currency,self.amount)) 19 | 20 | def __add__(self, other): 21 | if self.currency != other.currency: 22 | #raise Exception("Currencies Do Not Match") 23 | raise CurrenciesDoNotMatchError(self.currency + " " + other.currency) 24 | total_amount = self.amount + other.amount 25 | return Currency(self.currency, total_amount) 26 | 27 | 28 | value1 = Currency("USD", 20) 29 | value2 = Currency("INR", 30) 30 | print(value1 + value2) -------------------------------------------------------------------------------- /04-exception-handling/exception_handling_basics.py: -------------------------------------------------------------------------------- 1 | # Open File/Resource 2 | 3 | try: 4 | # Business Logic to read 5 | i = 0 # Not hardcoded, getting a input from user 6 | j = 10/i 7 | values = [1,2] 8 | sum(values) 9 | except TypeError: 10 | print("TypeError") 11 | j = 10 12 | except ZeroDivisionError: 13 | print("ZeroDivisionError") 14 | j = 0 15 | except: 16 | print("OtherError") 17 | j = 5 18 | else: 19 | print("Else") 20 | finally: 21 | # Close 22 | print("Finally") 23 | 24 | print(j) 25 | print("End") -------------------------------------------------------------------------------- /04-exception-handling/exception_handling_puzzles.py: -------------------------------------------------------------------------------- 1 | # try: 2 | # 10/0 3 | # except TypeError: 4 | # print("TypeError") 5 | # except ZeroDivisionError: 6 | # print("ZeroDivisionError") 7 | # 8 | # print("End") 9 | 10 | # try: 11 | # 10/0 12 | # except object: 13 | # print("ZeroDivisionError") 14 | # # catching classes that do not inherit from BaseException is not allowed 15 | # print("End") 16 | 17 | # try: 18 | # 10/0 19 | # except BaseException: 20 | # print("BaseException") 21 | # 22 | # print("End") 23 | 24 | # try: 25 | # 10/0 26 | # except Exception: 27 | # print("Exception") 28 | 29 | # try: 30 | # sum([1, '1']) 31 | # except (ZeroDivisionError, TypeError): 32 | # print("Exception") 33 | # 34 | # print("End") 35 | 36 | # try: 37 | # sum([1,'1']) 38 | # except (ZeroDivisionError, TypeError): 39 | # print("Exception") 40 | # 41 | # print("End") 42 | 43 | try: 44 | sum([1,'1']) 45 | except TypeError as error: 46 | print(error) 47 | print("End") -------------------------------------------------------------------------------- /05-tips/all_about_methods.py: -------------------------------------------------------------------------------- 1 | def example_method(mandatory_parameter, default_parameter="Default" 2 | , *args, **kwargs): 3 | print(f""" 4 | mandatory_parameter = {mandatory_parameter} {type(mandatory_parameter)} 5 | default_parameter = {default_parameter} {type(default_parameter)} 6 | args = {args} {type(args)} 7 | kwargs = {kwargs} {type(kwargs)} 8 | """) 9 | 10 | # example_method() #example_method() missing 1 required positional argument 11 | # example_method(mandatory_parameter=15) #example_method(15) 12 | # example_method(25,"Some String") 13 | # example_method(25,"String 1","String 2","String 3") 14 | # example_method(25,"String 1","String 2","String 3","String 4","String 5") 15 | # example_method(25,"String 1","String 2","String 3",key1='a', key2='b') 16 | #example_method(25,"String 1",key1='a', key2='b') 17 | # example_method(key1='a', key2='b',mandatory_parameter=25,default_parameter="String 1") 18 | # example_method(25,"String 1",key1='a', key2='b') 19 | example_list = [1,2,3,4,5,6] 20 | # example_method(*example_list) 21 | example_dict = {'a':'1', 'b':'2'} 22 | example_method(*example_list, **example_dict) -------------------------------------------------------------------------------- /05-tips/module_1.py: -------------------------------------------------------------------------------- 1 | def method_1(): 2 | print("method 1") 3 | 4 | class ClassA: 5 | def class_method_1(self): 6 | print("class_method_1 method 1") 7 | 8 | # print(__name__) 9 | 10 | if __name__ == '__main__': 11 | method_1() 12 | ClassA().class_method_1() -------------------------------------------------------------------------------- /05-tips/module_2.py: -------------------------------------------------------------------------------- 1 | import module_1 2 | 3 | module_1.method_1() 4 | module_1.ClassA().class_method_1() -------------------------------------------------------------------------------- /06-oops-advanced/amphibian.py: -------------------------------------------------------------------------------- 1 | class LandAnimal: 2 | def __init__(self): 3 | super().__init__() 4 | self.walking_speed = 5 5 | 6 | def increase_walking_speed(self, how_much): 7 | self.walking_speed += how_much 8 | 9 | class WaterAnimal: 10 | def __init__(self): 11 | super().__init__() 12 | self.swimming_speed = 10 13 | 14 | def increase_swimming_speed(self, how_much): 15 | self.swimming_speed += how_much 16 | 17 | class Amphibian(WaterAnimal, LandAnimal): 18 | def __init__(self): 19 | super().__init__() 20 | 21 | 22 | amphibian = Amphibian() 23 | amphibian.increase_swimming_speed(25) 24 | amphibian.increase_walking_speed(50) 25 | print(amphibian.swimming_speed) 26 | print(amphibian.walking_speed) -------------------------------------------------------------------------------- /06-oops-advanced/animal.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | class AbstractAnimal(ABC): 4 | @abstractmethod 5 | def bark(self): pass 6 | 7 | class Dog(AbstractAnimal): 8 | def bark(self): 9 | print("Bow Bow") 10 | 11 | print(Dog().bark()) -------------------------------------------------------------------------------- /06-oops-advanced/book_reviews.py: -------------------------------------------------------------------------------- 1 | class Book(object): 2 | def __init__(self, id, name, author): 3 | self.id = id 4 | self.name = name 5 | self.author = author 6 | self.reviews = [] 7 | 8 | def __repr__(self): 9 | return repr((self.id,self.name,self.author,self.reviews)) 10 | 11 | def add_review(self, review): 12 | self.reviews.append(review) 13 | 14 | 15 | class Review: 16 | def __init__(self, id, description, rating): 17 | self.id = id 18 | self.description = description 19 | self.rating = rating 20 | 21 | def __repr__(self): 22 | return repr((self.id,self.description,self.rating)) 23 | 24 | 25 | book = Book(123, 'Object Oriented Programming with Python', 'Ranga') 26 | 27 | # book.add_review() 28 | book.add_review(Review(10, "Great Book", 5)) 29 | book.add_review(Review(101, "Awesome", 5)) 30 | 31 | print(book) -------------------------------------------------------------------------------- /06-oops-advanced/fan.py: -------------------------------------------------------------------------------- 1 | # State 2 | 3 | # make 4 | # radius 5 | # color 6 | # speed 7 | # is_on 8 | 9 | # Behavior 10 | 11 | # switch_on 12 | # switch_off 13 | # increase_speed 14 | # decrease_speed 15 | 16 | class Fan: 17 | def __init__(self, make, radius, color): 18 | self.make = make 19 | self.radius = radius 20 | self.color = color 21 | self.speed = 0 22 | self.is_on = False 23 | 24 | def __repr__(self): 25 | return repr((self.make,self.radius,self.color,self.speed,self.is_on)) 26 | 27 | def switch_on(self): 28 | self.is_on = True 29 | self.speed = 3 30 | 31 | def switch_off(self): 32 | self.is_on = False 33 | self.speed = 0 34 | 35 | # increase_speed 36 | # decrease_speed 37 | 38 | 39 | fan = Fan('Manufacturer 1', 5, 'Green') 40 | fan.switch_on() 41 | print(fan) 42 | fan.switch_off() 43 | print(fan) -------------------------------------------------------------------------------- /06-oops-advanced/person_inheritance.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self,name, email): 3 | self.name = name 4 | self.email = email 5 | 6 | def __repr__(self): 7 | return repr((self.name,self.email)) 8 | 9 | 10 | class Student(Person): 11 | def __init__(self, name, email, college, cls): 12 | super().__init__(name,email) 13 | self.college = college 14 | self.cls = cls 15 | 16 | def __repr__(self): 17 | return repr((super().__repr__(), self.college,self.cls)) 18 | 19 | person = Person('Ranga','in28minutes@gmail.com') 20 | print(person) 21 | 22 | student = Student('Ranga','in28minutes@gmail.com', 'Stanford', 'Algorithms' ) 23 | print(student) 24 | 25 | 26 | # Person 27 | # name, email 28 | # Student 29 | # college, class 30 | # Employee 31 | # title, employer -------------------------------------------------------------------------------- /06-oops-advanced/recipe.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | 4 | class AbstractRecipe(ABC): 5 | 6 | def execute(self): 7 | self.prepare() 8 | self.recipe() 9 | self.cleanup() 10 | 11 | @abstractmethod 12 | def prepare(self): pass 13 | 14 | @abstractmethod 15 | def recipe(self): pass 16 | 17 | @abstractmethod 18 | def cleanup(self): pass 19 | 20 | class Recipe1(AbstractRecipe): 21 | 22 | def prepare(self): 23 | print('do the dishes') 24 | print('get raw materials') 25 | 26 | def recipe(self): 27 | print('execute the steps') 28 | 29 | def cleanup(self): pass 30 | 31 | 32 | class MicrowaveRecipe(AbstractRecipe): 33 | 34 | def prepare(self): 35 | print('do the dishes') 36 | print('get raw materials') 37 | print('switch on microwave') 38 | 39 | def recipe(self): 40 | print('execute the steps') 41 | 42 | def cleanup(self): 43 | print('switch off microwave') 44 | 45 | MicrowaveRecipe().execute() -------------------------------------------------------------------------------- /06-oops-advanced/test.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/in28minutes/learn-programming-with-python-/fbe79ba59fbc850d91c5bd10765fdfbc8d0d1fee/06-oops-advanced/test.py -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learn Python Programming in 150 Steps 2 | 3 | ## Hands on Step by Step Introduction to one of the most popular programming languages 4 | 5 | ## Course Links 6 | 7 | - TODO 8 | 9 | ## Installing Tools 10 | - TODO 11 | 12 | ## Introduction To Course 13 | 14 | We love Programming. Our aim with this course is to create a love for Programming. 15 | 16 | Python is one of the most popular programming languages. Python offers both object oriented and structural programming features. 17 | 18 | We take an hands-on approach using a combination of Python Shell and PyCharm as an IDE to illustrate more than 150 Python Coding Exercises, Puzzles and Code Examples. 19 | 20 | In more than 150 Steps, we explore the most important Python Programming Language Features 21 | - Basics of Python Programming - Expressions, Variables and Printing Output 22 | - Python Operators - Python Assignment Operator, Relational and Logical Operators, Short Circuit Operators 23 | - Python Conditionals and If Statement 24 | - Methods - Parameters, Arguments and Return Values 25 | - An Overview Of Python Platform 26 | - Object Oriented Programming - Class, Object, State and Behavior 27 | - Basics of OOPS - Encapsulation, Inheritance and Abstract Class. 28 | - Basics about Python Data Types 29 | - Basics about Python Built in Modules 30 | - Conditionals with Python - If Else Statement, Nested If Else 31 | - Loops - For Loop, While Loop in Python, Break and Continue 32 | - Immutablity of Python Basic Types 33 | - Python Data Structures - List, Set, Dictionary and Tuples 34 | - Introduction to Variable Arguments 35 | - Basics of Designing a Class - Class, Object, State and Behavior. Deciding State and Constructors. 36 | - Introduction to Exception Handling - Your Thought Process during Exception Handling. try, except, else and finally. Exception Hierarchy. Throwing an Exception. Creating and Throwing a Custom Exception. 37 | 38 | ## What You will learn 39 | - You will learn how to think as a Python Programmer 40 | - You will learn how to start your journey as a Python Programmer 41 | - You will learn the basics of PyCharm IDE and Python Shell 42 | - You will learn to develop awesome object oriented programs with Python 43 | - You will solve a wide variety of hands-on exercises on the topics discussed below 44 | - You will learn the basics of programming - variables, choosing a data type, conditional execution, loops, writing great methods, breaking down problems into sub problems and implementing exception handling. 45 | - You will learn the basics of Object Oriented Programming - Inheritance, Abstract Class and Constructors 46 | - You will learn the important concepts of Object Oriented Programming - Abstraction and Inheritance 47 | - You will learn about a wide variety of Python Data Structures - List, Set, Dictionary and Tuples 48 | 49 | ## Requirements 50 | - Connectivity to Internet to download Python 3 and PyCharm. 51 | - We will help you install Python 3 and PyCharm. 52 | 53 | ## Course Details 54 | 55 | #### Introduction 56 | - Step 00 - How To Make Best use of the Course Guide? TODO 57 | - Step 01 - Installing Python TODO 58 | 59 | #### Introduction To Python Programming With Multiplication Table 60 | - Step 00 - Getting Started with Programming 61 | - Step 01 - Introduction to Multiplication Table challenge 62 | - Step 02 - Launch Python Shell - TODO 63 | - Step 03 - Break Down Multiplication Table Challenge 64 | - Step 04 - Python Expression - An Introduction 65 | - Step 05 - Python Expression - Exercises 66 | - Step 06 - Java Expression - Puzzles 67 | - Step 07 - Printing output to console with Python 68 | - Step 08 - Calling Functions in Python - Puzzles 69 | - Step 09 - Advanced Printing output to console with Python 70 | - Step 10 - Advanced Printing output to console with Python - Exercises and Puzzles 71 | - Step 11 - Introduction to Variables in Python 72 | - Step 12 - Introduction to Variables in Python - Puzzles 73 | - Step 13 - Assignment Statement 74 | - Step 14 - Tip - Using formatted strings in print method 75 | - Step 15 - Using For Loop to Print Multiplication Table 76 | - Step 16 - Using For Loop in Python - Puzzles 77 | - Step 17 - Using For Loop in Python - Exercises 78 | - Step 18 - Getting Started with Programming - Revise all Terminology 79 | 80 | #### Introduction To Methods - MultiplicationTable 81 | - Step 00 - Section 02 - Methods - An Introduction 82 | - Step 01 - Your First Python Method - Hello World Twice and Exercise Statements 83 | - Step 02 - Introduction to Python Methods - Exercises 84 | - Step 03 - Introduction to Python Methods - Arguments and Parameters 85 | - Step 04 - Introduction to Python Method Parameters - Exercises 86 | - Step 05 - Introduction to Python Method - Multiple Parameters 87 | - Step 06 - Getting back to Multiplication Table - Creating a method 88 | - Step 07 - Tip - Indentation is king 89 | - Step 08 - Introduction to Python Method - Puzzles - Named Parameters 90 | - Step 09 - Introduction to Python Method - Return Values 91 | - Step 10 - Introduction to Python Method - Return Values - Exercises 92 | 93 | #### Introduction To Python Platform 94 | - Step 01 - Writing and Executing your First Python Script 95 | - Step 02 - Python Virtual Machine and bytecode 96 | 97 | #### Introduction To PyCharm 98 | - Step 01 - Installing and Introduction to PyCharm - TODO 99 | - Step 02 - Write and Execute a Python File with PyCharm 100 | - Step 03 - Execise - Write Multiplication Table Method with PyCharm 101 | - Step 04 - Debugging Code with PyCharm 102 | - Step 05 - PyCharm Tips : Tool Windows 103 | - Step 06 - PyCharm Tips : Keyboard Shortcuts 104 | 105 | #### Basic Numeric Data Types and Conditional Execution 106 | - Step 01 - Introduction to Numeric Data Types 107 | - Step 02 - Exercise - Calculate Simple Interest 108 | - Step 03 - Introduction to Numeric Data Types - Puzzles 109 | - Step 04 - Introduction to Boolean Data Type 110 | - Step 05 - Introduction to If Condition 111 | - Step 06 - Introduction to If Condition - Exercises 112 | - Step 07 - Logical Operators - and or not 113 | - Step 08 - Logical Operators - and or not - Puzzles 114 | - Step 09 - Introduction to If Condition - else and elif 115 | - Step 10 - if, else and elif - Menu Exercise - Part 1 116 | - Step 11 - if, else and elif - Menu Exercise - Part 2 117 | - Step 12 - if, else and elif - Puzzles 118 | 119 | #### Text in Python 120 | - Step 01 - Text in Python - Methods in str class ##EDIT 121 | - Step 02 - Data Type Conversion - Puzzles 122 | - Step 03 - Strings are immutable 123 | - Step 04 - There is no seperate Character data type 124 | - Step 05 - String module ##EDIT 125 | - Step 06 - Exercise - is_vowel, print lower case and upper case characters 126 | - Step 07 - String - Exercises and Puzzles 127 | - Step 08 - String - Conclusion 128 | 129 | #### Python Loops 130 | - Step 01 - For loop basics 131 | - Step 02 - For loop exercise 1 - is_prime 132 | - Step 03 - For loop exercise 2 - sum_upto_n 133 | - Step 04 - For loop exercise 3 - sum of divisors 134 | - Step 05 - For loop exercise 4 - print a number triangle 135 | - Step 06 - Introduction to while loop in Python 136 | - Step 07 - While loop - Exercises 137 | - Step 08 - Choosing a Loop - Menu Exercise 138 | - Step 09 - Loops - Puzzles - break and continue 139 | 140 | # Tips For Beginners 141 | - Tip 1 - Using Predefined Python Modules 142 | - Tip 2 - Loop - Getting Index Element 143 | - Tip 3 - Short hand If Statement 144 | - Tip 4 - Python is Strongly Typed and Dynamic Language 145 | - Tip 4 - Beginners Mistakes - Shadowing 146 | - Tip 5 - Beginners Mistakes - Indentation 147 | - Tip 6 - PEP8 - Python Style Guide 148 | - Tip 7 - PEP20 - Zen of Python 149 | 150 | #### Introduction To Object Oriented Programming 151 | - Step 00 - Introduction to Object Oriented Programming - Section Overview 152 | - Step 01 - Introduction to Object Oriented Programming - Basics 153 | - Step 02 - Introduction to Object Oriented Programming - Terminology - Class, Object, State and Behavior 154 | - Step 03 - Introduction to Object Oriented Programming - Exercise - Online Shopping System and Person 155 | - Step 04 - First Class and Object - Country class 156 | - Step 05 - Create Motor Bike Python Class and a couple of objects 157 | - Step 06 - Class and Objects - a few Puzzles 158 | - Step 07 - Constructor for MotorBike class 159 | - Step 08 - Constructor for Book class - Exercise 160 | - Step 09 - Constructors - Puzzles 161 | - Step 10 - Class and Objects - Methods and Behavior 162 | - Step 11 - Exercise - Enhance Book class with copies 163 | - Step 12 - Class and Objects - Methods and Behavior - Puzzles on self 164 | - Step 13 - Advantages of Encapsulation 165 | - Step 14 - Everything is Object in Python 166 | 167 | #### Python Data Structures 168 | - Step 01 - Python Data Structures - Why do we need them? 169 | - Step 02 - Operations on List Data Structure ##EDIT 170 | - Step 03 - Exercise with List - Student class 171 | - Step 04 - Puzzles with Strings Lists ## 172 | - Step 05 - List Slicing 173 | - Step 06 - List Sorting, Looping and Reversing ## 174 | - Step 07 - List as a Stack and Queue ## 175 | - Step 08 - List with a custom class - Country and representation 176 | - Step 08 - List with a custom class - Part 2 - sorting, max and min 177 | - Step 09 - List Comprehension ## 178 | - Step 10 - Introduction to Set ## 179 | - Step 11 - Introduction to Dictionary ## 180 | - Step 12 - Exercise with Dictionary - Word and Character Occurances 181 | - Step 13 - Puzzles with Data Structures ## 182 | - Step 14 - Tuples 183 | 184 | 185 | #### Object Oriented Programming Again 186 | - Step 01 - OOPS Basics Revised 187 | - Step 02 - Designing a Fan Class 188 | - Step 03 - Object Composition - Book and Reviews 189 | - Step 04 - Why do we need Inheritance 190 | - Step 05 - All classes in Python 3 inherit from object 191 | - Step 06 - Multiple Inheritance ## 192 | - Step 07 - Creating and Using an Abstract Class 193 | - Step 08 - Template Method Pattern with Recipe Class 194 | - Step 09 - A Quick Revision 195 | 196 | #### Error Handling with Python 197 | - Step 01 - Introduction to Error Handling - Your Thought Process during Error Handling 198 | - Step 02 - Basics of Exception Hierarchy 199 | - Step 03 - Basics of Error Handling - try except 200 | - Step 04 - Handling Multiple Errors with Multiple except blocks 201 | - Step 05 - Error Handling - Puzzles - Exception Details and 202 | - Step 06 - Error Handling - finally and else 203 | - Step 07 - Error Handling - Puzzles 2 204 | - Step 08 - Raising Exceptions 205 | - Step 09 - Raising Custom Exceptions 206 | - Step 10 - Exception Handling Best Practices 207 | 208 | # Final Tips 209 | - Tip 1 - Math Module and Decimal Class 210 | - Tip 2 - Statistics Module - find mean and median 211 | - Tip 3 - Collections Module - deque for Queue and Stack 212 | - Tip 4 - Date Module 213 | - Tip 5 - Methods and Arguments - Basics 214 | - Tip 6 - Methods and Arguments - Keyword Arguments 215 | - Tip 7 - Methods and Arguments - Unpacking Lists and Dictionaries 216 | - Tip 8 - Creating Custom Modules and Using Them 217 | - Tip 9 - Defining Equality for Classes 218 | - Tip 10 - None 219 | 220 | ### Course Recording Notes 221 | 222 | #### Preview Video 223 | - Welcome to course on *** in ** simple steps. 224 | - I'm Ranga Karanam. I've so and so much experience with ... I've been using this framework for ... 225 | - At in28minutes, we ask one question everyday - How to create more effective courses? All our success - *** students on Udemy and *** subscribers on Youtube - is a result of this pursuit of excellence. 226 | - You will develop *** and *** using *** 227 | - You will learn the basics like *** and move on to the advanced concepts like ***. 228 | - You will use 229 | - ... todo ... 230 | - Maven for dependency management, building and running the application in tomcat. 231 | - Eclipse IDE 232 | - All the code for this course and the step by step details are in our Github repository. 233 | - We have an awesome installation guide to help you install Maven and Eclipse. You are NOT expected to have any experience with Eclipse, Maven, or Tomcat. 234 | - What are we waiting for? Lets have some fun with *** in *** steps. We had a lot of fun creating this course for you and We are confident that you will have a lot of fun. I hope you are as excited as we are to learn more. Go ahead and enroll for the course. Or take a test drive with a free preview. See you in the course. 235 | 236 | #### Course Intro Video 237 | - Welcome to this course on ***. We are excited to teach you how to build awesome ***. 238 | - In this video, we introduce you to the different sections of the course. By the end of the video you should have a clear idea of how to make the best use of the course. 239 | - We have organized this course into 6 different sections. We have designed each section to be independent of each other. That means, you have the flexibility of customizing the course based on your skills and your needs. 240 | - If you have experience with Spring and Spring Boot, you can skip these sections. 241 | - Lets get a quick overview of each of the sections now: 242 | - Section I is an one hour introduction to Spring 243 | - Section II is an one hour introduction to Spring Boot.. 244 | - In summary this is your course. Feel free to create your own path and tailor it to your needs. 245 | - I will see you in the next video where we introduce you to our github repository 246 | 247 | #### Overview of the Github Repository 248 | - Welcome Back. In this video, we give you an overview of how our github repository for this course is organized. 249 | - Github repository for this course is at ****. 250 | - Home page of the github repository has an overview of the course and installation guide 251 | - For each hands-on section of the course, we have a seperate folder in the repository. You can see these five folders for *** different sections 252 | - Folder 1 contains ... 253 | - Folder 2 contains ... 254 | - Folder 3 contains ... 255 | - Each of these folders contain 256 | - Step by Step details of the sections 257 | - Complete code example at the end of the section 258 | - Intermediate backups at different stages of the section 259 | - Useful Links 260 | - For example, let's look at the folder for ***. Home page of the folder contains 261 | - Step by step details : What are we going to do in each step 262 | - Useful Links : Different links that would be useful during the course 263 | - Complete Code, Snippets and Examples : Example code that your can use during the section. For example, If you are using a class and you do not know the package of the class, you can search here and quickly find what you would need. 264 | - Intermediate Backups : You can download any of these zips and import them into Eclipse as maven projects. File > Import > Existing Maven Projects. 265 | - Understanding our github repository is key part of making best use of this course. I recommend to spend some time with our github repository and I will see you in the next video. 266 | 267 | #### Installation of Tools Video 268 | - In this video, we will help you install all the basic tools to get you started with the course 269 | - We use 270 | - Maven for Dependency Management 271 | - Eclipse as IDE 272 | - .. 273 | - Step by step details to install Python, Eclipse and Maven are in the installation guide present here. Also included are links to 5 videos that will help you to install and trouble shoot installations. 274 | - If you have any problems during the course, we recommend you to look at the troubleshooting section of the installation playlist. 275 | - Get your tools ready and I will see you in the course 276 | 277 | #### Each Section Introduction 278 | - Why is this section important to the course? 279 | - What is discussed in this section? 280 | - What is the github folder for this section? 281 | - Can a student skip this sections? 282 | - Is there a trouble shooting guide? 283 | - What are the backups available? 284 | - Are examples in this section dependent on any other section? 285 | 286 | #### Conclusion Video 287 | - Congratulations! You have successfully completed the course on ... We covered a wide range of topics starting from Spring, Spring Boot to ..... I'm sure you had a lot of fun doing this course. If you loved this course, we would love to hear from you. Do not forget to leave us a review. Until we see you in another in28minutes course, here's bye from the team here at in28minutes. 288 | - To find out more about *** use these References 289 | 290 | ## Templates 291 | 292 | ### Welcome Message 293 | ``` 294 | 295 | ## ADD A FEW SAMPLE REVIEWS AFter a couple of months 296 | ## ADD A FEW SAMPLE REVIEWS - in the description of the course 297 | 298 | Congratulations on joining this course from in28Minutes. 299 | 300 | We have 6800+ 5 Star reviews on our courses. 301 | 302 | I hope that by the time you are prompted to leave a review, that you think this course is an amazing course and can write a few sentences about what you like about the course for future students to see. If you do not think this course is a 5-star course, we want to make it a better course for you! Please message me with ways that I can make it the best course for you. 303 | 304 | There are three things you need to understand before you start this course! 305 | 306 | 1...... Listen + See + Do Hands-on + Repeat = 90% Retention 307 | For the first 2 hours, we repeat a few concepts to help you retain them. . 308 | 309 | 2...... Set Yourself a Goal 310 | Set 1 hour aside every day for the next week for this course! No exceptions allowed :) 311 | 312 | 3...... Udemy asks you for a review very early in the course! If you are not ready for giving a review, you can skip giving a review. 313 | 314 | Thank you and enjoy the course, 315 | Ranga 316 | ``` 317 | 318 | ### Thank You for completing the course message 319 | 320 | ``` 321 | Congratulations on completing the course from in28Minutes. 322 | 323 | We have 6800+ 5 Star reviews on our courses. We hope you think this course is an amazing course and can write a few sentences about what you like about the course for future students to see. 324 | 325 | We are on a constant journey to improve our courses further. Do message me if you have any suggestions. 326 | 327 | Good Luck for your future. 328 | 329 | Ranga from in28Minutes 330 | ``` 331 | 332 | ### Bonus Lectures 333 | 334 | ``` 335 | Our Best Selling Courses 336 | Get unbelievable offers on all our best-selling courses! 337 | http://eepurl.com/bOJulL 338 | 339 | ``` 340 | 341 | ## Future Things To Do 342 | 343 | 344 | 345 | ## Course Checklist 346 | 347 | Teachable 348 | - Publish course and put the link in PDF and Github 349 | 350 | YouTube 351 | - Decide Topics & Publishing Strategy 352 | - Automation 353 | - Starting video for individual sections 354 | - End video for small videos - talking about teachable course and pdf 355 | --------------------------------------------------------------------------------