Python in 24 Hours, Sams Teach Yourself, Second Edition

Book description

In just 24 sessions of one hour or less, Sams Teach Yourself Python in 24 Hours will help you get started fast, master all the core concepts of programming, and build anything from websites to games. Using this book’s straightforward, step-by-step approach, you’ll move from the absolute basics through functions, objects, classes, modules, database integration, and more. Every lesson and case study application builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Python development tasks.

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

Notes present interesting information related to the discussion.

Tips offer advice or show you easier ways to perform tasks.

Warnings alert you to possible problems and give you advice on how to avoid them.

Learn how to…

  • Install and run the right version of Python for your operating system

  • Store, manipulate, reformat, combine, and organize information

  • Create logic to control how programs run and what they do

  • Interact with users or other programs, wherever they are

  • Save time and improve reliability by creating reusable functions

  • Master Python data types: numbers, text, lists, and dictionaries

  • Write object-oriented programs that work better and are easier to improve

  • Expand Python classes to make them even more powerful

  • Use third-party modules to perform complex tasks without writing new code

  • Split programs to make them more maintainable and reusable

  • Clearly document your code so others can work with it

  • Store data in SQLite databases, write queries, and share data via JSON

  • Simplify Python web development with the Flask framework

  • Quickly program Python games with PyGame

  • Avoid, troubleshoot, and fix problems with your code

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 Author
  7. Dedication
  8. Acknowledgments
  9. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
  10. We Want to Hear from You!
  11. Reader Services
  12. Introduction
    1. Learning to Program
    2. Why Python?
    3. Getting Started
    4. How This Book Works
    5. What to Do If You Get Stuck
  13. Hour 1. Installing and Running Python
    1. Discovering Your Operating System
    2. Setting Up Python on Windows
    3. Setting Up Python on a Mac
    4. Summary
    5. Q&A
    6. Workshop
  14. Hour 2. Putting Numbers to Work in Python
    1. Storing Information with Variables
    2. Doing Math in Python
    3. Comparing Numbers
    4. Applying Python Math in the Real World
    5. Summary
    6. Q&A
    7. Workshop
  15. Hour 3. Logic in Programming
    1. Using a Basic if Statement
    2. Creating Blocks
    3. Adding an else to an if
    4. Testing Many Things with elif
    5. True and False Variables
    6. Using try/except to Avoid Errors
    7. Applying Logic to Real-World Problems
    8. Summary
    9. Q&A
    10. Workshop
  16. Hour 4. Storing Text in Strings
    1. Creating Strings
    2. Printing Strings
    3. Getting Information About a String
    4. Math and Comparison
    5. Formatting Strings
    6. Using Strings in the Real World
    7. Summary
    8. Q&A
    9. Workshop
  17. Hour 5. Processing Input and Output
    1. Getting Information from the Command Line
    2. Getting a Password
    3. Cleaning Up User Input
    4. Formatting Output
    5. Managing Input and Output in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  18. Hour 6. Grouping Items in Lists
    1. Creating a List
    2. Getting Information About a List
    3. Manipulating Lists
    4. Using Math in Lists
    5. Ordering Lists
    6. Comparing Lists
    7. Using Lists in the Real World
    8. Summary
    9. Q&A
    10. Workshop
  19. Hour 7. Using Loops to Repeat Code
    1. Repeating a Set Number of Times
    2. Repeating Only When True
    3. Using Loops in the Real World
    4. Summary
    5. Q&A
    6. Workshop
  20. Hour 8. Using Functions to Create Reusable Code
    1. Creating a Basic Function
    2. Passing Values to Functions
    3. Variables in Functions: Scope
    4. Grouping Functions Within a Function
    5. Sending a Varying Number of Parameters
    6. Using Functions in the Real World
    7. Summary
    8. Q&A
    9. Workshop
  21. Hour 9. Using Dictionaries to Pair Keys with Values
    1. Creating a Dictionary
    2. Getting Information About a Dictionary
    3. Comparing Dictionaries
    4. Using Dictionaries in the Real World
    5. Summary
    6. Q&A
    7. Workshop
  22. Hour 10. Making Objects
    1. Object-Oriented Programming
    2. Planning an Object
    3. Making Objects Out of Objects
    4. Using Objects in the Real World
    5. Summary
    6. Q&A
    7. Workshop
  23. Hour 11. Making Classes
    1. Making a Basic Class Statement
    2. Adding Methods to Classes
    3. Setting Up Class Instances
    4. Using Classes in the Real World
    5. Summary
    6. Q&A
    7. Workshop
  24. Hour 12. Expanding Classes to Add Functionality
    1. Built-in Extras
    2. Class Inheritance
    3. When to Expand Classes in the Real World
    4. Summary
    5. Q&A
    6. Workshop
  25. Hour 13. Using Python’s Modules to Add Functionality
    1. Python Packages
    2. Using the random Module
    3. Using the datetime Module
    4. Finding More Modules
    5. Using Modules in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  26. Hour 14. Splitting Up a Program
    1. Why Split Up a Program?
    2. Deciding How to Break Up Code
    3. How Python Finds a Program’s Code
    4. Splitting Up Code in the Real World
    5. Summary
    6. Q&A
    7. Workshop
  27. Hour 15. Providing Documentation for Code
    1. The Need for Good Documentation
    2. Embedding Comments in Code
    3. Explaining Code with Docstrings
    4. Including README and INSTALL
    5. Providing Documentation in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  28. Hour 16. Working with Program Files
    1. Reading to and Writing from Files
    2. Creating Files
    3. Getting Information About a Directory
    4. Getting Information About a File
    5. Using Files in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  29. Hour 17. Sharing Information with JSON
    1. The JSON Format
    2. Working with JSON Files
    3. Saving Objects as JSON
    4. Creating Custom Dictionaries
    5. Using JSON in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  30. Hour 18. Storing Information in Databases
    1. Why Use Databases?
    2. Talking to Databases with SQL
    3. Creating a Database
    4. Querying the Database
    5. Using Databases in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  31. Hour 19. Using SQL to Get More out of Databases
    1. Filtering with WHERE
    2. Sorting with ORDER BY
    3. Getting Unique Items with DISTINCT
    4. Updating Records with UPDATE
    5. Deleting Records with DELETE
    6. Using SQL in the Real World
    7. Summary
    8. Q&A
    9. Workshop
  32. Hour 20. Developing for the Web with Flask
    1. What Is Flask?
    2. Installing Flask
    3. Making Your First Flask App
    4. Adding Templates
    5. Using Frameworks in the Real World
    6. Summary
    7. Q&A
    8. Workshop
  33. Hour 21. Making Games with PyGame
    1. What Is PyGame?
    2. Installing PyGame
    3. Creating Screens
    4. Creating Shapes
    5. Moving Things Around on the Screen
    6. Getting Input from the User
    7. Drawing Text
    8. Using PyGame in the Real World
    9. Summary
    10. Q&A
    11. Workshop
  34. Hour 22. Saving Your Code Properly Through Versioning
    1. What Is Versioning?
    2. Versioning with Git and GitHub
    3. Managing Code in a Repository
    4. Experimental Changes with Branches
    5. Determining What Not to Push
    6. Summary
    7. Q&A
    8. Workshop
  35. Hour 23. Fixing Problem Code
    1. When Your Code Has a Bug
    2. Locating Errors with a Traceback
    3. Finding Errors with the pdb Debugger
    4. Searching the Internet for Solutions
    5. Trying a Fix
    6. Finding Outside Support
    7. Summary
    8. Q&A
    9. Workshop
  36. Hour 24. Taking the Next Steps with Python
    1. Interesting Projects
    2. Attending Conferences
    3. Working with Linux
    4. Contributing to Python
    5. Contributing to Other Projects
    6. Learning Another Language
    7. Looking Forward to Python 3
    8. Recommended Reading
    9. Recommended Websites
    10. Summary
    11. Q&A
    12. Workshop
  37. Index

Product information

  • Title: Python in 24 Hours, Sams Teach Yourself, Second Edition
  • Author(s):
  • Release date: October 2013
  • Publisher(s): Sams
  • ISBN: 9780133354461