Explore the world of programming languages through Python and learn the building blocks of writing programs. This book covers Python 3.10, explaining it through six key concepts. Each chapter contains a real-world example with practical advice and a section on advanced concepts. You'll start by reviewing the concept of expressions and functions, which are two of the core building blocks of programming languages. You'll then move on to object-oriented concepts to help gain a practical understanding of Python, along with a chapter on control flow constructs. The book also takes a close look at sequences, explaining constructs and additional types, and wraps up with a chapter on modules, focusing on how to use and create packages. Whether you’re new to programming or already an experienced developer, upon finishing this book, you will have a solid understanding of Python's state-of-the-art development features. What You Will Learn Study the six main concepts of the programming languages Learn how to use programming language constructs through examples Review the core Python language notations and concepts. Start using Python as a working language Who This Book Is For Software developers wanting to gain professional core Python knowledge quickly, and non-developers wanting to gain an understanding of programming concepts. Table of Contents 5 About the Author 10 About the Technical Reviewer 11 Acknowledgments 12 Introduction 13 Chapter 1: Expression: How to Compute 20 Expressions with Additional Types 22 Boolean Type in an Expression 23 String Type in an Expression 23 Expressions with Conditional Operators 24 Floating-Point Number Type in an Expression 25 Complex Number Type in an Expression 26 Variable Names 27 Statements 29 Deletion of a Variable Name 31 Additional Language Constructs 32 Statements and Expressions in Practice 33 Advanced Details 35 Names 35 Keywords and Special Names 35 Literals 36 Characters with Special Meaning 40 Python Standards 42 Object Diagram Notation 42 Key Takeaways 42 Chapter 2: The Function: Programs as a Series of Statements 44 Calling a Function 45 Side Effects of Functions 46 Function Arguments 48 Defining a Function 49 Keyword Arguments 51 Visibility of Names 52 Functions as Parameters 54 Definitions of Nested Functions 55 Functions in Practice 56 Advanced Details 59 Namespace and Scope 60 Positional-Only and Keyword-Only Parameters 60 Variable Number of Arguments 61 Lambda Expression 62 Decorator 62 Yield Statement and Asynchronous Functions 64 Key Takeaways 64 Chapter 3: The Class: How to Model the World 66 What Is a Class? 68 Creating Objects 69 Using Instance Variables and Methods 69 Defining Classes 70 Relationships Among Classes 74 Properties 77 Inheritance 80 Nested Classes 83 Special Methods 84 Classes in Practice 87 Advanced Details 89 Class Variables, Class Methods, and Static Methods 89 Abstract Base Classes 91 Immutable Objects and Data Classes 92 Methods of Identifying Classes 95 Class Diagrams 96 Key Takeaways 97 Chapter 4: The Control Structure: How to Describe the Workflow 99 if Statement 100 match Statement 104 while Statement 108 for Statement 115 Exception Handling 118 Context Management 122 Recursion 123 Loops in Practice 124 Advanced Details 126 Matching Classes and Other Kinds of Patterns 126 Exception Classes 129 Context Manager Classes 130 Evaluating Strings 131 Activity Diagram 131 Key Takeaways 132 Chapter 5: The Sequence: From Data to the Data Structure 133 Lists and Their Operations 134 Processing of a List 141 Tuples 145 Dictionaries 147 Sets 150 Copying Sequences 152 Sequences in Practice 154 Advanced Details 155 Iterable Objects 155 Deep Copy of Data Structures 156 Generator Functions and Coroutines 157 Functional-Style Manipulation of Lists 161 Multiplicity of Class Diagram Connections 161 Sequence Diagram 162 Key Takeaways 163 Chapter 6: The Module: Organization of Program Parts into a Unit 164 Built-in Modules 165 Defining Modules 169 Packages 170 Future Package 171 Package Management 172 Useful Third-Party Packages 173 Modules in Practice 176 Advanced Concepts 177 Structure of Python Projects 177 Virtual Environments 180 Tools for Testing 180 Tools for Static Analysis 182 Tools for Formatting 183 Preparation of Documentation 183 Key Takeaways 186 Appendix A: Binary Representation 187 Appendix B: Type Annotations 192 Appendix C: Asynchronous Programming 196 Bibliography 204 Index 207