Python for Developers: Learn to Develop Efficient Programs using Python (English Edition)
معرفی کتاب «Python for Developers: Learn to Develop Efficient Programs using Python (English Edition)» نوشتهٔ Mohit Raj، منتشرشده توسط نشر BPB Publications در سال 2023. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Python for Developers: Learn to Develop Efficient Programs using Python (English Edition)» در دستهٔ بدون دستهبندی قرار دارد.
Master python programming language in easy steps Key Features ● Start from basics of Python Control statement, loop structure, break, continue, and pass statement ● Detailed description of Python data types: string, tuple, list, and dictionary with the help of example ● Organizing code using function, modules, and packages ● Saving text and complex data in text, pickle, and JSON files ● Learn the use of time and time zones ● Parallel execution with the help of threading, multiprocessing, and subprocessing ● Helpful modules for industry Description It is said that learning Python is easy, but if a learner did not get the right path, then things can get complicated. This book is designed in such a way that you start from basics, followed by advance levels and then move on to some industry-related modules. The initial chapters are written in a simple manner; some chapters are of advance level. Start from the data structure of Python, such as string, list, tuple, and dictionary. The function and module chapter will let you know how to organize a large code. The built-in functions and modules like collections will give you greater flexibility to write efficient codes. The "time" chapter is very important when we deal with time-related things. The mid-chapter contains the advance chapters such as regular expressions, interaction with OS, and multithreading. These chapters are helpful when we want to search the pattern, run the OS commands, and execute the program in parallel. The last chapters are specially designed from an industry point of view. In order to ensure a high quality of code, we use config-parser to avoid hard-coding and logger to log the events. In the multiprocessing and subprocess chapter, you will learn creation, execution, and communication between the processes. What will you learn Python for developers is created by taking beginner and intermediate programmers. The book starts from scratch and takes you to the advanced level. After learning advance levels, you will learn parallel programming using multithreading, multiprocessing, and sub-processing. The book will provide information on modules which will be helpful form industry perspective. The book also contains the question for the preparation of the interview. You will also learn the difference between Python 2.7 and Python 3.7. Some of the chapters include an advance part, which will give an in-depth knowledge of the chapters. Who this book is for This book is for whoever wants to learn Python and aspires to become a developer or work on projects. Beginners can read this book easily; however, a little knowledge about the programming concepts would be helpful. Basic knowledge of computers would suffice. Table of Contents 1. Introduction to Python 2. Python Operators 3. Control statements and loop 4. Strings 5. List and tuple 6. Dictionary and sets 7. Functions 8. Modules 9. Exception handling 10. File handling 11. Collection 12. Random modules and built-in function 13. Time 14. Regular expression 15. Operating system interfaces 16. Class 17. Threads 18. Queue 19. Multiprocessing and Subprocess 20. Useful Modules About the Author Mohit is a Python programmer with a keen interest in the field of information security. He has completed his Bachelor's degree (B.tech)in Computer Science from Kurukshetra University, Kurukshetra, and a Master’s in Engineering (2012) in Computer Science from Thapar University, Patiala. He is a CEH, ECSA from EC-Council USA. He has worked in IBM, Teramatrix (Startup), and Sapient. He has been pursuing a Ph.D. degree in Blockchain from Thapar Institute of Engineering & Technology under Dr. Maninder Singh for two years. Mohit has published several articles in national and international magazines. 1. Introduction to Python ....................................................................................... 1 Structure .......................................................................................................... 1 Objective .......................................................................................................... 1 What is Python? ............................................................................................. 2 Reasons to choose Python .......................................................................... 2 Multi-purpose ................................................................................................. 2 Vast library and module support .................................................................... 3 Readability ...................................................................................................... 3 Object-Oriented .............................................................................................. 3 Platform independent ...................................................................................... 3 Python is dynamically typed and strongly typed ........................................... 3 Python installation ......................................................................................... 4 Installation of Python 3.x in Windows 10 ...................................................... 4 Installation of Python in Linux ................................................................. 6 Basic Python syntax ....................................................................................... 9 Print statement .......................................................................................... 9 Saving the program .................................................................................. 10 Triple quotes ............................................................................................. 10 Python Back Slash \ .................................................................................11 Escape sequence of string ..........................................................................11 Python formatted output.......................................................................... 12 Conclusion .................................................................................................... 12 Questions ....................................................................................................... 13 2. Python Operators ............................................................................................... 15 Structure ........................................................................................................ 15 Objective ........................................................................................................ 15 Variables ........................................................................................................ 15 Assignment statement ................................................................................. 16 Multiple assignment .................................................................................... 16 Numeric data types ..................................................................................... 17 xi Integer numbers ........................................................................................... 18 Floating-point numbers .............................................................................. 18 Python character sets ................................................................................... 18 Conversion functions .................................................................................. 19 Operators ....................................................................................................... 20 Arithmetic operators ................................................................................... 20 Type conversions ...................................................................................... 21 Comparison operators ................................................................................. 22 Assignment operators ................................................................................. 23 Bitwise operators .......................................................................................... 24 Logical operators .......................................................................................... 25 Membership operators ................................................................................ 26 Identity Operators ........................................................................................ 27 Operator precedence ................................................................................... 28 Advance part ................................................................................................ 29 Conclusion .................................................................................................... 30 Questions ....................................................................................................... 30 3. Control Statement and Loop ........................................................................... 31 Structure ........................................................................................................ 31 Objective ........................................................................................................ 32 Conditional statement ................................................................................. 32 If and if-else statements ............................................................................ 32 if statement .................................................................................................... 33 Tabs or Spaces? ........................................................................................ 34 if-else statement ........................................................................................ 34 if-elif-else structure .................................................................................. 35 Range() ........................................................................................................... 37 Loops.............................................................................................................. 39 For loop..................................................................................................... 39 Printing number 0 to 9 ................................................................................. 40 Printing the numbers in horizontal fashion ................................................. 40 For loop with string ...................................................................................... 41 Exercise 1 ...................................................................................................... 42 xii Exercise 2 ...................................................................................................... 43 while loop ...................................................................................................... 43 Break statement ............................................................................................ 45 Break statement with the while loop ........................................................ 46 Continue statement ...................................................................................... 47 else statement ............................................................................................... 48 pass statement .............................................................................................. 49 Conclusion .................................................................................................... 50 Questions ....................................................................................................... 50 4. Strings .................................................................................................................. 51 Structure ........................................................................................................ 51 Objective ........................................................................................................ 51 Indexing using subscript operator ............................................................ 53 Slicing for substrings ................................................................................... 54 String methods ............................................................................................. 56 count() ...................................................................................................... 56 find() ......................................................................................................... 57 Justify methods ......................................................................................... 57 ljust() ............................................................................................................. 57 rjust() ............................................................................................................ 58 center() .......................................................................................................... 59 zfill() .............................................................................................................. 59 Case methods ............................................................................................ 60 lower() ........................................................................................................... 60 upper() ........................................................................................................... 60 capitalize() ..................................................................................................... 61 swapcase() ..................................................................................................... 61 Strip methods ........................................................................................... 61 replace() .................................................................................................... 62 Split methods ............................................................................................ 63 Partition methods ..................................................................................... 64 Join method............................................................................................... 65 String Boolean methods ........................................................................... 65 startswith().................................................................................................... 65 xiii endswith() ..................................................................................................... 66 isdigit() .......................................................................................................... 67 isalpha() ......................................................................................................... 67 isalnum() ....................................................................................................... 68 isspace() ......................................................................................................... 68 format() ......................................................................................................... 68 String functions ............................................................................................ 69 Max()........................................................................................................ 69 min() ......................................................................................................... 70 Conclusion .................................................................................................... 70 Question ........................................................................................................ 70 5. Tuple and List ..................................................................................................... 73 Structure ........................................................................................................ 73 Objective ........................................................................................................ 74 Tuple .............................................................................................................. 74 Creating tuple .......................................................................................... 74 Empty tuple................................................................................................... 74 Creating tuple with the items .................................................................. 75 Indexing tuple .............................................................................................. 75 Slicing of tuple ......................................................................................... 76 Tuple methods .............................................................................................. 78 index() ...................................................................................................... 79 Tuple functions ............................................................................................. 79 len() .......................................................................................................... 79 max() ........................................................................................................ 79 Min() ........................................................................................................ 80 Operations of Tuples.................................................................................... 80 Addition of tuples ..................................................................................... 80 Multiplication of tuple ............................................................................. 80 In operator ................................................................................................ 81 for loop with tuple ....................................................................................... 81 Unpacking of tuple ...................................................................................... 82 List .................................................................................................................. 83 Creating a list ........................................................................................... 83 xiv Empty list ...................................................................................................... 83 List with the elements ................................................................................... 83 List operations .............................................................................................. 84 Accessing item of a list ............................................................................. 84 Updating list ............................................................................................ 84 Deleting list item...................................................................................... 85 Addition of the lists .................................................................................. 85 Multiplication of List ............................................................................... 86 in operator ................................................................................................ 86 List with for loop ...................................................................................... 86 List functions ................................................................................................ 87 len() .......................................................................................................... 87 max() ........................................................................................................ 87 List methods ................................................................................................. 89 Insert methods .............................................................................................. 89 append().................................................................................................... 89 insert() ...................................................................................................... 91 Deletion ......................................................................................................... 91 remove() .................................................................................................... 91 pop() ......................................................................................................... 92 count() ...................................................................................................... 93 index() ...................................................................................................... 93 Copy() ....................................................................................................... 94 Sort() ........................................................................................................ 95 reverse() .................................................................................................... 98 List comprehensions .................................................................................... 99 Exercise ........................................................................................................ 100 Conclusion .................................................................................................. 100 Questions ..................................................................................................... 101 6. Dictionary and Sets ......................................................................................... 103 Structure ...................................................................................................... 103 Objective ...................................................................................................... 103 Dictionary .................................................................................................... 104 xv Creating a dictionary ............................................................................. 104 Features of dictionary ............................................................................. 104 Operations on dictionary ....................................................................... 104 Accessing the values of dictionary .............................................................. 105 Deleting item from dictionary..................................................................... 105 Updating and adding in the dictionary ...................................................... 106 Adding item to dictionary ........................................................................... 106 Dictionary functions .............................................................................. 107 len(dict) ....................................................................................................... 107 Max(dict) .................................................................................................... 107 Dictionary methods ................................................................................ 107 copy() ........................................................................................................... 108 get() ............................................................................................................. 108 setdefault() .................................................................................................. 109 items() ..........................................................................................................110 keys() ............................................................................................................111 values() .........................................................................................................111 update() ........................................................................................................113 Exercise ...................................................................................................114 Set ..................................................................................................................115 With item ................................................................................................115 Without items ..........................................................................................115 add() ........................................................................................................116 remove() ...................................................................................................116 Conclusion ...................................................................................................117 Questions ......................................................................................................117 7. Function ..............................................................................................................119 Structure .......................................................................................................119 Objective ...................................................................................................... 120 What is function? ....................................................................................... 120 Defining a Python function ...................................................................... 120 Function with positional arguments ....................................................... 121 Function with the arguments and return value ..................................... 122 Function with default argument .............................................................. 123 xvi Function with variable-length arguments .............................................. 124 Function with keyworded arguments .................................................... 125 Argument pass by reference or value ..................................................... 126 Scope ............................................................................................................ 127 Types of scope ......................................................................................... 127 Local scope ................................................................................................... 128 Enclosing scope ........................................................................................... 128 Global scope ................................................................................................. 128 Built-in scope .............................................................................................. 128 Memory management ............................................................................... 129 Scope of variables ....................................................................................... 129 Conclusion .................................................................................................. 133 Questions ..................................................................................................... 133 8. Module ............................................................................................................... 135 Structure ...................................................................................................... 135 Objective ...................................................................................................... 136 Module ......................................................................................................... 136 The import statement ................................................................................ 136 The from statement ................................................................................ 137 Locating Python modules ......................................................................... 140 Compiled Python files ............................................................................... 142 dir() ........................................................................................................ 142 The __name__ statement ....................................................................... 143 Python package .......................................................................................... 145 Importing the modules from different path ............................................ 147 Conclusion .................................................................................................. 148 Questions ..................................................................................................... 148 9. Exception Handling ......................................................................................... 149 Structure ...................................................................................................... 149 Objective ...................................................................................................... 149 Exception ..................................................................................................... 150 Try statement with an except clause ....................................................... 150 xvii Multiple exception block........................................................................... 151 else in exception ......................................................................................... 152 finally statement ......................................................................................... 153 Program find its exception type ............................................................... 154 Raising an exception .................................................................................. 155 Advance section ......................................................................................... 157 User-defined exceptions ......................................................................... 157 Exercise .................................................................................................. 161 Conclusion .................................................................................................. 162 Questions ..................................................................................................... 162 10. File Handling .................................................................................................... 163 Structure ...................................................................................................... 163 Objective ...................................................................................................... 164 Text files ....................................................................................................... 164 Reading text from a file ............................................................................. 164 Writing text to a file ................................................................................... 167 The with statement .................................................................................... 172 Pickle ............................................................................................................ 174 Reading data from file and unpickling ................................................... 175 JSON with Python ...................................................................................... 176 Exercise ........................................................................................................ 178 Conclusion .................................................................................................. 180 Questions ..................................................................................................... 180 11. Collections ........................................................................................................ 181 Structure ...................................................................................................... 181 Objective ...................................................................................................... 182 Counter ........................................................................................................ 182 Counter methods .................................................................................... 183 update() ....................................................................................................... 183 Counter operations ................................................................................. 185 Addition ...................................................................................................... 185 Subtraction .................................................................................................. 186 xviii Union .......................................................................................................... 186 Intersection ................................................................................................. 187 Deque 187 Deque populating ................................................................................... 188 deque consuming .................................................................................... 189 deque rotating......................................................................................... 190 Namedtuple ................................................................................................ 19
دانلود کتاب Python for Developers: Learn to Develop Efficient Programs using Python (English Edition)