Learn Python the Hard Way: A Deceptively Simple Introduction to the Terrifyingly Beautiful World of Computers and Data Science, 5th Edition

Book description

You Will Learn Python!

Zed Shaw has created the world's most reliable system for learning Python. Follow it and you will succeed--just like the millions of beginners Zed has taught to date! You bring the discipline, persistence, and attention; the author supplies the masterful knowledge you need to succeed.

In Learn Python the Hard Way, Fifth Edition, you'll learn Python by working through 60 lovingly crafted exercises. Read them. Type in the code. Run it. Fix your mistakes. Repeat. As you do, you'll learn how a computer works, how to solve problems, and how to enjoy programming . . . even when it's driving you crazy.

  • Install a complete Python environment

  • Organize and write code

  • Fix and break code

  • Basic mathematics

  • Strings and text

  • Interact with users

  • Work with files

  • Looping and logic

  • Object-oriented programming

  • Data structures using lists and dictionaries

  • Modules, classes, and objects

  • Python packaging

  • Automated testing

  • Basic SQL for Data Science

  • Web scraping

  • Fixing bad data (munging)

  • The "Data" part of "Data Science"

It'll be frustrating at first. But if you keep trying, you'll get it--and it'll feel amazing! 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

  • Aspiring Data Scientists or academics who need to learn to code

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

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Halftitle Page
  4. Title Page
  5. Copyright Page
  6. Contents
  7. Preface
    1. Improvements in the Fifth Edition
    2. Acknowledgments
  8. Module 1: Getting Started in Python
    1. Exercise 0. Gearing Up
      1. General Instructions
      2. Minimalist Start
      3. Complete Instructions
      4. Testing Your Setup
      5. Learning the Command Line
      6. Next Steps
    2. Exercise 1. A Good First Program
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
      4. The Blue Plus
    3. Exercise 2. Comments and Pound Characters
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    4. Exercise 3. Numbers and Math
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    5. Exercise 4. Variables and Names
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    6. Exercise 5. More Variables and Printing
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    7. Exercise 6. Strings and Text
      1. What You Should See
      2. Study Drills
      3. Break It
      4. Common Student Questions
    8. Exercise 7. Combining Strings
      1. What You Should See
      2. Study Drills
      3. Break It
      4. Common Student Questions
    9. Exercise 8. Formatting Strings Manually
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    10. Exercise 9. Multi-Line Strings
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    11. Exercise 10. Escape Codes in Strings
      1. What You Should See
      2. Escape Sequences
      3. Study Drills
      4. Common Student Questions
    12. Exercise 11. Asking People Questions
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    13. Exercise 12. An Easier Way to Prompt
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    14. Exercise 13. Parameters, Unpacking, Variables
      1. Code Description
      2. Hold Up! Features Have Another Name
      3. What You Should See
      4. Study Drills
      5. Common Student Questions
    15. Exercise 14. Prompting and Passing
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    16. Exercise 15. Reading Files
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    17. Exercise 16. Reading and Writing Files
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    18. Exercise 17. More Files
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
  9. Module 2: The Basics of Programming
    1. Exercise 18. Names, Variables, Code, Functions
      1. Exercise Code
      2. What You Should See
      3. Study Drills
      4. Common Student Questions
    2. Exercise 19. Functions and Variables
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    3. Exercise 20. Functions and Files
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    4. Exercise 21. Functions Can Return Something
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    5. Exercise 22. Strings, Bytes, and Character Encodings
      1. Initial Research
      2. Switches, Conventions, and Encodings
      3. Dissecting the Output
      4. Dissecting the Code
      5. Encodings Deep Dive
      6. Breaking It
    6. Exercise 23. Introductory Lists
      1. Accessing Elements of a List
      2. Practicing Lists
      3. The Code
      4. The Challenge
      5. Final Challenge
    7. Exercise 24. Introductory Dictionaries
      1. Key/Value Structures
      2. Combining Lists with Data Objects
      3. The Code
      4. What You Should See
      5. The Challenge
      6. Final Challenge
    8. Exercise 25. Dictionaries and Functions
      1. Step 1: Function Names Are Variables
      2. Step 2: Dictionaries with Variables
      3. Step 3: Dictionaries with Functions
      4. Step 4: Deciphering the Last Line
      5. Study Drill
    9. Exercise 26. Dictionaries and Modules
      1. Step 1: Review of import
      2. Step 2: Find the __dict__
      3. Step 3: Change the __dict__
      4. Study Drill: Find the “Dunders”
    10. Exercise 27. The Five Simple Rules to the Game of Code
      1. Rule 1: Everything Is a Sequence of Instructions
      2. Rule 2: Jumps Make the Sequence Non-Linear
      3. Rule 3: Tests Control Jumps
      4. Rule 4: Storage Controls Tests
      5. Rule 5: Input/Output Controls Storage
      6. Putting It All Together
    11. Exercise 28. Memorizing Logic
      1. The Truth Terms
      2. The Truth Tables
      3. Common Student Questions
    12. Exercise 29. Boolean Practice
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    13. Exercise 30. What If
      1. What You Should See
      2. dis() It
      3. Study Drill
      4. Common Student Questions
    14. Exercise 31. Else and If
      1. What You Should See
      2. dis() It
      3. Study Drills
      4. Common Student Questions
    15. Exercise 32. Making Decisions
      1. What You Should See
      2. dis() It
      3. Study Drills
      4. Common Student Questions
    16. Exercise 33. Loops and Lists
      1. What You Should See
      2. dis() It
      3. Study Drills
      4. Common Student Questions
    17. Exercise 34. While Loops
      1. What You Should See
      2. dis() It
      3. Study Drills
      4. Common Student Questions
    18. Exercise 35. Branches and Functions
      1. What You Should See
      2. Study Drills
      3. Common Student Questions
    19. Exercise 36. Designing and Debugging
      1. From Idea to Working Code
      2. Rules for If-Statements
      3. Rules for Loops
      4. Tips for Debugging
      5. Homework
    20. 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
  10. Module 3: Applying What You Know
    1. Exercise 38. Beyond Jupyter for Windows
      1. Why Learn PowerShell?
      2. What Is PowerShell?
      3. Crash Landing
    2. Exercise 39. Beyond Jupyter for macOS/Linux
      1. macOS Troubles
      2. Why Learn Bash or ZSH?
      3. What Is Bash?
      4. Crash Landing
    3. Exercise 40. Advanced Developer Tools
      1. Managing conda Environments
      2. Adding conda-forge
      3. Using pip
      4. Using a .condarc
      5. General Editing Tips
      6. Going Further
    4. Exercise 41. A Project Skeleton
      1. Activate an Environment
      2. Just Use cookiecutter
      3. Building Your Project
      4. Installing Your Project
      5. Testing the Install
      6. Remove test-project
      7. Common Errors
      8. Study Drills
    5. Exercise 42. 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
    6. Exercise 43. Doing Things to Dictionaries
      1. A Dictionary Example
      2. What You Should See
      3. What Dictionaries Can Do
      4. Study Drills
      5. Common Student Questions
    7. Exercise 44. From Dictionaries to Objects
      1. Step 1: Passing a Dict to a Function
      2. Step 2: talk inside the Dict
      3. Step 3: Closures
      4. Step 4: A Person Constructor
      5. Study Drills
    8. Exercise 45. Basic Object-Oriented Programming
      1. Python’s People
      2. Using dir() and __dict__
      3. About the Dot (.)
      4. Terminology
      5. A Word on self
      6. Study Drills
      7. Common Student Questions
    9. Exercise 46. Inheritance and Advanced OOP
      1. How This Looks in Code
      2. About class Name(object)
      3. Study Drills
      4. Common Student Questions
    10. Exercise 47. Basic Object-Oriented Analysis and Design
      1. The Analysis of a Simple Game Engine
      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
    11. Exercise 48. Inheritance versus Composition
      1. What Is Inheritance?
      2. The Reason for super()
      3. Composition
      4. When to Use Inheritance or Composition
      5. Study Drill
      6. Common Student Questions
    12. Exercise 49. You Make a Game
      1. Evaluating Your Game
      2. Function Style
      3. Class Style
      4. Code Style
      5. Good Comments
      6. Evaluate Your Game
    13. Exercise 50. Automated Testing
      1. What Is the Purpose of Testing?
      2. How to Test Efficiently
      3. Install PyTest
      4. Simple PyTest Demo
      5. Running pytest
      6. Exceptions and try/except
      7. Getting Coverage Reports
      8. Study Drills
      9. Common Student Questions
  11. Module 4: Python and Data Science
    1. Exercise 51. What Is Data Munging?
      1. Why Data Munging?
      2. The Problem
      3. The Setup
      4. How to Code
      5. Process Example
      6. Solution Strategies
      7. Awesome ETL Tools
      8. Study Drills
    2. Exercise 52. Scraping Data from the Web
      1. Introducing with
      2. The Problem
      3. The Setup
      4. The Clue
      5. Awesome Scraping Tools
      6. Study Drills
    3. Exercise 53. Getting Data from APIs
      1. Introducing JSON
      2. The Problem
      3. The Setup
      4. The Clue
      5. Awesome API Tools
      6. Study Drills
    4. Exercise 54. Data Conversion with pandas
      1. Introducing Pandoc
      2. The Problem
      3. The Setup
      4. The Clue
      5. Study Drills
    5. Exercise 55. How to Read Documentation (Featuring pandas)
      1. Why Programmer Documentation Sucks
      2. How to Actively Read Programmer Docs
      3. Step #1: Find the Docs
      4. Step #2: Determine Your Strategy
      5. Step #3: Code First, Docs Second
      6. Step #4: Break or Change the Code
      7. Step #5: Take Notes
      8. Step #6: Use It on Your Own
      9. Step #7: Write About What You Learned
      10. Step #8: What’s the Gestalt?
      11. Reading My pandas Curriculum
    6. Exercise 56. Using Only pandas
      1. Make a Project
      2. The Problem
      3. The Setup
      4. Study Drill
    7. Exercise 57. The SQL Crash Course
      1. What Is SQL?
      2. The Setup
      3. Fixing and Loading
      4. Create, Read, Update, Delete
      5. SELECT
      6. Date and Time
      7. INSERT
      8. UPDATE
      9. DELETE and Transactions
      10. Math, Aggregates, and GROUP BY
      11. Python Access
    8. Exercise 58. SQL Normalization
      1. What Is Normalization?
      2. First Normal Form
      3. Second Normal Form (2NF)
      4. Querying 2NF Data
      5. Querying with Joins
      6. Study Drills
    9. Exercise 59. SQL Relationships
      1. One-to-Many (1:M)
      2. Many-to-Many (M:M)
      3. One-to-One (1:1)
      4. Attributed Relations
      5. Querying M:M Tables
      6. Your Last Study Drill
    10. Exercise 60. Advice from an Even Older Programmer
  12. Index
  13. Code Snippets

Product information

  • Title: Learn Python the Hard Way: A Deceptively Simple Introduction to the Terrifyingly Beautiful World of Computers and Data Science, 5th Edition
  • Author(s): Zed A. Shaw
  • Release date: February 2024
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780138270711