Python: Visual QuickStart Guide, Second Edition

Book description

Python is a remarkably powerful dynamic programming language that is used in a wide variety of application domains such as Web, database access, desktop GUIs, game and software development, and network programming. Fans of Python use the phrase "batteries included" to describe the standard library, which covers everything from asynchronous processing to zip files. The language itself is a flexible powerhouse that can handle practically any application domain. This task-based tutorial is for students with no programming experience as well as those programmers who have some experience with the programming language and now want to take their skills to the next level. The book walks a reader through all the fundamentals and then moves on to more advanced topics. It's a complete end-to-end tutorial and reference.

Table of contents

  1. Copyright
  2. Acknowledgments
  3. 1. Introduction to Programming
    1. The Python Language
    2. What Is Python Useful For?
    3. How Programmers Work
      1. The programming process
    4. Installing Python
      1. Installing Python on the Mac
      2. Installing Python on Linux
  4. 2. Arithmetic, Strings, and Variables
    1. The Interactive Command Shell
      1. The shell prompt
      2. Transcripts
    2. Integer Arithmetic
      1. Integer division
      2. Order of evaluation
      3. Unlimited size
    3. Floating Point Arithmetic
      1. Float literals
      2. Overflow
      3. Limited precision
      4. Complex numbers
    4. Other Math Functions
      1. Using return values
      2. Importing a module
    5. Strings
      1. Indicating a string
      2. String length
    6. String Concatenation
    7. Getting Help
      1. Listing functions in a module
      2. Printing documentation strings
    8. Converting Between Types
      1. Converting integers and strings to floats
      2. Converting integers and floats to strings
      3. Converting a float to an integer
      4. Converting strings to numbers
    9. Variables and Values
      1. Rules for making variable names
    10. Assignment Statements
    11. How Variables Refer to Values
      1. Assignments don’t copy
      2. Numbers and strings are immutable
    12. Multiple Assignment
      1. Swapping variable values
  5. 3. Writing Programs
    1. Using IDLE’s Editor
      1. Running programs from the command line
    2. Compiling Source Code
      1. Object code
    3. Reading Strings from the Keyboard
      1. Tracing the program
      2. Reading numbers from the keyboard
    4. Printing Strings on the Screen
    5. Source Code Comments
    6. Structuring a Program
  6. 4. Flow of Control
    1. Boolean Logic
      1. Logical equivalence
      2. Logical “and”
      3. Logical “or”
      4. Logical negation
      5. Evaluating larger Boolean expressions
      6. Short-circuit evaluation
    2. If-Statements
      1. If/else-statements
    3. Code Blocks and Indentation
      1. If/elif-statements
      2. Conditional expressions
    4. Loops
      1. For-loops
      2. While-loops
    5. Comparing For-Loops and While-Loops
      1. Calculating factorials
      2. Summing numbers from the user
      3. Summing an unknown number of numbers
    6. Breaking Out of Loops and Blocks
    7. Loops Within Loops
  7. 5. Functions
    1. Calling Functions
      1. Functions that don’t return a value
      2. Reassigning function names
    2. Defining Functions
      1. Parts of a function
    3. Variable Scope
      1. Global variables
    4. Using a main Function
    5. Function Parameters
      1. Pass by reference
      2. An important example
      3. Default values
      4. Keyword parameters
    6. Modules
      1. Namespaces
  8. 6. Strings
    1. String Indexing
      1. Negative indexing
      2. Accessing characters with a for-loop
    2. Characters
      1. Escape characters
    3. Slicing Strings
      1. Slicing shortcuts
      2. Slicing with negative indexes
    4. Standard String Functions
      1. Testing functions
      2. Searching functions
      3. Case-changing functions
      4. Formatting functions
      5. Stripping functions
      6. Splitting functions
      7. Replacement functions
      8. Other functions
    5. Regular Expressions
      1. Simple regular expressions
      2. Matching with regular expressions
      3. More regular expressions
  9. 7. Data Structures
    1. The type Command
    2. Sequences
    3. Tuples
      1. Tuple immutability
      2. Tuple functions
    4. Lists
      1. Mutability
    5. List Functions
    6. Sorting Lists
    7. List Comprehensions
      1. More examples
      2. Filtered comprehensions
    8. Dictionaries
      1. Key restrictions
      2. Dictionary functions
    9. Sets
  10. 8. Input and Output
    1. Formatting Strings
      1. String interpolation
      2. Conversion specifiers
    2. String Formatting
    3. Reading and Writing Files
      1. Folders
      2. The current working directory
    4. Examining Files and Folders
    5. Processing Text Files
      1. Reading a text file, line by line
      2. Reading a text file as a string
      3. Writing to a text file
      4. Appending to a text file
      5. Inserting a string at the start of a file
    6. Processing Binary Files
      1. Pickling
    7. Reading Web Pages
  11. 9. Exception Handling
    1. Exceptions
      1. Raising an exception
    2. Catching Exceptions
      1. Try/except blocks
      2. Catching multiple exceptions
      3. Catching any exception
    3. Clean-Up Actions
      1. The with statement
  12. 10. Object-Oriented Programming
    1. Writing a Class
      1. The self parameter
    2. Displaying Objects
    3. Flexible Initialization
    4. Setters and Getters
      1. Property decorators
      2. Private variables
    5. Inheritance
      1. Overriding methods
    6. Polymorphism
      1. Implementing the move functions
      2. Playing Undercut
      3. Polymorphism in action
    7. Learning More
  13. A. Popular Python Packages
    1. PIL: The Python Imaging Library
    2. Tkinter: Python GUIs
    3. Zope: A Web management system
    4. Django: Developing interactive Web sites
    5. Pygame: 2D animation
    6. SciPy: Scientific computing
    7. Twisted: Network programming
    8. PyPI: The Python Package Index
  14. B. Comparing Python 2 and Python 3
    1. What’s New in Python 3
    2. Converting Python 2 to Python 3
      1. Which Version of Python Should You Use?

Product information

  • Title: Python: Visual QuickStart Guide, Second Edition
  • Author(s):
  • Release date: December 2008
  • Publisher(s): Peachpit Press
  • ISBN: None