0%

Book Description

You Will Learn Python 3!

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

In addition to the text, companion videos are also available for this book on Safari. Search "9780134862989" or "Learn Python 3 the Hard Way (Companion Videos)" to access over 11 hours of video available for this book.

In Learn Python 3 the Hard Way, 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 a computer works; what good programs look like; and how to read, write, and think about code. Zed then teaches you even more in 5+ hours of video where he shows you how to break, fix, and debug your code–live, as he's doing the exercises.

  • Install a complete Python environment

  • Organize and write code

  • Fix and break code

  • Basic mathematics

  • Variables

  • Strings and text

  • Interact with users

  • Work 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

  • 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 course 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.

This Book Is Perfect For

  • Total beginners with zero programming experience

  • Junior developers who know one or two languages

  • Returning professionals who haven't written code in years

  • Seasoned professionals looking for a fast, simple, crash course in Python 3

Table of Contents

  1. About This eBook
  2. Title Page
  3. Copyright Page
  4. Contents
  5. Preface
    1. Improvements in the Python 3 Edition
    2. The Hard Way Is Easier
      1. Reading and Writing
      2. Attention to Detail
      3. Spotting Differences
      4. Ask, Don’t Stare
      5. Do Not Copy-Paste
      6. Using the Included Videos
      7. A Note on Practice and Persistence
    3. Acknowledgments
  6. Exercise 0. The Setup
    1. macOS
      1. macOS: What You Should See
    2. Windows
      1. Windows: What You Should See
    3. Linux
      1. Linux: What You Should See
    4. Finding Things on the Internet
    5. Warnings for Beginners
    6. Alternative Text Editors
  7. Exercise 1. A Good First Program
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  8. Exercise 2. Comments and Pound Characters
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  9. Exercise 3. Numbers and Math
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  10. Exercise 4. Variables and Names
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  11. Exercise 5. More Variables and Printing
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  12. Exercise 6. Strings and Text
    1. What You Should See
    2. Study Drills
    3. Break It
    4. Common Student Questions
  13. Exercise 7. More Printing
    1. What You Should See
    2. Study Drills
    3. Break It
    4. Common Student Questions
  14. Exercise 8. Printing, Printing
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  15. Exercise 9. Printing, Printing, Printing
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  16. Exercise 10. What Was That?
    1. What You Should See
    2. Escape Sequences
    3. Study Drills
    4. Common Student Questions
  17. Exercise 11. Asking Questions
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  18. Exercise 12. Prompting People
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  19. Exercise 13. Parameters, Unpacking, Variables
    1. Hold Up! Features Have Another Name
    2. What You Should See
    3. Study Drills
    4. Common Student Questions
  20. Exercise 14. Prompting and Passing
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  21. Exercise 15. Reading Files
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  22. Exercise 16. Reading and Writing Files
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  23. Exercise 17. More Files
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  24. Exercise 18. Names, Variables, Code, Functions
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  25. Exercise 19. Functions and Variables
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  26. Exercise 20. Functions and Files
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  27. Exercise 21. Functions Can Return Something
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  28. Exercise 22. What Do You Know So Far?
    1. What You Are Learning
  29. Exercise 23. Strings, Bytes, and Character Encodings
    1. Initial Research
    2. Switches, Conventions, and Encodings
    3. Disecting the Output
    4. Disecting the Code
    5. Encodings Deep Dive
    6. Breaking It
  30. Exercise 24. More Practice
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  31. Exercise 25. Even More Practice
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  32. Exercise 26. Congratulations, Take a Test!
    1. Common Student Questions
  33. Exercise 27. Memorizing Logic
    1. The Truth Terms
    2. The Truth Tables
    3. Common Student Questions
  34. Exercise 28. Boolean Practice
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  35. Exercise 29. What If
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  36. Exercise 30. Else and If
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  37. Exercise 31. Making Decisions
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  38. Exercise 32. Loops and Lists
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  39. Exercise 33. While Loops
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  40. Exercise 34. Accessing Elements of Lists
    1. Study Drills
  41. Exercise 35. Branches and Functions
    1. What You Should See
    2. Study Drills
    3. Common Student Questions
  42. Exercise 36. Designing and Debugging
    1. Rules for if-statements
    2. Rules for Loops
    3. Tips for Debugging
    4. Homework
  43. Exercise 37. Symbol Review
    1. Keywords
    2. Data Types
    3. String Escape Sequences
    4. Old Style String Formats
    5. Operators
    6. Reading Code
    7. Study Drills
    8. Common Student Questions
  44. Exercise 38. Doing Things to Lists
    1. What You Should See
    2. What Lists Can Do
    3. When to Use Lists
    4. Study Drills
    5. Common Student Questions
  45. Exercise 39. Dictionaries, Oh Lovely Dictionaries
    1. A Dictionary Example
    2. What You Should See
    3. What Dictionaries Can Do
    4. Study Drills
    5. Common Student Questions
  46. Exercise 40. Modules, Classes, and Objects
    1. Modules Are Like Dictionaries
      1. Classes Are Like Modules
      2. Objects Are Like Import
      3. Getting Things from Things
      4. A First Class Example
    2. What You Should See
    3. Study Drills
    4. Common Student Questions
  47. Exercise 41. Learning to Speak Object-Oriented
    1. Word Drills
    2. Phrase Drills
    3. Combined Drills
    4. A Reading Test
    5. Practice English to Code
    6. Reading More Code
    7. Common Student Questions
  48. Exercise 42. Is-A, Has-A, Objects, and Classes
    1. How This Looks in Code
    2. About class Name(object)
    3. Study Drills
    4. Common Student Questions
  49. Exercise 43. Basic Object-Oriented Analysis and Design
    1. The Analysis of a Simple Game Engine
      1. Write or Draw About the Problem
      2. Extract Key Concepts and Research Them
      3. Create a Class Hierarchy and Object Map for the Concepts
      4. Code the Classes and a Test to Run Them
      5. Repeat and Refine
    2. Top Down versus Bottom Up
    3. The Code for “Gothons from Planet Percal #25”
    4. What You Should See
    5. Study Drills
    6. Common Student Questions
  50. Exercise 44. Inheritance versus Composition
    1. What Is Inheritance?
      1. Implicit Inheritance
      2. Override Explicitly
      3. Alter Before or After
      4. All Three Combined
    2. The Reason for super()
      1. Using super() with __init__
    3. Composition
    4. When to Use Inheritance or Composition
    5. Study Drills
    6. Common Student Questions
  51. Exercise 45. You Make a Game
    1. Evaluating Your Game
    2. Function Style
    3. Class Style
    4. Code Style
    5. Good Comments
    6. Evaluate Your Game
  52. Exercise 46. A Project Skeleton
    1. macOS/Linux Setup
    2. Windows 10 Setup
    3. Creating the Skeleton Project Directory
      1. Final Directory Structure
    4. Testing Your Setup
    5. Using the Skeleton
    6. Required Quiz
    7. Common Student Questions
  53. Exercise 47. Automated Testing
    1. Writing a Test Case
    2. Testing Guidelines
    3. What You Should See
    4. Study Drills
    5. Common Student Questions
  54. Exercise 48. Advanced User Input
    1. Our Game Lexicon
      1. Breaking Up a Sentence
      2. Lexicon Tuples
      3. Scanning Input
      4. Exceptions and Numbers
    2. A Test First Challenge
    3. What You Should Test
    4. Study Drills
    5. Common Student Questions
  55. Exercise 49. Making Sentences
    1. Match and Peek
    2. The Sentence Grammar
    3. A Word on Exceptions
    4. The Parser Code
    5. Playing with the Parser
    6. What You Should Test
    7. Study Drills
    8. Common Student Questions
  56. Exercise 50. Your First Website
    1. Installing flask
    2. Make a Simple “Hello World” Project
    3. What’s Going On?
    4. Fixing Errors
    5. Create Basic Templates
    6. Study Drills
    7. Common Student Questions
  57. Exercise 51. Getting Input from a Browser
    1. How the Web Works
    2. How Forms Work
    3. Creating HTML Forms
    4. Creating a Layout Template
    5. Writing Automated Tests for Forms
    6. Study Drills
    7. Breaking It
  58. Exercise 52. The Start of Your Web Game
    1. Refactoring the Exercise 43 Game
    2. Creating an Engine
    3. Your Final Exam
    4. Common Student Questions
  59. Next Steps
    1. How to Learn Any Programming Language
  60. Advice from an Old Programmer
  61. Appendix. Command Line Crash Course
    1. Introduction: Shut Up and Shell
      1. How to Use This Appendix
      2. You Will Be Memorizing Things
    2. The Setup
      1. Do This
      2. You Learned This
      3. Do More
    3. Paths, Folders, Directories (pwd)
      1. Do This
      2. You Learned This
      3. Do More
    4. If You Get Lost
      1. Do This
      2. You Learned This
    5. Make a Directory (mkdir)
      1. Do This
      2. You Learned This
      3. Do More
    6. Change Directory (cd)
      1. Do This
      2. You Learned This
      3. Do More
    7. List Directory (ls)
      1. Do This
      2. You Learned This
      3. Do More
    8. Remove Directory (rmdir)
      1. Do This
      2. You Learned This
      3. Do More
    9. Moving Around (pushd, popd)
      1. Do This
      2. You Learned This
      3. Do More
    10. Making Empty Files (touch/New-Item)
      1. Do This
      2. You Learned This
      3. Do More
    11. Copy a File (cp)
      1. Do This
      2. You Learned This
      3. Do More
    12. Moving a File (mv)
      1. Do This
      2. You Learned This
      3. Do More
    13. View a File (less/more)
      1. Do This
      2. You Learned This
      3. Do More
    14. Stream a File (cat)
      1. Do This
      2. You Learned This
      3. Do More
    15. Removing a File (rm)
      1. Do This
      2. You Learned This
      3. Do More
    16. Exiting Your Terminal (exit)
      1. Do This
      2. You Learned This
      3. Do More
    17. Command Line Next Steps
      1. Unix Bash References
      2. PowerShell References
  62. Index
  63. Code Snippets