Get Programming
Learn to code with Python
Ana Bell
  • March 2018
  • ISBN 9781617293788
  • 456 pages
  • printed in black & white

Accessible and intuitive. After going through the many examples in the book, I felt much more confident in my Python programming skills.

Nicole Kogan, MIT

Get Programming: Learn to code with Python introduces you to the world of writing computer programs without drowning you in confusing jargon or theory that make getting started harder than it should be. Filled with practical examples and step-by-step lessons using the easy-on-the-brain Python language, this book will get you programming in no time!

This book works perfectly alongside Ana Bell's liveVideo course Get Programming with Python in Motion, featuring more projects and skills for you to pick up with this great language!

Listen to this book in liveAudio! liveAudio integrates a professional voice recording with the book’s text, graphics, code, and exercises in Manning’s exclusive liveBook online reader. Use the text to search and navigate the audio, or download the audio-only recording for portable offline listening. You can purchase or upgrade to liveAudio here or in liveBook.

About the Technology

Let's face it. The only way to learn computer programming is to do it. Whether you want to skill up for your next job interview or just get a few pet projects done, programming can be an amazing tool. This book is designed especially for beginners, helping them learn to program hands on, step by step, project by project. It's time to get programming!

About the book

Get Programming: Learn to code with Python teaches you the basics of computer programming using the Python language. In this exercise-driven book, you'll be doing something on nearly every page as you work through 38 compact lessons and 7 engaging capstone projects. By exploring the crystal-clear illustrations, exercises that check your understanding as you go, and tips for what to try next, you'll start thinking like a programmer in no time.

Table of Contents detailed table of contents

Front matter



about this book

Who should read this book

How this book is organized: a roadmap

About the code

Unit 0 : Python and Your Programming Environment

Lesson 1 Why Should You Learn How to Program?

1.1 Why Programming Matters

1.1.1 Programming is not just for Professionals

1.1.2 Improve your Life

1.1.3 Challenge Yourself

1.2 Where you are now and where you will be

1.3 Our Plan for Learning how to Program

1.3.1 First Steps

1.3.2 Practice, practice, practice, practice

1.3.3 Thinking like a programmer

1.4 Summary

Lesson 2 Basic Principles of Learning a Programming Language

2.1 Programming as a Skill

2.2 A Parallel with Baking

2.2.1 Understand the Task “bake a loaf of bread”

2.2.2 The Recipe

2.2.3 Visualizing the Recipe with Flowcharts

2.2.4 Use an Existing Recipe or Make One Up?

2.3 Think, Code, Test, Debug, Repeat

2.3.1 Understanding the Task

2.3.2 Visualizing the Task

2.3.3 Writing Pseudocode

2.4 Writing Readable Code

2.4.1 Using Descriptive and Meaningful Names

2.4.2 Commenting Your Code

2.5 Summary

2.6 Answers to Quick Checks

Unit 1: Variables, Types, Expressions, and Statements

Lesson 3 Introducing Python: A Programming Language

3.1 Installing Python

3.1.1 What is Python?

3.1.2 Downloading Python Version 3.5

3.1.3 Anaconda Python Distribution

3.1.4 Integrated Development Environments

3.2 Setting up your Workspace

3.2.1 The IPython Console

3.2.2 The File Editor

3.3 Summary

3.4 Answers to Quick Checks

Lesson 4 Variables and Expressions: Giving Names and Values to Things

4.1 Giving Names to Things

4.1.1 Math versus Programming

4.1.2 What the Computer Can and Cannot Do

4.2 Introducing Variables

4.2.1 Objects are Things that can be Manipulated

4.2.2 Objects have Names

4.2.3 What Object Names are Allowed?

4.2.4 Creating a Variable

4.2.5 Updating a Variable

4.3 Summary

4.4 Answers to Quick Checks

4.5 Answers to Summary Questions

Lesson 5 Object Types and Statements of Code

5.1 Types of Things

5.2 Basic Type of Objects in Programming

5.2.1 Integers as Whole Numbers

5.2.2 Floating Point as Decimal Numbers

5.2.3 Booleans as True/False Data

5.2.4 Strings as Sequences of Characters

5.2.5 The Absence of a Value

5.3 Working with Basic Types of Data Values

5.3.1 Building Blocks of Expressions

5.3.2 Converting Between Different Types

5.3.3 How Arithmetic Impacts Object Types

5.4 Summary

5.5 Answers to Quick Checks

Lesson 6 Capstone Project: Your First Python Program: Convert Hours to Minutes

6.1 Think-Code-Test-Debug

6.2 Divide your Task

6.3 Implement the Conversion Formula

6.3.1 How many Hours?

6.3.2 How many Minutes?

6.4 Your First Python Program: One Solution

6.5 Your First Python Program: Another Solution

6.6 Summary

6.7 Answers to Quick Checks

6.8 Answers to Summary Exercises

Unit 2: Strings, Tuples, and Interacting with the User

Lesson 7 Introducing String Objects: Sequences of Characters

7.1 Strings as Sequences of Characters

7.2 Basic Operations on Strings

7.2.1 Creating a string Object

7.2.2 Understanding Indexing into a String

7.2.3 Understanding Slicing a string

7.3 Other Operations on string Objects

7.3.1 Getting the Number of Characters in a String with len()

7.3.2 Converting Between Letter Cases with upper() and lower()

7.4 Summary

7.5 Answers to Quick Checks

Lesson 8 Advanced String Operations

8.1.1 Find a Specific Substring in a String with find()

8.1.2 Find out if a Substring is in the String with “in”

8.1.3 Count how Many Times a Substring Occurs with count()

8.1.4 Replacing Substrings with replace()

8.2 Mathematical Operations

8.3 Summary

8.4 Answers to Quick Checks

8.5 Answers to Summary Exercises

Lesson 9 Simple Error Messages

9.1 Reading Basic Error Messages

9.1.1 Type Up Statements and Try Things Out

9.1.2 String Error Messages

9.2 Summary

Lesson 10 Tuple Objects: Sequences of any Kind of Object

10.1 Tuples as Sequences of Data

10.1.1 Understanding the Tuple Object Representation

10.2 Understanding Operations on Tuples

10.2.1 Getting the tuple Length with len()

10.2.2 Indexing into and Slicing a tuple with []

10.2.3 Mathematical Operations

10.2.4 Swapping Objects Inside tuples

10.3 Summary

10.4 Answers to Quick Checks

10.5 Answers to Summary Exercises

Lesson 11 Interacting with the User

11.1 Showing Output

11.1.1 Printing Expressions

11.1.2 Printing Multiple Objects

11.2 Getting User Input

11.2.1 Prompting the User

11.2.2 Reading the Input

11.2.3 Storing the Input in a Variable

11.2.4 Converting the User Input to a Different Type

11.2.5 Asking for More Inputs

11.3 Summary

11.4 Answers to Quick Checks

11.5 Answers to Summary Exercises

Lesson 12 Capstone Project: Name Mashup

12.1 Understanding the Problem Statement

12.1.1 Drawing out a Sketch of the Problem

12.1.2 Coming up with a few Examples

12.1.3 Abstracting the Problem into Pseudocode

12.2 Splitting up First and Last Names

12.2.1 Finding the Space between the First and Last Name

12.2.2 Using Variables to Save Calculated Values

12.2.3 Testing what you have so Far

12.3 Storing the Halves of all Names

12.3.1 Finding the Midpoint of Names

12.4 Combining the Halves

12.5 Summary

Unit 3: Making Decisions in Your Programs

Lesson 13 Introducing Decisions in Programs

13.1 Making Decisions With Conditionals

13.1.1 Yes/No Questions and True/False Statements

13.1.2 Adding a Condition to a Statement

13.2 The Code to Make the Decision

13.2.1 Coding up a Decision — an Example

13.2.2 Coding up a Decision — a General Way

13.3 Structuring Your Programs

13.3.1 Making Many Decisions

13.3.2 Making Decisions Based on Other Decision's Outcomes

13.3.3 A More Complicated Example with Nested Conditionals

13.4 Summary

13.5 Answers to Quick Checks

13.6 Answers to Summary Questions

Lesson 14 Making More Complicated Decisions

14.1 Combining Multiple Conditions

14.1.1 Conditionals are Made up of True/False Expressions

14.1.2 Operator Precedence Rules

14.2 Choosing which Lines to Execute

14.2.1 Do this or that

14.2.2 Putting it All Together

14.2.3 Thinking in Terms of Code Blocks

14.3 Summary

14.4 Answers to Quick Checks

14.5 Answers to Summary Exercises

Lesson 15 Capstone Project: Choose Your Own Adventure

15.1 Outlining the Game Rules

15.2 Creating Different Paths

15.3 More Choices? Yes, Please!

15.4 Summary

Unit 4: Repeating Tasks

Lesson 16 Repeating Tasks with Loops

16.1 Repeating a Task

16.1.1 Adding Non-Linearity to Programs

16.1.2 Infinite Repetitions

16.2 Looping a Certain Number of Times

16.2.1 for Loops

16.3 Looping N Times

16.3.1 Loops over the Common Sequence 0 to N-1

16.3.2 Unrolling Loops

16.4 Summary

16.5 Answers to Quick Checks

16.6 Answers to Summary Exercises

Lesson 17 Customizing Loops

17.1 Customizing Loops

17.2 Looping Over Strings

17.3 Summary

17.4 Answers to Quick Checks

17.5 Answers to Summary Exercises

Lesson 18 Repeating Tasks while Conditions Hold

18.1 Looping While a Condition is True

18.1.1 Looping to Make a Guess

18.1.2 while Loops

18.1.3 Infinite Loop

18.2 for Loops vs while Loops

18.3 Manipulating Loops

18.3.1 Exiting Early out of a Loop

18.3.2 Going to the Beginning of a Loop

18.4 Checkpoint Exercises

18.5 Summary

18.6 Answers to Quick Checks

18.7 Answers to Summary Exercises

Lesson 19 Capstone Project: Scrabble, Art Edition

19.1 Understanding the Problem Statement

19.1.1 Change the Representation of all Valid Words

19.1.2 Making a Valid Word with the Given Tiles

19.2 Dividing Up your Code into Pieces

19.3 Summary

Unit 5: Organizing Your Code into Reusable Blocks

Lesson 20 Building Programs to Last

20.1 Breaking a Big Task into Smaller Tasks

20.1.1 Ordering an Item Online

20.1.2 Understanding the Main Points

20.2 Introducing Black Boxes of Code in Programming

20.2.1 Code Modules

20.2.2 Abstracting Code

20.2.3 Reusing Code

20.3 Subtasks Exist in their Own Environments

20.4 Summary

20.5 Answers to Quick Checks

20.6 Answers to Summary Exercises

Lesson 21 Achieving Modularity and Abstraction with Functions

21.1 Writing a Function

21.1.1 Function Basics: What the Function takes in

21.1.2 Function Basics: What the Function Does

21.1.3 Function Basics: What the Function Returns

21.2 Using Functions

21.2.1 Returning More than One Value

21.2.2 Functions without a return Statement

21.3 Documenting your Functions

21.4 Summary

21.5 Answers to Quick Checks

21.6 Answers to Summary Exercises

Lesson 22 Advanced Operations with Functions

22.1 Thinking about Functions with Two Different Hats

22.1.1 Writer Hat

22.1.2 User Hat

22.2 Function Scope

22.2.1 Simple Scoping Example

22.2.2 Scoping Rules

22.3 Nesting Functions

22.4 Passing Functions as Parameters

22.5 Returning a Function

22.6 Summary

22.7 Answers to Quick Checks

22.8 Answers to Summary Exercises

Lesson 23 Capstone Project: Analyze Your Friends

23.1 Reading a File

23.1.1 File Format

23.1.2 The Newline Character

23.1.3 Remove the Newline Character

23.1.4 Using Tuples to Store Information

23.1.5 What to Return

23.2 Sanitizing User Inputs

23.3 Testing and Debugging what you have so far

23.3.1 File Objects

23.3.2 Writing a Text File with Names and Phone Numbers

23.3.3 Opening Files for Reading

23.4 Reusing Functions

23.5 Analyze the Information

23.5.1 The Specification

23.5.2 Helper Functions

23.6 Summary

Unit 6: Working with Mutable Data Types

Lesson 24 Mutable and Immutable Objects

24.1 Immutable Objects

24.2 The Need for Mutability

24.3 Summary

24.4 Answers to Quick Checks

24.5 Answers to Summary Exercises

Lesson 25 Working with Lists

25.1 Lists vs. Tuples

25.2 Creating Lists and getting Elements at Specific Positions

25.3 Counting and getting Positions of Elements

25.4 Adding Items to Lists: append, insert, and extend

25.4.1 Using append

25.4.2 Using insert

25.4.3 Using extend

25.5 Removing Items from a List: pop

25.6 Changing an Element Value

25.7 Summary

25.8 Answers to Quick Checks

25.9 Answers to Summary Exercises

Lesson 26 Advanced Operations with Lists

26.1 Sorting and Reversing lists

26.2 Lists of lists

26.3 Converting a string to a list

26.4 Applications of Lists

26.4.1 Stacks

26.4.2 Queues

26.5 Summary

26.6 Answers to Quick Checks

26.7 Answers to Summary Exercises

Lesson 27 Dictionaries as Maps between Objects

27.1 Creating Dictionaries, Keys, and Values

27.2 Adding key-value Pairs to a Dictionary

27.2.1 Short Diversion into Restrictions on Keys

27.3 Removing key-value Pairs from a Dictionary

27.4 Getting all the Keys and Values in a Dictionary

27.4.1 No Ordering to Dictionary Pairs

27.5 Why Should You use a Dictionary?

27.5.1 Keeping Count with Frequency Dictionaries

27.5.2 Building Unconventional Dictionaries

27.6 Summary

27.7 Answers to Quick Checks

27.8 Answer to Summary Exercise

Lesson 28 Aliasing and Copying Lists and Dictionaries

28.1 Object Aliases

28.1.1 Aliases of Immutable Objects

28.1.2 Aliases of Mutable Objects

28.1.3 Mutable objects as Function Parameters

28.2 Making Copies of Mutable Objects

28.2.1 Commands to Copy Mutable Objects

28.2.2 Getting Copies of Sorted Lists

28.2.3 A Word of Caution when Iterating over Mutable Objects

28.2.4 Why does Aliasing Exist?

28.3 Summary

28.4 Answers to Quick Checks

28.5 Answers to Summary Exercises

Lesson 29 Capstone Project: Document Similarity

29.1 Breaking the Problem into Tasks

29.2 Reading File Information

29.3 Saving all Words from the File

29.4 Mapping words to their Frequency

29.5 Comparing two documents using a Similarity Score

29.6 Putting it all Together

29.7 One Possible Extension

29.8 Summary

Unit 7: Making Your Own Object Types by Using Object-Oriented Programming

Lesson 30 Making Your Own Object Types

30.1 Why do You Need New Object Types?

30.2 What Makes up an Object?

30.2.1 Object Properties

30.2.2 Object Behaviors

30.3 Using Dot Notation

30.4 Summary

30.5 Answers to Quick Checks

Lesson 31 Creating a Class for an Object Type

31.1 Implementing a New Object Type using a Class

31.2 Data Attributes as Object Properties

31.2.1 Initializing an Object with init

31.2.2 Creating an Object Property inside init

31.3 Methods as Object Operations and Behaviors

31.4 Using an Object Type you Defined

31.5 Creating a Class with Parameters in init

31.6 Dot Notation on a Class Name not an Object

31.7 Summary

31.8 Answers to Quick Checks

31.9 Answers to Summary Exercises

Lesson 32 Working with your own Object Types

32.1 Defining a Stack Object

32.1.1 Choosing Data Attributes

32.1.2 Implementing Methods

32.2 Using a Stack Object

32.2.1 Make a Stack of Pancakes

32.2.2 Make a Stack of Circles

32.3 Summary

32.4 Answers to Quick Checks

32.5 Answers to Summary Exercises

Lesson 33 Customizing Classes

33.1 Overriding a Special Method

33.2 Overriding print() to work with your Class

33.3 Behind the Scenes

33.4 What can you do with Classes?

33.4.1 Scheduling Events

33.5 Summary

33.6 Answers to Quick Checks

33.7 Answers to Summary Exercises

Lesson 34 Capstone Project: Card Game

34.1 Using Classes that already Exist

34.2 Detailing the Game Rules

34.3 Defining the Player Class

34.4 Defining the CardDeck Class

34.5 Simulate the Card Game

34.5.1 Setting up the Objects

34.5.2 Simulating Rounds in the Game

34.6 Modularity and Abstraction with Classes

34.7 Summary

Unit 8 Using Libraries to Enhance your Programs

Lesson 35 Useful Libraries

35.1 Importing Libraries

35.2 Doing mathematical operation with the math library

35.3 Random numbers with the random library

35.3.1 Randomizing Lists

35.3.2 Simulating Games of Chance

35.3.3 Replicating results using a seed

35.4 Timing programs with the time library

35.4.1 Using the clock

35.4.2 Pausing your program

35.5 Summary

35.6 Answers to Quick Checks

35.7 Answers to Summary Exercises

Lesson 36 Testing and Debugging your Programs

36.1 Working with the unittest library

36.2 Separating the program from the tests

36.2.1 Types of tests

36.3 Debugging your Code

36.3.1 Using Tools to Help you Step through Code

36.4 Summary

36.5 Answers to Quick Checks

36.6 Answers to Summary Exercises

Lesson 37 A Library for Graphical User Interfaces

37.1 A Library for Graphical User Interfaces

37.2 Setting up a Program using the tkinter library

37.3 Adding Widgets

37.4 Adding Event Handlers

37.5 Summary

37.6 Answers to Quick Checks

37.7 Answer to Summary Exercises

Lesson 38 Capstone Project: Game of Tag

38.1 Identifying the Parts to the Problem

38.2 Creating Two Shapes in a Window

38.3 Moving Shapes inside the Canvas

38.4 Detecting a Collision between Shapes

38.5 Possible Extensions

38.6 Summary


Appendix A: Appendix A Answers to lesson exercises

Appendix B: Appendix B Python Cheat Sheet

Appendix C: Appendix C Interesting Python Libraries

What's inside

  • Programming skills you can use in any language
  • Learn to code - no experience required
  • Learn Python, the language for beginners
  • Dozens of exercises and examples help you learn by doing

About the reader

No prior programming experience needed.

About the author

Ana Bell is an MIT lecturer and scientist who teaches the popular course, Introduction to Computer Science and Programming Using Python.

placing your order...

Don't refresh or navigate away from the page.
print book $20.99 $34.99 pBook + eBook + liveBook
Additional shipping charges may apply
Prints and ships within 3-5 days
Get Programming (print book) added to cart
continue shopping
go to cart

eBook $22.39 $27.99 3 formats + liveBook
Get Programming (eBook) added to cart
continue shopping
go to cart

Add liveAudio for only $15.99
Prices displayed in rupees will be charged in USD when you check out.
customers also reading

This book 1-hop 2-hops 3-hops

FREE domestic shipping on three or more pBooks