Learn to Program, 3rd Edition

Book description

It's easier to learn how to program a computer than it has ever been before. Now everyone can learn to write programs for themselves - no previous experience is necessary. Chris Pine takes a thorough, but lighthearted approach that teaches you the fundamentals of computer programming, with a minimum of fuss or bother. Whether you are interested in a new hobby or a new career, this book is your doorway into the world of programming.

Computers are everywhere, and being able to program them is more important than it has ever been. But since most books on programming are written for other programmers, it can be hard to break in.

At least it used to be. Chris Pine will teach you how to program. You'll learn to use your computer better, to get it to do what you want it to do. Starting with small, simple one-line programs to calculate your age in seconds, you'll see how to write interactive programs, to use APIs to fetch live data from the internet, to rename your photos from your digital camera, and more. You'll learn the same technology used to drive modern dynamic websites and large, professional applications.

Whether you are looking for a fun new hobby or are interested in entering the tech world as a professional, this book gives you a solid foundation in programming. Chris teaches the basics, but also shows you how to think like a programmer. You'll learn through tons of examples, and through programming challenges throughout the book. When you finish, you'll know how and where to learn more - you'll be on your way.

What You Need:

All you need to learn how to program is a computer (Windows, macOS, or Linux) and an internet connection. Chris Pine will lead you through setting set up with the software you will need to start writing programs of your own.

Publisher resources

View/Submit Errata

Table of contents

  1.  Acknowledgments
  2.  Preface to the Third Edition
    1. What’s New in This Edition
  3.  Introduction
    1. What Is Programming?
    2. Programming Languages
    3. Installation and Setup
    4. The Art of Programming
  4. 1. Numbers
    1. Printing to the Screen
    2. Integers and Floats
    3. Simple Arithmetic
    4. Progress Checkpoint
  5. 2. Letters
    1. String Arithmetic
    2. Numbers vs. Digits
    3. When Bad Things Happen to Good Programs
    4. Progress Checkpoint
  6. 3. Variables and Assignment
    1. Variables Point to Values
    2. Progress Checkpoint
  7. 4. Conversions and Input
    1. Numbers to Strings and Back Again
    2. Let Me Tell You a Secret
    3. Getting Strings from the User
    4. Cleaning Up User Input
    5. Good Variable Names
    6. Progress Checkpoint
  8. 5. Methods
    1. Fancy String Methods
    2. More Arithmetic
    3. Random Numbers
    4. The Math Object
    5. Progress Checkpoint
  9. 6. Flow Control
    1. Comparison Methods
    2. Branching
    3. Looping
    4. A Little Bit of Logic
    5. Progress Checkpoint
  10. 7. Arrays and Iterators
    1. My First Iterator
    2. More Array Methods
    3. Progress Checkpoint
  11. 8. Custom Methods
    1. Method Arguments: What Goes In
    2. Local Variables: What’s Inside
    3. Experiment: Stuby
    4. Return Values: What Comes Out
    5. Progress Checkpoint
  12. 9. File Input and Output
    1. Really Doing Something
    2. The Thing about Computers
    3. Saving and Loading for Grown-Ups
    4. JSON
    5. Back to Our Regularly Scheduled Programming
    6. Renaming Photos
    7. Progress Checkpoint
  13. 10. More Classes and Methods
    1. The Time Class
    2. The Hash Class
    3. The Range Class
    4. Stringy Superpowers
    5. Classes and the Class Class
    6. Progress Checkpoint
  14. 11. Custom Classes and Class Extensions
    1. Creating Classes
    2. Instance Variables
    3. Methods: new vs. initialize
    4. The Care and Feeding of Your Baby Dragon
    5. Progress Checkpoint
  15. 12. Remote Data and APIs
    1. Random Internet Jokes
    2. Respect
    3. Trivia Database
    4. Location of the ISS
    5. Where Did I Put My Keys?
    6. Movie Search
    7. Progress Checkpoint
  16. 13. Blocks and Procs
    1. Methods That Take Procs
    2. Methods That Return Procs
    3. Passing Blocks (Not Procs) into Methods
    4. Progress Checkpoint
  17. 14. The Magic of Recursion
    1. A Method So Easy, It Calls Itself
    2. Rite of Passage: Sorting
    3. Progress Checkpoint
  18. 15. Beyond This Book
    1. Interactive Ruby (irb)
    2. The PickAxe: Programming Ruby
    3. Ruby-Doc.org
    4. Online Search
    5. Stack Overflow
    6. Tim Toady
    7. You Did It
  19. A1. Installation and Setup on Windows
  20. A2. Installation and Setup on macOS
  21. A3. Installation and Setup on Linux
  22. A4. A Few Things to Try: Possible Solutions
    1. Exercises from Chapter 1
    2. Exercises from Chapter 2
    3. Exercises from Chapter 3
    4. Exercises from Chapter 4
    5. Exercises from Chapter 5
    6. Exercises from Chapter 6
    7. Exercises from Chapter 7
    8. Exercises from Chapter 8
    9. Exercises from Chapter 9
    10. Exercises from Chapter 10
    11. Exercises from Chapter 11
    12. Exercises from Chapter 12
    13. Exercises from Chapter 13
    14. Exercises from Chapter 14

Product information

  • Title: Learn to Program, 3rd Edition
  • Author(s): Chris Pine
  • Release date: June 2021
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781680508178