A Byte of Python | Swaroop C. H.
A Byte of Python
first Edition

A Byte of Python

by Swaroop C. H.

"A Byte of Python" is a free book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save text files, then this is the book for you. This book will teach you to use Python version 3. There will also be guidance for you to adapt to the older and more common Python version 2 in the book.

The original text can be viewed at https://python.swaroopch.com/ ​

A Byte of Python
Dedication
Preface
1. About Python
1.1. Story behind the name
1.2. Features of Python
1.3. Python 3 versus 2
1.4. What Programmers Say
2. Installation
2.1. Installation on Windows
2.2. Installation on Mac OS X
2.3. Installation on GNU/Linux
2.4. Summary
3. First Steps
3.1. Using The Interpreter Prompt
3.2. Choosing An Editor
3.3. PyCharm
3.4. Vim
3.5. Emacs
3.6. Using A Source File
3.7. Getting Help
3.8. Summary
4. Basics
4.1. Comments
4.2. Literal Constants
4.3. Numbers
4.4. Strings
4.5. Variable
4.6. Identifier Naming
4.7. Data Types
4.8. Object
4.9. How to write Python programs
4.10. Logical and Physical Line
4.11. Indentation
4.12. Summary
5. Operators and Expressions
5.1. Operators
5.2. Shortcut for math operation and assignment
5.3. Evaluation Order
5.4. Changing the Order Of Evaluation
5.5. Associativity
5.6. Expressions
5.7. Summary
6. Control Flow
6.1. The if Statement
6.2. The while Statement
6.3. The for loop
6.4. The break Statement
6.5. The continue Statement
6.6. Summary
7. Functions
7.1. Function Parameters
7.2. Local Variables
7.3. The global statement
7.4. Default Argument Values
7.5. Keyword Arguments
7.6. VarArgs parameters
7.7. The return Statement
7.8. DocStrings
7.9. Summary
8. Modules
8.1. Byte-compiled .pyc files
8.2. The from..import statement
8.3. A module's __name__
8.4. Making Your Own Modules
8.5. The dir function
8.6. Packages
8.7. Summary
9. Data Structures
9.1. List
9.2. Quick Introduction To Objects And Classes
9.3. Tuple
9.4. Dictionary
9.5. Sequence
9.6. Set
9.7. References
9.8. More About Strings
9.9. Summary
10. Problem Solving
10.1. The Problem
10.2. The Solution
10.3. Second Version
10.4. Third Version
10.5. Fourth Version
10.6. More Refinements
10.7. The Software Development Process
10.8. Summary
11. Object Oriented Programming
11.1. The self
11.2. Classes
11.3. Methods
11.4. The __init__ method
11.5. Class and Object Variables
11.6. Inheritance
11.7. Summary
12. Input and Output
12.1. Input from user
12.2. Files
12.3. Pickle
12.4. Unicode
12.5. Summary
13. Exceptions
13.1. Errors
13.2. Exceptions
13.3. Handling Exceptions
13.4. Raising Exceptions
13.5. Try ... Finally
13.6. The with Statement
13.7. Summary
14. Standard Library
14.1. Sys module
14.2. Logging module
14.3. Module of the Week Series
14.4. Summary
15. More
15.1. Passing tuples around
15.2. Special Methods
15.3. Single Statement Blocks
15.4. Lambda Forms
15.5. List Comprehension
15.6. Receiving Tuples and Dictionaries in Functions
15.7. The assert Statement
15.8. Decorators
15.9. Differences between Python 2 and Python 3
15.10. Summary
16. What Next
16.1. Next Projects
16.2. Example Code
16.3. Advice
16.4. Videos
16.5. Questions and Answers
16.6. Tutorials
16.7. Discussion
16.8. News
16.9. Installing libraries
16.10. Creating a Website
16.11. Graphical Software
16.12. Various Implementations
16.13. Functional Programming (for advanced readers)
16.14. Summary
17. Appendix: FLOSS
18. Appendix: Colophon
18.1. Birth of the Book
18.2. Teenage Years
18.3. Now
18.4. About the Author
19. Appendix: History Lesson
19.1. Status Of The Book
19.2. Revision History
20. Appendix: Translations
21. Appendix: Translation How-to
22. Feedback

This book is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

All the code/scripts provided in this book is licensed under the 3-clause BSD License unless otherwise noted.

Printed version

A printed hard copy of the book can be purchased at https://www.swaroopch.com/buybook/ for your offline reading pleasure, and to support the continued development and improvement of this book.

The author(s) of this volume are not affiliated in any manner with LiveCarta.com.