A Grip of Python

Shiv Dayal

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.


Dedication

Dedicated to my family and free software community

Table of Contents

Preface
I. Python Programming
1. Introduction to Python
1.1. Pros and Cons of Python
1.2. Who uses Python?
1.3. Prerequisite
1.4. Tools of the Trade
1.5. Zen of Python
1.6. How to Write and Run Programs in Python
1.7. Invoking REPL of Python
2. Basics
2.1. Character Set
2.2. Keywords
2.3. What is a Program?
2.4. Lexical Analysis
2.5. Line Structure
2.6. Identifiers or Names
2.7. Literals
2.8. Operators
2.9. Delimiters
2.10. Booleans
2.11. Summary
3. Operators and Expressions
3.1. Arithmetic Conversions
3.2. Atoms
3.3. Primaries
3.4. Binary Arithmetic Operators
3.5. Unary Arithmetic and Bitwise Operations
3.6. The Power Operator
3.7. Shift Operators
3.8. Binary Bitwise Operators
3.9. Comparisons
3.10. Boolean Operators
3.11. Assignment Expressions
3.12. Conditional Expressions
3.13. Lambdas
3.14. Expression Lists
3.15. Evaluation Order
3.16. Operator Precedence
4. Control Flow Statements
4.1. Expression Statements
4.2. Assignment Statements
4.3. The assert Statement
4.4. The pass Statement
4.5. The del Statement
4.6. The return Statement
4.7. The yield Statement
4.8. The raise Statement
4.9. The break Statement
4.10. The continue Statement
4.11. The import Statement
4.12. The global Statement
4.13. The nonlocal Statement
4.14. Compound Statements
4.15. The if Statement
4.16. The while Statement
4.17. The for Statement
4.18. The try Statement
4.19. The with Statement
4.20. The match Statement
5. Strings and Keyboard IO
5.1. What is a string?
5.2. Operations on Strings
Index
A. GNU Free Documentation License

© 2022 Shiv S. Dayal. www.ashtavakra.org. GNU FDL license v1.3 or later is applicable where not stated.