John Hunt
Python#
Frozensets#
Gotchas#
lterables#
Iterators#
TicTacToe#
This textbook is aimed at readers who have little or no knowledge of computer programming but want to learn to program in Python. It starts from the very basics including how to install your Python environment, how to write a very simple program and run it, what a variable is, what an if statement is, how iteration works using for and while loops as well as important key concepts such as functions, classes and modules. Each subject area is prefaced with an introductory chapter, before continuing with how these ideas work in Python.
The second edition has been completely updated for the latest versions of Python including Python 3.11 and Python 3.12. New chapters have been added such as those that consider where and how Python is used, the use of Frozensets, how data can be sorted, enumerated types in Python, structural pattern matching and how (and why) Python Virtual Environments are configured. A new chapter ‘The Python Bites back’ is introduced to present the fourteen most common / biggest gotchas for someone new to Python. Other sections have been updated with new features such as Exception Groups, string operations and dictionary operations.
A Beginners Guide to Python 3 Programming second Edition provides all you need to know about Python, with numerous examples provided throughout including several larger worked case studies illustrating the ideas presented in the previous chapters.
Table of Contents
1 Introduction
2 Where is Python Used
3 Setting up the Python Environment
4 A First Python Program
5 Python Strings
6 Numbers, Booleans and None
7 Flow of Control Using if Statements
8 Iteration/Looping
9 Number Guessing Game
10 Recursion
11 Introduction to Structured Analysis
12 Functions in Python
13 Scope and Lifetime of Variables
14 Implementing a Calculator Using Functions
15 Introduction to Functional Programming
16 Higher-Order Functions
17 Curried Functions
18 Introduction to Object Orientation
19 Python Classes
20 Class Side and Static Behaviour
21 Class Inheritance
22 Why Bother with Object Orientation?
23 Operator Overloading
24 Python Properties
25 Abstract Base Classes
26 Error and Exception Handling
27 Python Modules and Packages
28 Protocols, Polymorphism and Descriptors
29 Decorators
30 lterables and Iterators
31 Generators and Coroutines
32 Collections, Tuples and Lists
33 Sets
34 Dictionaries
35 Frozensets
36 Collection Related Modules
37 ADTs, Queues and Stacks
38 Map, Filter and Reduce
39 Sorting and Higher-Order Functions
40 Python Enumerated Values
41 Structural Pattern Matching
42 Python Virtual Environments
43 Monkey Patching
44 Attribute Lookup
45 The Python Bites Back
46 TicTacToe Game
John Hunt is a technology trainer, consultant, mentor and author who has 35 years experience within the computing industry. He has worked extensively in Object Oriented and Functional technologies using language from Java through C# to Scala and of course Python. John was first involved with Python while working with a FinTech company in 2010. Since then he has been involved in numerous Python projects and has worked with a number of companies helping to develop their Python skills.