liveBook · Manning

What you will learn in Learn AI-Assisted Python Programming, Second Edition

With GitHub Copilot and ChatGPT

by Leo Porter and Daniel Zingaro
Foreword by Beth Simon

Chapter by chapter

Chapter 1: Introducing AI-assisted programming with GitHub Copilot

1.1 Improving how we talk to computers · 1.1.1 Making it a little easier · 1.1.2 Making it a lot easier · 1.2 About the technology · 1.2.1 Python, your programming language · 1.2.2 GitHub Copilot, your AI assistant · 1.2.3 How Copilot works behind the scenes—in 30 seconds · 1.3 How Copilot changes how we learn to program · 1.4 What else can Copilot do for us? · 1.5 Risks and challenges when using Copilot · 1.6 The skills we need · 1.7 Societal concerns about AI code assistants like Copilot · 1.8 Summary

What you learn in chapter 1 →

Chapter 2: Getting started with Copilot

2.1 Setting up your computer to start learning · 2.2 The software we’ll be using · 2.2.1 Python · 2.2.2 Visual Studio Code · 2.2.3 GitHub account · 2.3 Getting your system set up: Part 1 · 2.4 Working with Python in Visual Studio Code · 2.4.1 Set up your working folder · 2.4.2 Check to see if your setup is working properly · 2.5 Writing and running some small programs · 2.6 Getting your system set up: Part 2 · 2.6.1 Check to see if Copilot is working properly · 2.7 Addressing common Copilot challenges · 2.8 Our path forward · 2.8.1 How we’ll be working with Copilot throughout the book · 2.8.2 Showcasing Copilot’s value in a data processing task · 2.9 Summary

What you learn in chapter 2 →

Chapter 3: Designing functions

3.1 Functions · 3.1.1 The components of a function · 3.1.2 Using a function · 3.2 The design cycle of functions with Copilot · 3.3 Examples of creating good functions with Copilot · 3.3.1 Dan’s stock pick · 3.3.2 Leo’s password · 3.3.3 Getting a strong password · 3.3.4 Scrabble scoring · 3.3.5 The best word · 3.4 Benefits of functions · 3.5 Roles of functions · 3.6 What’s a reasonable task for a function? · 3.6.1 Attributes of good functions · 3.6.2 Examples of good (and bad) leaf functions · 3.7 Exercises · 3.8 Summary

What you learn in chapter 3 →

Chapter 4: Reading Python code: Part 1

4.1 Why we need to read code · 4.2 Asking Copilot to explain code · 4.3 Top 10 programming features you need to know: Part 1 · 4.3.1 #1. Functions · 4.3.2 #2. Variables · 4.3.3 #3. Conditionals · 4.3.4 #4. Strings · 4.3.5 #5. Lists · 4.4 Exercises · 4.5 Summary

What you learn in chapter 4 →

Chapter 5: Reading Python code: Part 2

5.1 Top 10 programming features you need to know: Part 2 · 5.1.1 #6. Loops · 5.1.2 #7. Indentation · 5.1.3 #8. Dictionaries · 5.1.4 #9. Files · 5.1.5 #10. Modules · 5.2 Exercises · 5.3 Summary

What you learn in chapter 5 →

Chapter 6: Testing and prompt engineering

6.1 Why it’s crucial to test code · 6.2 Closed-box and open-box testing · 6.2.1 Closed-box testing · 6.2.2 How do we know which test cases to use? · 6.2.3 Open-box testing · 6.3 How to test your code · 6.3.1 Testing using the Python prompt · 6.3.2 Testing in your Python file (we won’t be doing it this way) · 6.3.3 doctest · 6.4 Revisiting the cycle of designing functions with Copilot · 6.5 Full testing example · 6.5.1 Finding the most students we can add to a row · 6.5.2 Improving the prompt to find a better solution · 6.5.3 Testing the new solution · 6.6 Another full testing example: Testing with files · 6.6.1 What tests should we run? · 6.6.2 Creating the function · 6.6.3 Testing the function · 6.6.4 Common challenges with doctest · 6.7 Exercises · 6.8 Summary

What you learn in chapter 6 →

Chapter 7: Problem decomposition

7.1 Problem decomposition · 7.2 Small examples of top-down design · 7.3 Spelling suggestions · 7.4 Spelling suggestions using top-down design · 7.5 Breaking down the process subproblem · 7.5.1 Getting the list of words from the word list file · 7.5.2 Generating the list of all possible words · 7.5.3 Generating the list of all real words · 7.6 Summary of our top-down design · 7.7 Implementing our functions · 7.7.1 create_word_list · 7.7.2 add_letter · 7.7.3 delete_letter · 7.7.4 change_letter · 7.7.5 all_possible_words · 7.7.6 all_real_words · 7.7.7 get_spelling_suggestions · 7.7.8 spell_check · 7.8 Exercises · 7.9 Summary

What you learn in chapter 7 →

Chapter 8: Debugging and better understanding your code

8.1 What causes errors (bugs)? · 8.2 How to find the bug · 8.2.1 Using print statements to learn about the code behavior · 8.2.2 Using VS Code’s debugger to learn about the code behavior · 8.3 How to fix a bug (once found) · 8.3.1 Asking Copilot to fix your bug via Copilot Chat · 8.3.2 Giving Copilot a new prompt for the whole function · 8.3.3 Giving Copilot a targeted prompt for part of a function · 8.3.4 Modifying the code to fix the bug yourself · 8.4 Modifying our workflow in light of our new skills · 8.5 Applying our debugging skills to a new problem · 8.6 Using the debugger to better understand code · 8.7 A caution about debugging · 8.8 Exercises · 8.9 Summary

What you learn in chapter 8 →

Chapter 9: Automating tedious tasks

9.1 Why programmers make tools · 9.2 How to use Copilot to write tools · 9.3 Example 1: Cleaning up email text · 9.3.1 Conversing with Copilot · 9.3.2 Writing the tool to clean up email · 9.4 Example 2: Adding cover pages to PDF files · 9.4.1 Conversing with Copilot · 9.4.2 Writing the tool · 9.5 Example 3: Merging phone picture libraries · 9.5.1 Conversing with Copilot · 9.5.2 Top-down design · 9.5.3 Writing the tool · 9.6 Exercises · 9.7 Summary

What you learn in chapter 9 →

Chapter 10: Making some games

10.1 Game programs · 10.2 Adding randomness · 10.3 Example 1: Bulls and Cows · 10.3.1 How the game works · 10.3.2 Top-down design · 10.3.3 Parameters and return types · 10.3.4 Implementing our functions · 10.3.5 Adding a graphical interface for Bulls and Cows · 10.4 Example 2: Bogart · 10.4.1 How the game works · 10.4.2 Top-down design · 10.4.3 Implementing our functions · 10.5 Exercises · 10.6 Summary

What you learn in chapter 10 →

Chapter 11: Creating an authorship identification program

11.1 Authorship identification · 11.2 Authorship identification using top-down design · 11.3 Breaking down the process subproblem · 11.3.1 Figuring out the signature for the mystery book · 11.4 Summary of our top-down design · 11.5 Implementing our functions · 11.5.1 clean_word · 11.5.2 average_word_length · 11.5.3 different_to_total · 11.5.4 exactly_once_to_total · 11.5.5 split_string · 11.5.6 get_sentences · 11.5.7 average_sentence_length · 11.5.8 get_phrases · 11.5.9 average_sentence_complexity · 11.5.10 make_signature · 11.5.11 get_all_signatures · 11.5.12 get_score · 11.5.13 lowest_score · 11.5.14 process_data · 11.5.15 make_guess · 11.6 Going further · 11.7 Exercises · 11.8 Summary

What you learn in chapter 11 →

Chapter 12: Future directions

12.1 Prompt patterns · 12.1.1 Flipped interaction pattern · 12.1.2 Persona pattern · 12.2 Limitations and future directions · 12.2.1 Where Copilot (currently) struggles · 12.2.2 Is Copilot a new programming language? · 12.3 Exercises · 12.4 Summary

What you learn in chapter 12 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.