Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

Book description

In just 24 sessions of one hour or less, Sams Teach Yourself Python Programming for Raspberry Pi in 24 Hours teaches you Python programmingon Raspberry Pi, so you can start creating awesome projects for homeautomation, home theater, gaming, and more. Using this book’s straightforward,step-by-step approach, you’ll move from the absolute basics all theway through network and web connections, multimedia, and even connectingwith electronic circuits for sensing and robotics. Every lesson and casestudy application builds on what you’ve already learned, giving you arock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Raspberry Pi Python programming tasks.

Quizzes at the end of each chapter help you test your knowledge.

By the Way notes present interesting information related to the discussion.

Did You Know? tips offer advice or show you easier ways to perform tasks.

Watch Out! cautions alert you to possible problems and give you advice on how to avoid them.

  • Get your Raspberry Pi and choose the right low-cost peripherals

  • Set up Raspian Linux and the Python programming environment

  • Learn Python basics, including arithmetic and structured commands

  • Master Python 3 lists, tuples, dictionaries, sets, strings, files, and modules

  • Reuse the same Python code in multiple locations with functions

  • Manipulate string data efficiently with regular expressions

  • Practice simple object-oriented programming techniques

  • Use exception handling to make your code more reliable

  • Program modern graphical user interfaces with Raspberry Pi and OpenGL

  • Create Raspberry Pi games with the PyGame library

  • Learn network, web, and database techniques you can also use in business software

  • Write Python scripts that send email

  • Interact with other devices through Raspberry Pi’s GPIO interface

  • Walk through example Raspberry Pi projects that inspire you to do even more

  • Table of contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents at a Glance
    5. Table of Contents
    6. About the Authors
    7. Dedication
    8. Acknowledgments
    9. We Want to Hear from You!
    10. Reader Services
    11. Introduction
      1. Programming with Python
      2. Who Should Read This Book?
      3. Conventions Used in This Book
    12. Part I: The Raspberry Pi Programming Environment
      1. Hour 1. Setting Up the Raspberry Pi
        1. What Is a Raspberry Pi?
        2. Acquiring a Raspberry Pi
        3. What Raspberry Pi Peripherals Are Necessary?
        4. Nice Additional Peripherals
        5. Deciding How to Purchase Peripherals
        6. Getting Your Raspberry Pi Working
        7. Troubleshooting Your Raspberry Pi
        8. Summary
        9. Q&A
        10. Workshop
      2. Hour 2. Understanding the Raspbian Linux Distribution
        1. Learning About Linux
        2. Interacting with the Raspbian Command Line
        3. Interacting with the Raspbian GUI
        4. Summary
        5. Q&A
        6. Workshop
      3. Hour 3. Setting Up a Programming Environment
        1. Exploring Python
        2. Checking Your Python Environment
        3. Installing Python and Tools
        4. Learning About the Python Interpreter
        5. Learning About the Python Interactive Shell
        6. Learning About the Python Development Environment Shell
        7. Creating Python Scripts
        8. Knowing Which Tool to Use and When
        9. Summary
        10. Q&A
        11. Workshop
    13. Part II: Python Fundamentals
      1. Hour 4. Understanding Python Basics
        1. Producing Python Script Output
        2. Formatting Scripts for Readability
        3. Understanding Python Variables
        4. Assigning Value to Python Variables
        5. Learning About Python Data Types
        6. Allowing Python Script Input
        7. Summary
        8. Q&A
        9. Workshop
      2. Hour 5. Using Arithmetic in Your Programs
        1. Working with Math Operators
        2. Calculating with Fractions
        3. Using Complex Number Math
        4. Getting Fancy with the math Module
        5. Using the NumPy Math Libraries
        6. Summary
        7. Q&A
        8. Workshop
      3. Hour 6. Controlling Your Program
        1. Working with the if Statement
        2. Grouping Multiple Statements
        3. Adding Other Options with the else Statement
        4. Adding More Options Using the elif Statement
        5. Comparing Values in Python
        6. Checking Complex Conditions
        7. Negating a Condition Check
        8. Summary
        9. Q&A
        10. Workshop
      4. Hour 7. Learning About Loops
        1. Performing Repetitive Tasks
        2. Using the for Loop for Iteration
        3. Using the while Loop for Iteration
        4. Creating Nested Loops
        5. Summary
        6. Q&A
        7. Workshop
    14. Part III: Advanced Python
      1. Hour 8. Using Lists and Tuples
        1. Introducing Tuples
        2. Introducing Lists
        3. Using Multidimensional Lists to Store Data
        4. Working with Lists and Tuples in Your Scripts
        5. Creating Lists by Using List Comprehensions
        6. Working with Ranges
        7. Summary
        8. Q&A
        9. Workshop
      2. Hour 9. Dictionaries and Sets
        1. Understanding Python Dictionary Terms
        2. Exploring Dictionary Basics
        3. Programming with Dictionaries
        4. Understanding Python Sets
        5. Exploring Set Basics
        6. Obtaining Information from a Set
        7. Modifying a Set
        8. Programming with Sets
        9. Summary
        10. Q&A
        11. Workshop
      3. Hour 10. Working with Strings
        1. The Basics of Using Strings
        2. Using Functions to Manipulate Strings
        3. Formatting Strings for Output
        4. Summary
        5. Q&A
        6. Workshop
      4. Hour 11. Using Files
        1. Understanding Linux File Structures
        2. Opening a File
        3. Reading a File
        4. Closing a File
        5. Writing to a File
        6. Summary
        7. Q&A
        8. Workshop
      5. Hour 12. Creating Functions
        1. Utilizing Python Functions in Your Programs
        2. Returning a Value
        3. Passing Values to Functions
        4. Handling Variables in a Function
        5. Using Lists with Functions
        6. Using Recursion with Functions
        7. Summary
        8. Q&A
        9. Workshop
      6. Hour 13. Working with Modules
        1. Introducing Module Concepts
        2. Exploring Standard Modules
        3. Learning About Python Modules
        4. Creating Custom Modules
        5. Summary
        6. Q&A
        7. Workshop
      7. Hour 14. Exploring the World of Object-Oriented Programming
        1. Understanding the Basics of Object-Oriented Programming
        2. Defining Class Methods
        3. Sharing Your Code with Class Modules
        4. Summary
        5. Q&A
        6. Workshop
      8. Hour 15. Employing Inheritance
        1. Learning About the Class Problem
        2. Understanding Subclasses and Inheritance
        3. Using Inheritance in Python
        4. Using Inheritance in Python Scripts
        5. Summary
        6. Q&A
        7. Workshop
      9. Hour 16. Regular Expressions
        1. What Are Regular Expressions?
        2. Working with Regular Expressions in Python
        3. Defining Basic Patterns
        4. Using Advanced Regular Expressions Features
        5. Working with Regular Expressions in Your Python Scripts
        6. Summary
        7. Q&A
        8. Workshop
      10. Hour 17. Exception Handling
        1. Understanding Exceptions
        2. Handling Exceptions
        3. Handling Multiple Exceptions
        4. Summary
        5. Q&A
        6. Workshop
    15. Part IV: Graphical Programming
      1. Hour 18. GUI Programming
        1. Programming for a GUI Environment
        2. Examining Python GUI Packages
        3. Using the tkinter Package
        4. Exploring the tkinter Widgets
        5. Summary
        6. Q&A
        7. Workshop
      2. Hour 19. Game Programming
        1. Understanding Game Programming
        2. Learning About Game Frameworks and Libraries
        3. Setting Up the PyGame Library
        4. Using PyGame
        5. Learning More About PyGame
        6. Dealing with PyGame Action
        7. Summary
        8. Q&A
        9. Workshop
    16. Part V: Business Programming
      1. Hour 20. Using the Network
        1. Finding the Python Network Modules
        2. Working with Email Servers
        3. Working with Web Servers
        4. Linking Programs Using Socket Programming
        5. Summary
        6. Q&A
        7. Workshop
      2. Hour 21. Using Databases in Your Programming
        1. Working with the MySQL Database
        2. Using the PostgreSQL Database
        3. Summary
        4. Q&A
        5. Workshop
      3. Hour 22. Web Programming
        1. Running a Web Server on the Pi
        2. Programming with the Common Gateway Interface
        3. Expanding Your Python Webpages
        4. Processing Forms
        5. Summary
        6. Q&A
        7. Workshop
    17. Part VI: Raspberry Pi Python Projects
      1. Hour 23. Creating Basic Pi/Python Projects
        1. Thinking About Basic Pi/Python Projects
        2. Displaying HD Images via Python
        3. Playing Music
        4. Creating a Special Presentation
        5. Summary
        6. Q&A
        7. Workshop
      2. Hour 24. Working with Advanced Pi/Python Projects
        1. Exploring the GPIO Interface
        2. Using the RPi.GPIO Module
        3. Controlling GPIO Output
        4. Detecting GPIO Input
        5. Summary
        6. Q&A
        7. Workshop
    18. Part VII: Appendix
      1. Appendix A. Loading the Raspbian Operating System onto an SD Card
        1. Windows: Loading Raspbian onto an SD Card
        2. Linux: Loading Raspbian onto an SD Card
        3. Mac: Loading Raspbian onto an SD Card
    19. Index

    Product information

    • Title: Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours
    • Author(s): Richard Blum, Christine Bresnahan
    • Release date: October 2013
    • Publisher(s): Sams
    • ISBN: 9780133490169