Python Quick Start ebook

By Martin McBride, 2021-02-04
Tags: python beginner
Categories: book python


Buy now from Leanpub or Amazon.

Download a free preview.

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.

Contents:

  • 1 Getting started with Python
  • 1.1 Installing Python
  • 1.2 Running IDLE
  • 1.3 Simple maths in Python
  • 1.4 Variables
  • 1.5 Strings
  • 1.6 Console shortcuts
  • 2 Hello world
  • 2.1 Writing a program
  • 2.2 In case of errors
  • 2.3 Print statements - outputting text
  • 2.4 Sequencing
  • 2.5 Input statements - getting user input
  • 2.6 Selection
  • 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.4 Variables point to values
  • 3.5 None
  • 3.6 Multiple assignments
  • 4 Numbers and maths
  • 4.1 Types of number
  • 4.2 Basic maths operations
  • 4.3 Precedence and brackets
  • 4.4 Built-in maths functions
  • 4.5 math module
  • 4.6 Limitations of floats
  • 4.7 More advanced topics
  • 5 Strings
  • 5.1 Creating strings
  • 5.2 String type
  • 5.3 Operations on strings
  • 5.4 Converting between strings and other data types
  • 5.5 How to use special characters in a string
  • 6 Loops
  • 6.1 For loops
  • 6.2 The range function
  • 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.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.2 Creating lists
  • 9.3 The list type
  • 9.4 Accessing list elements
  • 9.5 Operations on lists
  • 9.6 Looping over a list
  • 9.7 List functions
  • 9.8 List methods
  • 9.9 Two-dimensional lists
  • 9.10 Aliasing
  • 9.11 Examples
  • 10 Using functions
  • 10.1 Why use functions?
  • 10.2 Built-in functions
  • 10.3 Importing modules
  • 10.4 How to call functions
  • 10.5 Defining your own functions
  • 11 More loops
  • 11.1 The break operator
  • 11.2 The continue operator
  • 11.3 Using else with a loop
  • 11.4 Nested loop statements
  • 11.5 Modifying a for loop
  • 11.6 Looping in reverse order
  • 11.7 sorted()
  • 11.8 Looping over multiple items
  • 11.9 More about zip()
  • 11.10 Accessing the loop count using enumerate
  • 11.11 Looping over selected items
  • 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.6 Membership testing
  • 12.7 Identity testing
  • 12.8 Truthy values
  • 12.9 Short circuit evaluation
  • 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
  • 15 Tuples
  • 15.1 What is a tuple?
  • 15.2 Creating a tuple
  • 15.3 Accessing elements
  • 15.4 Packing and unpacking tuples
  • 15.5 Tuple vs list operations
  • 15.6 Pros and cons of immutability
  • 16 Exceptions
  • 16.1 Program errors
  • 16.2 What are exceptions
  • 16.3 Exception types
  • 16.4 Catching exceptions
  • 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.2 Reading data
  • 17.3 Writing data
  • 17.4 Using with statements
  • 17.5 CSV data

More information:

If you have any comments or questions you can get in touch by any of the following methods:

  • The book page on the Leanpub website.
  • Signing up for the Python Informer newsletter at pythoninformer.com
  • Following @pythoninformer on twitter.
  • Contacting me directly by email (info@axlesoft.com).

Buy now from Leanpub, or download a free preview.

If you found this article useful, you might be interested in the book NumPy Recipes or other books by the same author.

Join the PythonInformer Newsletter

Sign up using this form to receive an email when new content is added:

Popular tags

2d arrays abstract data type alignment and angle animation arc array arrays bar chart bar style behavioural pattern bezier curve built-in function callable object chain circle classes clipping close closure cmyk colour combinations comparison operator comprehension context context manager conversion count creational pattern data science data types decorator design pattern device space dictionary drawing duck typing efficiency ellipse else encryption enumerate fill filter font font style for loop formula function function composition function plot functools game development generativepy tutorial generator geometry gif global variable gradient greyscale higher order function hsl html image image processing imagesurface immutable object in operator index inner function input installing iter iterable iterator itertools join l system lambda function latex len lerp line line plot line style linear gradient linspace list list comprehension logical operator lru_cache magic method mandelbrot mandelbrot set map marker style matplotlib monad mutability named parameter numeric python numpy object open operator optimisation optional parameter or pandas partial application path pattern permutations pie chart pil pillow polygon pong positional parameter print product programming paradigms programming techniques pure function python standard library radial gradient range recipes rectangle recursion reduce regular polygon repeat rgb rotation roundrect scaling scatter plot scipy sector segment sequence setup shape singleton slice slicing sound spirograph sprite square str stream string stroke structural pattern subpath symmetric encryption template tex text text metrics tinkerbell fractal transform translation transparency triangle truthy value tuple turtle unpacking user space vectorisation webserver website while loop zip zip_longest