Beginner's Guide to Python

From Mark Weiman's Wiki
Revision as of 01:22, 19 March 2021 by Markzz (talk | contribs) (→‎Table of Contents)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Welcome to my beginner's guide to programming in Python! This guide/book is intended for those who want a relatively comprehensive introduction to Python and requires no prior experience programming in any language. That stated, there will be notes scattered around to discuss differences between Python and C for those who are familiar with C (or languages like C) and even a section towards the end of how to extend Python in C. Needless to say, if you are not familiar with C, ignore these notes.

This book will be written with Python 3 in mind. This is because Python 2 is currently past its end of life and I don't feel it needs to be covered. There will be a section towards the end of what is different in case you encounter a Python 2 script or need to write one. The two are similar, but have incompatible differences.

It is recommended that you are using some form of Linux when following this book. Although everything in this book should work fine on any operating system that has Python 3 available to it, certain differences that you are expected to know may cause an unforeseen error if you copy code from here verbatim. If you are a Windows user and you have the hardware necessary for virtualization (CPUs with VT-x or AMD-Vi), it is highly recommended to install Python via Ubuntu using WSL2, or if no virtualization hardware or Windows 10 is not available, via Cygwin. You can also install Python 3 from python.org, but you'll have to make sure your environment is set up yourself.

Table of Contents

  • Chapter 1 - Introduction
    • 1.1 - Introduction
    • 1.2 - Maneuvering The Shell
    • 1.3 - Installation
    • 1.4 - The Python Interpreter
    • 1.5 - Tools
  • Chapter 2 - Getting Started
    • 2.1 - Hello World!
    • 2.2 - Data Types
    • 2.3 - Variables
    • 2.4 - Operators
    • 2.5 - print And input
    • 2.6 - Comments
    • 2.7 - Structure Of A Script
  • Chapter 3 - Flow Control
    • 3.1 - Boolean Expressions
    • 3.2 - Making Decisions With if
    • 3.3 - Loops
    • 3.4 - Functions
    • 3.5 - Lambda Expressions
    • 3.6 - Style
  • Chapter 4 - Lists, Dictionaries, Tuples, Oh My!
    • 4.1 - Data Structures 101
    • 4.2 - Lists
    • 4.3 - Dictionaries
    • 4.4 - Tuples
    • 4.5 - Sets
    • 4.6 - Helpful Commands
    • 4.7 - Iterators
    • 4.8 - Generators
  • Chapter 5 - Classes
    • 5.1 - Your First Class
    • 5.2 - More About Scope
    • 5.3 - Variables
    • 5.4 - Methods
    • 5.5 - Special Methods
    • 5.6 - Inheritance
    • 5.7 - When To Use
  • Chapter 6 - Modules
    • 6.1 - Why Bother?
    • 6.2 - Your First Module
    • 6.3 - Helpful Functions
    • 6.4 - Packaging
  • Chapter 7 - Input and Output (I/O)
    • 7.1 - Working With Files
    • 7.2 - stderr vs stdout vs stdin
    • 7.3 - Getting Fancy
  • Chapter 8 - Handling Errors
    • 8.1 - Exceptions
    • 8.2 - Handling an Exception
    • 8.3 - Raising Exceptions
    • 8.4 - Defining Your Own Exception
  • Chapter 9 - Built-in Modules
  • Chapter 10 - virtualenv
  • Chapter 11 - Extending Python In C
    • 11.1 - Forward
  • Chapter 12 - Python 2 vs Python 3
    • 12.1 - print
    • 12.2 - Strings
    • 12.3 - Scope
    • 12.4 - Other