Python Books

9780470555156.pdfDierbach, Charles (2013)An Introduction to Computer Science Using Python – A Computational Problem-Solving Focus to Computer Science” John Wiley and Sons, Inc

Sample Code from Book (ZIP 812KB)

Student Companion Site with Errata
(http://bcs.wiley.com/he-bcs/Books?action=index&bcsId=9046&itemId=0470555157)

With a focus on computational problem solving from Chapter 1, this text provides numerous hands-on exercises and examples, each chapter ending with a significant-size program demonstrating the step-by-step process of program development, testing, and debugging. A final chapter includes the history of computing, starting with Charles Babbage, containing over 65 historical images. An end-of-book Python 3 Programmers’ Reference is also included for quick lookup of Python details.

Table of Contents

1 Introduction 

1.1 What Is Computer Science?
1.2 Computer Algorithms
1.3 Computer Hardware
1.4 Computer Software
1.5 The Process of Computational Problem Solving
1.6 The Python Programming Language
1.7 A First Program—Calculating the Drake Equation

2 Data and Expressions 

2.1 Literals
2.2 Variables and Identifier
2.3 Operators
2.4 Expressions and Data Types
2.5 Age in Seconds Program

3 Control Structures 

3.1 What Is a Control Structure?
3.2 Boolean Expressions (Conditions)
3.3 Selection Control
3.5 Calendar Month Program

4 Lists 

4.1 List Structures
4.2 Lists (Sequences) in Python
4.3 Iterating Over Lists (Sequences) in Python
4.4 More on Python Lists
4.5 Calendar Year Program

5 Functions 

5.1 Program Routines
5.2 More on Functions
5.3 Credit Card Calculation Program

6 Objects and Their Use

6.1 Software Objects
6.2 Turtle Graphics
6.3 Horse Race Simulation Program

7 Modular Design

7.1 Modules
7.2 Top-Down Design
7.3 Python Modules
7.3.1 What Is a Python Module?
7.4 Calendar Year Program (function version)

8 Text Files 

8.1 What Is a Text File?
8.2 Using Text Files
8.3 String Processing
8.4 Exception Handling
8.5 Cigarette Use/Lung Cancer Correlation Program

9 Dictionaries and Sets 

9.1 Dictionary Type in Python
9.2 Set Data Type
9.3 A Food Co-op’s Worker Scheduling Simulation

10 Object-Oriented Programming 

10.1 What Is Object-Oriented Programming?
10.2 Encapsulation
10.3 Inheritance
10.4 Polymorphism
10.5 Object-Oriented Design Using UML
10.6 Vehicle Rental Agency Program

11 Recursion

11.1 Recursive Functions
11.2 Recursive Problem Solving
11.3 Iteration vs. Recursion
11.4 Towers of Hanoi

12 Computing and Its Developments 

CONTRIBUTIONS TO THE MODERN COMPUTER

12.1 The Concept of a Programmable Computer
12.2 Developments Leading to Electronic Computing

FIRST-GENERATION COMPUTERS (1940s–mid-1950s)

12.3 The Early Groundbreakers
12.4 The First Commercially Available Computers

SECOND-GENERATION COMPUTERS (mid-1950s to mid-1960s)

12.5 Transistorized Computers
12.6 The Development of High-Level Programming Languages

THIRD-GENERATION COMPUTERS (mid-1960s to early 1970s)

12.7 The Development of the Integrated Circuit (1958)
12.8 Mainframes, Minicomputers, and Supercomputers

FOURTH-GENERATION COMPUTERS (early 1970s to the Present)

12.9 The Rise of the Microprocessor
12.10 The Dawn of Personal Computing

THE DEVELOPMENT OF COMPUTER NETWORKS

12.11 The Development of Wide Area Networks
12.12 The Development of Local Area Networks (LANs)
12.13 The Development of the Internet and World Wide Web

  • Each chapter covers general programming concepts before introducing specific Python syntax.
  • Each section is followed by pedagogical elements to reinforce understanding.
  • Extensive examples, programming assignments, and end of chapter capstone assignments provide plenty of practice for problem solving.
  • Every chapter contains thorough coverage of testing, debugging, and program modification.
  • Exercises progress in complexity within every chapter, easing students from conceptual understanding to writing small chunks of code to writing complex programs.
  • A chapter containing an illustrated history of the CS discipline puts programming concepts into context.
  • Python 3 Programmers’ Reference found in the back of the book serves as a quick lookup reference for programming in Python.

catDowney, Allen, B. (2015) How to Think Like a Computer Scientist – Think Python, Second Edition, O’Reilly

Read Think Python 2e in HTML

Download here (PDF 876KB) – Second Edition using Python 3
Download here (PDF 12, 458KB) – First Edition using Python 2

Download Code Files (ZIP  1,949KB) – Second Edition
Download Code Files (ZIP 1,001KB) – First Edition

Think Python is an introduction to Python programming for beginners. It starts with basic concepts of programming, and is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression. Larger pieces, like recursion and object-oriented programming are divided into a sequence of smaller steps and introduced over the course of several chapters.

What’s new in the second edition?

  • We’ve upgraded to Python 3: All examples in the book are now Python 3, and the supporting code has been updated to run in both Python 2 and 3.
  • We’ve removed the roadblocks: Based on reader feedback, we know where people had problems, so we’ve fixed or removed the pain points.
  • Python in the browser: For beginners, one of the challenges of getting started is installing Python. For readers who don’t want to install Python right away, we provide instructions for running Python in a browser using PythonAnywhere, a free online programming environment.
  • More Python goodies: We’ve added a chapter to cover some powerful Python features that didn’t make it into the first edition, including list comprehensions and additional data structures.

Think Python 2e is a Free Book. It is available under the Creative Commons Attribution-NonCommercial 3.0 Unported License, which means that you are free to copy, distribute, and modify it, as long as you attribute the work and don’t use it for commercial purposes.

Contents


Fund_PythonLambert, Kenneth, A. (2010) Fundamentals of Python: From First Programs Through Data Structures, Course Technology, Cengage Learning

NOTE: Fundamentals of Python: First Programs (2012) using Python 3 is available for loan from the LRC.

In FUNDAMENTALS OF PYTHON: FROM FIRST PROGRAMS THROUGH DATA STRUCTURES, Washington and Lee University professor Kenneth A. Lambert presents all of the important topics in CS1 and CS2 in one volume. This economical format provides instructors with a consistent approach to teaching introductory programming and data structures over a standard two-term course sequence. The book uses the Python programming language, which is both easy to learn for beginners and scales well to advanced applications.

  • Uses a just-in-time approach, with no new concept introduced before it is needed to solve a problem.
  • Early emphasis on problem solving and algorithm development.
  • Covers multiple design strategies, including top-down design and recursive design with functions, object-based programming, and object-oriented design.
  • Engages students’ interest with modern applications such as graphics, graphical user interfaces (GUIs), networks, and image processing.
  • Walks students through the development of complete programs in numerous case studies.
  • Covers basic software development tools for design, testing, and documentation.
  • Provides exercises at the end of each section to reinforce students’ understanding of each concept.
  • Includes sets of programming projects to give students practice in problem solving.

Table of Contents

1. Introduction.
2. Data Types and Expressions.
3. Control Statements.
4. Strings and Text Files.
5. Lists and Dictionaries.
6. Design With Functions.
7. Simple Graphics and Image Processing.
8. Design with Classes.
9. Graphical User Interfaces.
10. Multithreading, Networks, and Client/Server Programming.
11. Searching, Sorting, and Complexity.
12. Tools for Design, Documentation, and Testing.
13. Collections, Arrays, and Linked Structures.
14. Stacks.
15. Queues.
16. Linked Lists.
17. Recursion.
18. Hierarchical Collections: Trees.
19. Unordered Collections: Sets and Dictionaries.
20. Graphs.
Appendices.
Glossary.


Sande, W. and Sande, C. (2009) Hello World! Computer Programming for Kids and Other Beginners, Manning Publications

There is a newer version of this book (2013).

Download eBook PDF (PDF 16,4553KB)

Download source code (ZIP 6,095KB)

“Computer programming is a powerful tool for children to ‘learn learning,’ that is, to learn the skills of thinking and problem-solving…Children who engage in programming transfer that kind of learning to other things.”–Nicholas Negroponte, the man behind the One Laptop Per Child project that hopes to put a computer in the hands of every child on earth, January 2008.
Your computer won’t respond when you yell at it. Why not learn to talk to your computer in its own language? Whether you want to write games, start a business, or you’re just curious, learning to program is a great place to start. Plus, programming is fun!
Hello World! provides a gentle but thorough introduction to the world of computer programming. It’s written in language a 12-year-old can follow, but anyone who wants to learn how to program a computer can use it. Even adults. Written by Warren Sande and his son, Carter, and reviewed by professional educators, this book is kid-tested and parent-approved.
You don’t need to know anything about programming to use the book. But you should know the basics of using a computer–e-mail, surfing the web, listening to music, and so forth. If you can start a program and save a file, you should have no trouble using this book.

1. Getting Started

Installing Python

Starting Python with IDLE

Instructions, please

Interacting with Python

Time to program

Running your first program

If something goes wrong

Your second program

2. Remember This — Memory and Variables

Input, processing, output

Names

What’s in a name?

Numbers and strings

How “variable” are they?

The new me

3. Basic Math

The four basic operations

Operators

Order of operations

Two more operators

Really big and really small

4. Types of Data

Changing types

Getting more information: type()

Type-conversion errors

Using type conversions

5. Input

raw_input()

The print command and the comma

Inputting numbers

Input from the Web

6. GUIs — Graphical User Interfaces

What’s a GUI?

Our first GUI

GUI input

Pick your flavor

The number-guessing game… again

Other GUI pieces 60

7. Decisions, Decisions

Testing, testing

Indenting

Am I seeing double?

Other kinds of tests

What happens if the test is false?

Testing for more than one condition

Using “and”

Using “or”

Using “not”

8. Loop the Loop

Counting loops

Using a counting loop

A shortcut — range()

A matter of style — loop variable names

Counting by steps

Counting without numbers

While we’re on the subject…

Bailing out of a loop — break and continue

9. Just for You — Comments

Adding comments

Single-line comments

End-of-line comments

Multiline comments

Commenting style

Commenting out

10. Game Time

Skier

11. Nested and Variable Loops

Nested loops

Variable loops

Variable nested loops

Even more variable nested loops

Using nested loops

12. Collecting Things Together — Lists

What’s a list?

Creating a list

Adding things to a list

What’s the dot?

Lists can hold anything

Getting items from a list

“Slicing” a list

Modifying items

Other ways of adding to a list

Deleting from a list

Searching a list

Looping through a list

Sorting lists

Mutable and immutable

Lists of lists: tables of data

13. Functions

Functions — the building blocks

Calling a function

Passing arguments to a function

Functions with more than one argument

Functions that return a value

Variable scope

Forcing a global

A bit of advice on naming variables

14. Objects

Objects in the real world

Objects in Python

Object = attributes + methods

What’s the dot?

Creating objects

An example class — HotDog

Hiding the data

Polymorphism and inheritance

Thinking ahead

15. Modules

What’s a module?

Why use modules?

Buckets of blocks

How do we create modules?

How do we use modules?

Namespaces

Standard modules

16. Graphics

Getting some help — Pygame

A Pygame window

Drawing in the window

Individual pixels

Images

Let’s get moving!

Animation

Smoother animation

Bouncing the ball

Wrapping the ball

17. Sprites and Collision Detection

Sprites

Bump! Collision detection

Counting time

18. A New Kind of Input — Events

Events

Keyboard events

Mouse events

Timer events

Time for another game — PyPong

19. Sound

More help from Pygame — mixer

Making sounds versus playing sounds

Playing sounds

Controlling volume

Repeating music

Adding sounds to PyPong

More wacky sounds

Adding music to PyPong

20. More GUIs

Working with PythonCard

Components

Making our GUI do something

The return of event handlers

Moving the button

More useful GUIs

TempGUI

What’s on the menu?

21. Print Formatting and Strings

New lines

Horizontal spacing — tabs

Inserting variables in strings

Number formatting

Strings ‘n’ things

22. File Input and Output

What’s a file?

Filenames

File locations

Opening a file

Reading a file

Text files and binary files

Writing to a file

Saving your stuff in files: pickle

Game time again — Hangman

23. Take a Chance — Randomness

What’s randomness?

Rolling the dice

Creating a deck of cards

Crazy Eights

24. Computer Simulations

Modeling the real world

Lunar Lander

Keeping time

Time objects

Saving time to a file

Virtual Pet

25. What’s Next?

General programming

Python

Game programming and Pygame

Other Python stuff

Look around

Appendix: Variable Naming Rules

Answers to Self-Test Questions

Though the concepts and ideas presented apply to any programming language, Hello World! uses the easy to learn Python programming language. Python is free, and is available for different platforms, including Windows, Linux, and Mac. Hello World! covers all the basic concepts of computer programming, including memory, looping, decisions, input and output, data structures, graphics, and many more. It then applies them to fun, interesting topics like computer graphics, game programming, and simulations.

  • Makes programming fun and easy to learn
  • Explains concepts in clear language—no “geek speak”
  • Lots of pictures, cartoons, and fun examples to hold your interest
  • Complete set of fully-worked questions and examples make it great for use by yourself or in a classroom

Shaw, Z. A. (2013) Learn Python the Hard Way: A Very Simple Introduction to the Terrifyingly Beautiful World of Computers and Code (Zed Shaw’s Hard Way), Third Edition, Addison Wesley

Download Learn Python the Hard Way, 3rd Edition (PDF 4,038KB)

Zed Shaw has perfected the world’s best system for learning Python. Follow it and you will succeed-just like the hundreds of thousands of beginners Zed has taught to date! You bring the discipline, commitment, and persistence; the author supplies everything else.

In Learn Python the Hard Way, Third Edition, you’ll learn Python by working through 52 brilliantly crafted exercises. Read them. Type their code precisely. (No copying and pasting!) Fix your mistakes. Watch the programs run. As you do, you’ll learn how software works; what good programs look like; how to read, write, and think about code; and how to find and fix your mistakes using tricks professional programmers use. Most importantly, you’ll learn the following, which you need to start writing excellent Python software of your own:

  • Installing a complete Python environment
  • Organizing and writing code
  • Basic mathematics
  • Variables
  • Strings and text
  • Interacting with users
  • Working with files
  • Looping and logic
  • Data structures using lists and dictionaries
  • Program design
  • Object-oriented programming
  • Inheritance and composition
  • Modules, classes, and objects
  • Python packaging
  • Debugging
  • Automated testing
  • Basic game development
  • Basic web development

It’ll be hard at first. But soon, you’ll just get it-and that will feel great!
This tutorial will reward you for every minute you put into it. Soon, you’ll know one of the world’s most powerful, popular programming languages. You’ll be a Python programmer.
Watch Zed, too! The accompanying DVD contains 5+ hours of passionate, powerful teaching: a complete Python video course!


Learn Python the Hard Way – Online Tutorial
(http://learnpythonthehardway.org/book/)

Welcome to the 3rd Edition of Learn Python the Hard Way. You can visit the companion site to the book at http://learnpythonthehardway.org/ where you can purchase digital downloads and paper versions of the book.

Download Learn Python the Hard Way, 3rd Edition (PDF 4,038KB)
Download Source Code (ZIP 19KB)

Table Of Contents


McGrath, M. (2013) Python in Easy Steps, In Easy Steps

Download Source Code (ZIP  9,239KB)

This essential In Easy Steps guide instructs you how to program in the powerful Python language, giving complete examples that illustrate each aspect with colourized source code. In the step-by-step trusted formula, you’ll be a Python guru in no time!
Python in easy steps begins by explaining how to install the free Python interpreter so you can quickly begin to create your own executable programs by copying the book’s examples. It demonstrates all the Python language basics before moving on to provide examples of Object Oriented Programming (OOP) and CGI scripting to handle web form data. This book concludes by demonstrating how you can use your acquired knowledge to create and deploy graphical windowed applications.
Python in easy steps makes no assumption you have previous knowledge of any programming language so it’s ideal for the newcomer to computer programming. It has an easy-to-follow style that will appeal to programmers moving from another programming language, to the student who is studying Python programming at school or college, and to those seeking a career in computing who need a fundamental understanding of computer programming.
Python is the language used to program the Raspberry Pi – covered by Raspberry Pi in easy steps.
The Python 3.x language is under active development so frequent new releases are made available as small improvements are added to the language and Python in easy steps features the very latest versions of Python at the time of publication. Python development is one of evolution, rather than revolution, so the examples provided in this book can be used in subsequent releases. Simply download the latest version of Python then follow the easy steps.