Python Quick Start
$9.99
Minimum price
$14.99
Suggested price

Python Quick Start

A beginner's introduction to Python programming

About the Book

Python is an extremely popular language, and is an excellent choice for first time programmers, because it is simple to get started with, but extremely powerful once you get to know it. Python in the language of choice for machine learning and web development, but is can also be used for anything from system scripts to games to desktop applications. It is also embedded in many existing applications to provide a scripting mechanism, which can be used to automate many applications such as Paintshop or Blender.

This book will help you learn Python whether you are a complete beginner or you already have experience programming in other languages. It teaches all the core features of the language, step by step, with example code.

About the Author

Martin McBride
Martin McBride

Martin McBride is a software developer, specialising in computer graphics, sound, and mathematical programming. He has been writing code since the 1980s in a wide variety of languages from assembler through to C++, Java and Python. He writes for PythonInformer.com and is the author of Functional Programming in Python. He is interested in generative art and works on the generativepy open source project.

Table of Contents

  • Foreword
    • Who is this book for?
    • About the author
    • Keep in touch
  • Introduction
    • What is Python
    • History of Python
    • Zen of Python
  • 1 Getting started with Python
    • 1.1 Installing Python
      • 1.1.1 Windows
      • 1.1.2 Linux
    • 1.2 Running IDLE
    • 1.3 Simple maths in Python
    • 1.4 Variables
      • 1.4.1 Calculations with variables
      • 1.4.2 Changing the value of a variable
      • 1.4.3 Variable names
    • 1.5 Strings
      • 1.5.1 Strings in variables
    • 1.6 Console shortcuts
  • 2 Hello world
    • 2.1 Writing a program
      • 2.1.1 Running the IDLE console window
      • 2.1.2 Opening an edit window
      • 2.1.3 Typing in your code
      • 2.1.4 Type, don’t copy and paste
      • 2.1.5 Running your code
      • 2.1.6 Seeing the result
    • 2.2 In case of errors
    • 2.3 Print statements - outputting text
    • 2.4 Sequencing
    • 2.5 Input statements - getting user input
      • 2.5.1 Inputting a number
    • 2.6 Selection
      • 2.6.1 Indentation
    • 2.7 Iteration
    • 2.8 Comments
  • 3 Variables and values
    • 3.1 Creating and using variables
    • 3.2 Variables can store any type of data
    • 3.3 Naming variables
      • 3.3.1 Legal variable names
      • 3.3.2 Reserved words
      • 3.3.3 Choosing variable names
      • 3.3.4 Naming conventions
      • 3.3.5 Unicode characters
    • 3.4 Variables point to values
    • 3.5 None
    • 3.6 Multiple assignments
  • 4 Numbers and maths
    • 4.1 Types of number
      • 4.1.1 Integers
      • 4.1.2 Floating point numbers
      • 4.1.3 Finding the type
    • 4.2 Basic maths operations
      • 4.2.1 Addition
      • 4.2.2 Int and float results
      • 4.2.3 Subtraction
      • 4.2.4 Multiplication
      • 4.2.5 Division
      • 4.2.6 Power
      • 4.2.7 Floor divide
      • 4.2.8 Modulo
      • 4.2.9 Unary operators
      • 4.2.10 Augmented assignment
    • 4.3 Precedence and brackets
      • 4.3.1 Statements and expressions
    • 4.4 Built-in maths functions
      • 4.4.1 abs()
      • 4.4.2 min() and max()
      • 4.4.3 int()
      • 4.4.4 float()
    • 4.5 math module
    • 4.6 Limitations of floats
    • 4.7 More advanced topics
      • 4.7.1 Scientific notation for floats
      • 4.7.2 Complex numbers
  • 5 Strings
    • 5.1 Creating strings
    • 5.2 String type
    • 5.3 Operations on strings
      • 5.3.1 Methods
    • 5.4 Converting between strings and other data types
    • 5.5 How to use special characters in a string
      • 5.5.1 Quote characters
      • 5.5.2 Unicode characters
      • 5.5.3 Newline characters
      • 5.5.4 The escape character \
  • 6 Loops
    • 6.1 For loops
      • 6.1.1 The loop variable
    • 6.2 The range function
      • 6.2.1 Changing the start value
      • 6.2.2 Using a step value
    • 6.3 For loop example - printing a times table
    • 6.4 While loops
    • 6.5 While loop example - getting user input
    • 6.6 Nested loops
  • 7 Input and output
    • 7.1 Input prompts
    • 7.2 Inputting numbers
    • 7.3 Print
    • 7.4 Print separators
  • 8 If statements
    • 8.1 if statements
      • 8.1.1 Example if statement
    • 8.2 Comparison operators
    • 8.3 Else statement
    • 8.4 Elif statement
    • 8.5 Compound conditions
    • 8.6 Comparison operator chaining
    • 8.7 Precedence
  • 9 Lists
    • 9.1 What is a list?
      • 9.1.1 Lists vs arrays
    • 9.2 Creating lists
      • 9.2.1 Empty lists
      • 9.2.2 The list function
    • 9.3 The list type
    • 9.4 Accessing list elements
      • 9.4.1 Reading an element
      • 9.4.2 Changing an element
    • 9.5 Operations on lists
    • 9.6 Looping over a list
      • 9.6.1 Doing calculations in a loop
    • 9.7 List functions
      • 9.7.1 Finding the length of the list
      • 9.7.2 Finding the min a max values
      • 9.7.3 Adding up the values in a list
    • 9.8 List methods
      • 9.8.1 Adding elements
      • 9.8.2 Searching for elements in a list
      • 9.8.3 Removing elements
      • 9.8.4 Other methods
    • 9.9 Two-dimensional lists
      • 9.9.1 Ragged arrays
    • 9.10 Aliasing
      • 9.10.1 Reassigning variables
      • 9.10.2 Does aliasing affect numbers?
    • 9.11 Examples
      • 9.11.1 Finding every element of a given value
      • 9.11.2 Creating a 2-dimensional list of zeros
  • 10 Using functions
    • 10.1 Why use functions?
    • 10.2 Built-in functions
      • 10.2.1 repr
      • 10.2.2 chr and ord
      • 10.2.3 help and dir
    • 10.3 Importing modules
      • 10.3.1 Simple import statement
      • 10.3.2 Importing individual functions
      • 10.3.3 Aliasing a module
      • 10.3.4 Importing all functions (don’t do this)
    • 10.4 How to call functions
      • 10.4.1 Optional parameters
      • 10.4.2 Variable number of arguments
      • 10.4.3 Named optional parameters
    • 10.5 Defining your own functions
      • 10.5.1 Printing @s
      • 10.5.2 Printing more @s
      • 10.5.3 Returning a value
  • 11 More loops
    • 11.1 The break operator
      • 11.1.1 Break in a for loop
      • 11.1.2 Break in a while loop
    • 11.2 The continue operator
    • 11.3 Using else with a loop
    • 11.4 Nested loop statements
      • 11.4.1 Printing times tables
    • 11.5 Modifying a for loop
    • 11.6 Looping in reverse order
      • 11.6.1 Using range() to count backwards - ugly
      • 11.6.2 reversed()
    • 11.7 sorted()
    • 11.8 Looping over multiple items
      • 11.8.1 zip
      • 11.8.2 How zip() works
    • 11.9 More about zip()
    • 11.10 Accessing the loop count using enumerate
    • 11.11 Looping over selected items
      • 11.11.1 Using filter
      • 11.11.2 The advantage of using filter
  • 12 Programming logic
    • 12.1 Boolean types
    • 12.2 Comparison operators and their opposites
    • 12.3 Boolean operations and De Morgan’s Laws
    • 12.4 Ternary operators
    • 12.5 Comparing containers
      • 12.5.1 Strings
      • 12.5.2 Lists
      • 12.5.3 Other containers
    • 12.6 Membership testing
    • 12.7 Identity testing
    • 12.8 Truthy values
      • 12.8.1 Numbers
      • 12.8.2 Strings
      • 12.8.3 Lists
      • 12.8.4 Other collections
      • 12.8.5 None
      • 12.8.6 Other objects
    • 12.9 Short circuit evaluation
      • 12.9.1 Short-circuiting with the or operator
      • 12.9.2 Short-circuiting with the and operator
      • 12.9.3 Short-circuiting to avoid errors
      • 12.9.4 The value of an or/and expression
      • 12.9.5 Getting a true or false value
  • 13 Slices
    • 13.1 Slicing a list
    • 13.2 Using negative indices
    • 13.3 Delete or replace a slice of a list
    • 13.4 Slicing tuples and strings
    • 13.5 Loop over a slice
    • 13.6 Using steps
  • 14 More strings
    • 14.1 Raw strings
    • 14.2 Multi-line strings
    • 14.3 Looping over a string
    • 14.4 Joining strings
    • 14.5 Splitting a string
    • 14.6 Formatting strings
    • 14.7 The in operator
    • 14.8 Other string methods
      • 14.8.1 Changing case
      • 14.8.2 Dealing with whitespace
      • 14.8.3 Padding
      • 14.8.4 Search
      • 14.8.5 Splitting strings
      • 14.8.6 Categorising strings
  • 15 Tuples
    • 15.1 What is a tuple?
    • 15.2 Creating a tuple
    • 15.3 Accessing elements
    • 15.4 Packing and unpacking tuples
      • 15.4.1 Packing a tuple
      • 15.4.2 Unpacking a tuple
      • 15.4.3 Real-life examples
    • 15.5 Tuple vs list operations
      • 15.5.1 Tuple slices
      • 15.5.2 Adding elements to a tuple
      • 15.5.3 Finding elements
      • 15.5.4 Removing elements
      • 15.5.5 Looping
      • 15.5.6 In case of emergency
    • 15.6 Pros and cons of immutability
  • 16 Exceptions
    • 16.1 Program errors
    • 16.2 What are exceptions
    • 16.3 Exception types
      • 16.3.1 ImportError
      • 16.3.2 IndexError
      • 16.3.3 TypeError
      • 16.3.4 ValueError
      • 16.3.5 ZeroDivisionError
    • 16.4 Catching exceptions
      • 16.4.1 Only catch exceptions you can handle
      • 16.4.2 Accessing the exception message
    • 16.5 Using else with exceptions
    • 16.6 Using finally with exceptions
    • 16.7 Throwing exceptions
  • 17 Working with files
    • 17.1 Using files
      • 17.1.1 Opening the file
      • 17.1.2 Reading and writing data
      • 17.1.3 Closing the file
    • 17.2 Reading data
      • 17.2.1 Code for reading a file
      • 17.2.2 Reading lines from a file
      • 17.2.3 Looping over the lines in a file
    • 17.3 Writing data
      • 17.3.1 Code to write a file
      • 17.3.2 The write function
    • 17.4 Using with statements
    • 17.5 CSV data
      • 17.5.1 Reading CSV data
      • 17.5.2 Trying the code
      • 17.5.3 Formatting the output
      • 17.5.4 Writing CSV data
      • 17.5.5 Understanding the code
      • 17.5.6 Trying the code
  • 18 More books from this author
    • 18.1 Numpy Recipes
    • 18.2 Computer Graphics in Python with Pycairo
    • 18.3 Functional Programming in Python

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub