Real-World Python

Book description

With its emphasis on project-based practice, Real-World Python will take you from playing with syntax to writing complete programs in no time. You’ll conduct experiments, explore statistical concepts, and solve novel problems that have frustrated geniuses throughout history, like detecting distant exoplanets, as you continue to build your Python skills.

Chapters begin with a clearly defined project goal and a discussion of ways to attack the problem, followed by a mission designed to make you think like a programmer. You’ll direct a Coast Guard search-and-rescue effort, plot and execute a NASA flight to the moon, protect access to a secure lab using facial recognition, and more. Along the way you’ll learn how to:

•Use libraries like matplotlib, NumPy, Bokeh, pandas, Requests, Beautiful Soup, and turtle
•Work with Natural Language Processing and computer vision modules like NLTK and OpenCV
•Write a program to detect and track objects moving across a starfield
•Scrape speeches from the internet and autosummarize them
•Use the Mars Orbiter Laser Altimeter (MOLA) map to select spacecraft landing sites
•Survive a zombie apocalypse with the aid of data-plotting and visualization tools

The book’s programs are beginner-friendly, but as you progress you’ll learn more sophisticated techniques to help you grow your coding capabilities. Once your missions are accomplished, you’ll be ready to solve real-world problems with Python on your own.

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Author
  6. BRIEF CONTENTS
  7. CONTENTS IN DETAIL
  8. ACKNOWLEDGMENTS
  9. INTRODUCTION
    1. Who Should Read This Book?
    2. Why Python?
    3. What’s in This Book?
    4. Onward!
  10. 1 SAVING SHIPWRECKED SAILORS WITH BAYES’ RULE
    1. Bayes’ Rule
    2. Project #1: Search and Rescue
    3. Summary
    4. Further Reading
    5. Challenge Project: Smarter Searches
    6. Challenge Project: Finding the Best Strategy with MCS
    7. Challenge Project: Calculating the Probability of Detection
  11. 2 ATTRIBUTING AUTHORSHIP WITH STYLOMETRY
    1. Project #2: The Hound, The War, and The Lost World
    2. Summary
    3. Further Reading
    4. Practice Project: Hunting the Hound with Dispersion
    5. Practice Project: Punctuation Heatmap
    6. Challenge Project: Fixing Frequency
  12. 3 SUMMARIZING SPEECHES WITH NATURAL LANGUAGE PROCESSING
    1. Project #3: I Have a Dream . . . to Summarize Speeches!
    2. Project #4: Summarizing Speeches with gensim
    3. Project #5: Summarizing Text with Word Clouds
    4. Summary
    5. Further Reading
    6. Challenge Project: Game Night
    7. Challenge Project: Summarizing Summaries
    8. Challenge Project: Summarizing a Novel
    9. Challenge Project: It’s Not Just What You Say, It’s How You Say It!
  13. 4 SENDING SUPER-SECRET MESSAGES WITH A BOOK CIPHER
    1. The One-Time Pad
    2. The Rebecca Cipher
    3. Project #6: The Digital Key to Rebecca
    4. Summary
    5. Further Reading
    6. Practice Project: Charting the Characters
    7. Practice Project: Sending Secrets the WWII Way
  14. 5 FINDING PLUTO
    1. Project #7: Replicating a Blink Comparator
    2. Project #8: Detecting Astronomical Transients with Image Differencing
    3. Summary
    4. Further Reading
    5. Practice Project: Plotting the Orbital Path
    6. Practice Project: What’s the Difference?
    7. Challenge Project: Counting Stars
  15. 6 WINNING THE MOON RACE WITH APOLLO 8
    1. Understanding the Apollo 8 Mission
    2. Project #9: To the Moon with Apollo 8!
    3. Summary
    4. Further Reading
    5. Practice Project: Simulating a Search Pattern
    6. Practice Project: Start Me Up!
    7. Practice Project: Shut Me Down!
    8. Challenge Project: True-Scale Simulation
    9. Challenge Project: The Real Apollo 8
  16. 7 SELECTING MARTIAN LANDING SITES
    1. How to Land on Mars
    2. The MOLA Map
    3. Project #10: Selecting Martian Landing Sites
    4. Summary
    5. Further Reading
    6. Practice Project: Confirming That Drawings Become Part of an Image
    7. Practice Project: Extracting an Elevation Profile
    8. Practice Project: Plotting in 3D
    9. Practice Project: Mixing Maps
    10. Challenge Project: Making It Three in a Row
    11. Challenge Project: Wrapping Rectangles
  17. 8 DETECTING DISTANT EXOPLANETS
    1. Transit Photometry
    2. Project #11: Simulating an Exoplanet Transit
    3. Project #12: Imaging Exoplanets
    4. Summary
    5. Further Reading
    6. Practice Project: Detecting Alien Megastructures
    7. Practice Project: Detecting Asteroid Transits
    8. Practice Project: Incorporating Limb Darkening
    9. Practice Project: Detecting Starspots
    10. Practice Project: Detecting an Alien Armada
    11. Practice Project: Detecting a Planet with a Moon
    12. Practice Project: Measuring the Length of an Exoplanet’s Day
    13. Challenge Project: Generating a Dynamic Light Curve
  18. 9 IDENTIFYING FRIEND OR FOE
    1. Detecting Faces in Photographs
    2. Project #13: Programming a Robot Sentry Gun
    3. Detecting Faces from a Video Stream
    4. Summary
    5. Further Reading
    6. Practice Project: Blurring Faces
    7. Challenge Project: Detecting Cat Faces
  19. 10 RESTRICTING ACCESS WITH FACE RECOGNITION
    1. Recognizing Faces with Local Binary Pattern Histograms
    2. Project #14: Restricting Access to the Alien Artifact
    3. Summary
    4. Further Reading
    5. Challenge Project: Adding a Password and Video Capture
    6. Challenge Project: Look-Alikes and Twins
    7. Challenge Project: Time Machine
  20. 11 CREATING AN INTERACTIVE ZOMBIE ESCAPE MAP
    1. Project #15: Visualizing Population Density with a Choropleth Map
    2. Summary
    3. Further Reading
    4. Challenge Project: Mapping US Population Change
  21. 12 ARE WE LIVING IN A COMPUTER SIMULATION?
    1. Project #16: Life, the Universe, and Yertle’s Pond
    2. Summary
    3. Further Reading
    4. Moving On
    5. Challenge Project: Finding a Safe Space
    6. Challenge Project: Here Comes the Sun
    7. Challenge Project: Seeing Through a Dog’s Eyes
    8. Challenge Project: Customized Word Search
    9. Challenge Project: Simplifying a Celebration Slideshow
    10. Challenge Project: What a Tangled Web We Weave
    11. Challenge Project: Go Tell It on the Mountain
  22. APPENDIX PRACTICE PROJECT SOLUTIONS
    1. Chapter 2: Attributing Authorship with Stylometry
    2. Chapter 4: Sending Super-Secret Messages with a Book Cipher
    3. Chapter 5: Finding Pluto
    4. Chapter 6: Winning the Moon Race with Apollo 8
    5. Chapter 7: Selecting Martian Landing Sites
    6. Chapter 8: Detecting Distant Exoplanets
    7. Chapter 9: Identifying Friend or Foe
    8. Chapter 10: Restricting Access with Face Recognition
  23. INDEX

Product information

  • Title: Real-World Python
  • Author(s): Lee Vaughan
  • Release date: November 2020
  • Publisher(s): No Starch Press
  • ISBN: 9781718500624