Learn AI-Assisted Python Programming with GitHub Copilot and ChatGPT (Leo Porter, Daniel Zingaro) (Z-Library)

Author: Leo Porter, Daniel Zingaro

非小说

Software is essential today. It’s hard to think of any industry where software isn’t changing practically everything about how work is done. Manufacturing needs software to monitor production and shipping, let alone the robots that increasingly perform the actual task. Advertising, politics, and fitness, among others, are awash in big data and they routinely use software to make sense of it. Video games and movies are created using software. We could go on and on, but you get the point. Writing computer programs in Python just got a lot easier! Use AI-assisted coding tools like GitHub Copilot and ChatGPT to turn your ideas into applications faster than ever. AI has changed the way we write computer programs. With tools like Copilot and ChatGPT, you can describe what you want in plain English, and watch your AI assistant generate the code right before your eyes. It’s perfect for beginners, or anyone who’s struggled with the steep learning curve of traditional programming. In Learn AI-Assisted Python Programming: With GitHub Copilot and ChatGPT you’ll learn how to: Write fun and useful Python applications—no programming experience required! Use the Copilot AI coding assistant to create Python programs Write prompts that tell Copilot exactly what to do Read Python code and understand what it does Test your programs to make sure they work the way you want them to Fix code with prompt engineering or human tweaks Apply Python creatively to help out on the job Learn AI-Assisted Python Programming: With GitHub Copilot and ChatGPT is a hands-on beginner’s guide that is written by two esteemed computer science university professors. It teaches you everything you need to start programming Python in an AI-first world. You’ll hit the ground running, writing prompts that tell your AI-assistant exactly what you want your programs to do. Along the way, you’ll pick up the essentials of Python programming and practice the higher-level thinking you’ll need to create ...

📄 File Format: PDF
💾 File Size: 8.7 MB
80
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
M A N N I N G Leo Porter ● Daniel Zingaro Foreword by Beth Simon, Ph.D. With GitHub Copilot and ChatGPT
📄 Page 2
The function design cycle with Copilot, augmented to include debugging
📄 Page 3
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: orders@manning.com © 2024 by Manning Publications Co. All rights Reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid- free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. ∞ Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 ISBN: 9781633437784 Printed in the United States of America The author and publisher have made every effort to ensure that the information in this book was correct at press time. The author and publisher do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause, or from any usage of the information herein. Development editor: Rebecca Johnson Technical editor: Peter Morgan Review editor: Dunja NikitoviÊ Production editor: Aleksandar DragosavljeviÊ Copy editor: Katie Petito Technical proofreader: Mark Thomas Typesetter: Tamara ŠveliÊ SabljiÊ Cover designer: Marija Tudor
📄 Page 4
Dan thanks his wife, Doyali, for trading some of their time, again, to help this book exist. Leo thanks his wife, Lori, and his children Sam and Avery for their love and support.
📄 Page 5
iv contents foreword ix acknowledgments xi introduction xiii about the authors xxii about the cover illustration xxiv 1 Introducing AI-assisted programming with Copilot 1 1.1 How we talk to computers 2 Making it a little easier 2 ■ Making it a lot easier 3 1.2 About the technology 3 Copilot, your AI Assistant 4 ■ How Copilot works behind the scenes—in 30 seconds 5 1.3 How Copilot changes how we learn to program 6 1.4 What else can Copilot do for us? 7 1.5 Risks and challenges when using Copilot 8 1.6 The skills we need 10 1.7 Societal concerns about AI code assistants like Copilot 11 Summary 12
📄 Page 6
vcontents 2 Getting started with Copilot 13 2.1 Time to set up your computer to start learning 14 Overview of the software in your programming environment 14 2.2 Getting your system set up 15 2.3 Working with Copilot in Visual Studio Code 16 Set up your working folder 17 ■ Check to see if your setup is working properly 18 2.4 Addressing common Copilot challenges 20 2.5 Our first programming problem 22 Showcasing Copilot’s value in a data processing task 23 Summary 32 3 Designing functions 33 3.1 Functions 34 The components of a function 35 ■ Using a function 37 3.2 Benefits of functions 38 3.3 Roles of functions 40 3.4 What’s a reasonable task for a function? 43 Attributes of good functions 43 ■ Examples of good (and bad) leaf functions 44 3.5 The cycle of design of functions with Copilot 45 3.6 Examples of creating good functions with Copilot 46 Dan’s stock pick 47 ■ Leo’s password 50 ■ Getting a strong password 54 ■ Scrabble scoring 55 ■ The best word 57 Summary 59 4 Reading Python code: Part 1 60 4.1 Why we need to read code 61 4.2 Asking Copilot to explain code 63 4.3 Top 10 programming features you need to know: Part 1 66 #1. Functions 67 ■ #2. Variables 67 ■ #3. Conditionals 69 #4. Strings 72 ■ #5. Lists 74 ■ Conclusion 76 Summary 77
📄 Page 7
vi contents 5 Reading Python code: Part 2 78 5.1 Top 10 programming features you need to know: Part 2 79 #6. Loops 79 ■ #7. Indentation 83 ■ #8. Dictionaries 90 #9. Files 91 ■ #10. Modules 94 Summary 98 6 Testing and prompt engineering 99 6.1 Why it is crucial to test code 99 6.2 Closed-box and open-box testing 100 Closed-box testing 101 ■ How do we know which test cases to use? 103 ■ Open-box testing 103 6.3 How to test your code 104 Testing using the Python prompt 105 ■ Testing in your Python file (we won’t be doing it this way) 105 ■ doctest 105 6.4 Revisiting the cycle of designing functions with Copilot 108 6.5 Full testing example 110 Finding the most students we can add to a row 110 ■ Improving the prompt to find a better solution 113 ■ Testing the new solution 114 6.6 Another full testing example—Testing with files 116 What tests should we run? 117 ■ Creating the function 120 Testing the function 120 ■ Common challenges with doctest 121 Summary 123 7 Problem decomposition 124 7.1 Problem decomposition 125 7.2 Small examples of top-down design 125 7.3 Authorship identification 127 7.4 Authorship identification using top-down design 129 7.5 Breaking down the process subproblem 130 Figuring out the signature for the mystery book 130 7.6 Summary of our top-down design 138
📄 Page 8
viicontents 7.7 Implementing our functions 138 clean_word 139 ■ average_word_length 140 ■ different_to_ total 142 ■ exactly_once_to_total 142 ■ split_string 144 get_sentences 146 ■ average_sentence_length 146 get_phrases 147 ■ average_sentence_complexity 147 make_signature 148 ■ get_all_signatures 149 get_score 152 ■ lowest_score 153 ■ process_data 154 make_guess 154 7.8 Going further 156 Summary 157 8 Debugging and better understanding your code 158 8.1 What causes errors (bugs)? 159 8.2 How to find the bug 160 Using print statements to learn about the code behavior 160 Using VS Code’s debugger to learn about the code behavior 162 8.3 How to fix a bug (once found) 169 Asking Copilot to fix your bug via chat 169 ■ Giving Copilot a new prompt for the whole function 171 ■ Giving Copilot a targeted prompt for part of a function 171 ■ Modifying the code to fix the bug yourself 172 8.4 Modifying our workflow in light of our new skills 173 8.5 Applying our debugging skills to a new problem 174 8.6 Using the debugger to better understand code 180 8.7 A caution about debugging 180 Summary 181 9 Automating tedious tasks 182 9.1 Why programmers make tools 183 9.2 How to use Copilot to write tools 184 9.3 Example 1: Cleaning up email text 184 Conversing with Copilot 185 ■ Writing the tool to clean up email 189 9.4 Example 2: Adding cover pages to PDF files 192 Conversing with Copilot 194 ■ Writing the tool 198
📄 Page 9
viii contents 9.5 Example 3: Merging phone picture libraries 206 Conversing with Copilot 208 ■ Top-down design 211 Writing the tool 212 Summary 215 10 Making some games 216 10.1 Game programs 217 10.2 Adding randomness 218 10.3 Example 1: Bulls and Cows 220 How the game works 220 ■ Top-down design 222 Parameters and return types 224 ■ Implementing our functions 226 ■ Adding a graphical interface for Bulls and Cows 233 10.4 Example 2: Bogart 234 How the game works 234 ■ Top-down design 236 Implementing our functions 240 Summary 247 11 Future directions 248 11.1 Prompt patterns 248 Flipped interaction pattern 250 ■ Persona pattern 253 11.2 Limitations and future directions 255 Where Copilot (currently) struggles 255 ■ Is Copilot a new programming language? 256 Summary 260 references 261 index 264
📄 Page 10
ix foreword It’s an awesome time to learn programming. Why? Let me use an analogy to explain. I like to make my own bread. I make it more frequently, and more reliably, when I use my stand mixer to knead the dough compared to kneading it by hand. Maybe you’d say that’s lazy. I’d say it makes me more productive and more likely to actually make the bread. Maybe you have something that makes your life easier by taking over a tedious task, leaving you free to focus on more important or interesting things. Do you have a car that supports you in parallel parking? I recall when Gmail added spell and grammar checks in languages other than English. My husband’s German relative were so excited that he was writing them longer emails—because the effort of remembering little-used German language specifics went away and allowed him to spend more time on the content! Sadly, until recently, when learning programming, you had no equivalent of a stand mixer or grammar check to support you. And there are lots of tedious things to learn and remember when you start programming. Good news! As of spring 2023, radically new and (we think) effective sup- port is finally here. You are about to learn programming with one of the most exciting human task supporters so far this century: artificial intelligence. Spe- cifically, this book seeks to support you in developing your ability to program in Python to solve computational problems more easily and faster by teaching you using a tool called GitHub Copilot. Copilot is a programming support tool that uses something called a LLM (large language model) to draw “help” from
📄 Page 11
x foreword a huge number of previously written programs. Once you learn how to direct it (sadly, it’s more complicated than effectively using a stand mixer), Copilot can dramatically increase your productivity and success in writing programs to solve your problem. But should you use Copilot? Are you really learning to program if you use it? Preliminary evidence looks positive—showing that students who learned with Copilot, when assigned a programming task to be done without the help of Copilot, did better than students who learned without Copilot (and also did the task without Copilot) [1]. That said, compared to what we used to teach in an introductory programming class, there are different skills you will need to focus on when programming with Copilot, specifically problem decomposition and debugging (it’s OK if you don’t know what those are). Just know, practicing programmers need to know those skills as well, but we previously weren’t able to teach them explicitly or effectively in introductory courses, because students didn’t have the brain space left for learning these “high-level skills” while focus- ing on nit-picky things like spelling and grammar (programming languages have these, just like real world languages). Leo and Dan are expert computing educators and researchers; the decisions that they’ve made to guide your learning in this book are grounded in what we know about teaching and learning programming. I’m excited that, with this book, they’re taking steps toward what the next wave of teaching programming will look like. So, congratulations! Whether you have never done any programming or whether you started to learn before and got frustrated… we think you will find learning to program with Copilot transformative and will allow you to engage your brain in more meaningful and “expert-like” programming experiences! —Beth Simon, Ph.D.
📄 Page 12
xi acknowledgments Writing a book about technology in flux was new for us. Each day of writing started with us reading the new articles, opinion pieces, and capabilities of LLMs. Early plans had to be scrapped or revised. New ideas presented them- selves for later chapters only after we’d written earlier chapters and had access to the latest LLM features. We thank the entire Manning Publications team for their agility and help throughout the process. In particular, we thank our Development Editor Rebecca Johnson for her expertise, wisdom, and support. Rebecca provided insightful feedback, constructive criticism, and creative suggestions that have greatly improved the quality and clarity of our work. Rebecca was supportive and encouraging and helped us manage book timelines and our busy schedules. Thank you, Rebecca—you went above and beyond for us. We also thank our Technical Editor Peter Morgan and our Technical Proof- reader Mark Thomas. Both offered valuable contributions to the quality of the book. To all the reviewers: Aishvarya Verma, Andrew Freed, Andy Wiesendanger, Beth Simon, Brent Honadel, Cairo Cananea, Frank Thomas-Hockey, Ganesh Falak, Ganesh Swaminathan, Georgerobert Freeman, Hariskumar Panakmal, Hendrica van Emde Boas, Ildar Akhmetov, Jean-Baptiste Bang Nteme, Kalai C. E. Nathan, Max Fowler, Maya Lea-Langton, Mikael Dautrey, Monica Popa, Nata- sha Chong, Ozren Harlovic, Pedro Antonio Ibarra Facio, Radhakrishna Anil,
📄 Page 13
xii acknowledgments Snehal Bobade, Srihari Sridharan, Tan Wee, Tony Holdroyd, Wei Luo, Wondi Wolde, your suggestions helped make this a better book. We thank our colleagues for supporting our work and offering their ideas for what such a book should attempt to do. Many of their ideas have informed our thinking as we sought to redefine what an introductory programming course looks like. We particularly thank Brett Becker, Michelle Craig, Paul Denny, Bill Griswold, Philip Guo, and Gerald Soosai Raj.
📄 Page 14
xiii introduction Software is essential today. It’s hard to think of any industry where software isn’t changing practically everything about how work is done. Manufacturing needs software to monitor production and shipping, let alone the robots that increasingly perform the actual task. Advertising, politics, and fitness, among others, are awash in big data and they routinely use software to make sense of it. Video games and movies are created using software. We could go on and on, but you get the point. The result has been that more people than ever want to learn how to pro- gram. We’re not just talking about the computer science, computer engi- neering, and data science majors at universities who have been in a perpetual “enrollment crisis” for the past decade. We’re also talking about the scientist who needs to write software to evaluate their data, the office worker who wants to automate some of their tedious data processing tasks, and the hobbyist who wants to create a fun video game for their friends. Despite the desire to learn programming, there are decades of research in our field (computing education) that have identified many reasons for why learning to write software is hard. Even after you figure out how to solve the problem, you have to tell a machine how to accomplish it in a programming language whose rules are unforgiving. Granted, writing programs in a language like Python is substantially easier than in machine code using punch cards, but it’s still hard. We know it’s hard because we’ve seen the failure rates of intro- ductory computer science courses. We’ve seen first-hand as we’ve watched
📄 Page 15
xiv introduction motivated and intelligent students fail our courses, sometimes multiple times, before they succeed or, worse, give up. But what if we could talk to computers in a better way? A way that doesn’t require us to know all the detailed syntax rules that trip up most novices. That era has just begun thanks to AI assistants like Copilot that offer intelligent code suggestions in the same way ChatGPT can write reasonable text when prompted. This book is for everyone who wants to learn how to write software in the AI assistant era. We’re excited to be on your learning journey with you. AI assistants change how programming is done We’ll introduce you to your AI assistant, Copilot, in chapter 1, but we want to give you a brief overview now. If you read the news headlines or even opinion pieces by lauded software engineering professionals talking about Copilot or ChatGPT, you’ve seen that opinions run the gamut. Some people say that AI assistants mean the end of all programming jobs. Others say that AI assistants are so hopelessly flawed you are better without them. These views of the world are at such extremes that it’s easy to poke holes in either argument. AI assis- tants learn from existing code, so if some new tool/technology is developed, humans will need to write the bulk of the initial code. As a recent article well expressed, there isn’t a lot (or any) code out there for quantum computers since they are still in their infancy [1]. So human programmers aren’t going away, at least not any time soon. At the same time, in our time working with Copilot, we’ve seen how powerful it is. Both of us have written software for decades and Copilot can often give us correct code much faster than we could write it on our own. To ignore such a powerful tool seems analogous to a car- penter refusing to use power tools. As educators, the opportunity to help people learn to write software is instantly apparent. Why should students spend so much time fighting with syn- tax when writing code from scratch when the code suggested by an AI assistant is almost always syntactically correct? Why should students have to reach out to professors, instructional staff, friends, or internet forums for help explaining what a section of code is doing when AI assistants are really good at explaining code (particularly for questions asked by novices)? And if AI assistants often write correct code when solving common programming problems (by learn- ing from huge volumes of code written in the past), why shouldn’t students be using it to help them program? Be warned that this doesn’t mean that writing software is now just easy and that we can entirely offload the skill of programming onto the AI. Instead, the skills to write good software are evolving. Skills like problem decomposition, code specification, code reading, and code testing have become even more
📄 Page 16
xvintroduction important than they were in the past; skills like knowing library semantics and syntax become less important. We’ll say more about this in the next chapters, but this book will teach you the skills that matter going forward. These skills will be valuable whether you dabble in writing software from time to time or you are starting a career in software engineering. Audience We have two primary audiences for the book. The first is everyone who has thought about writing software (and even tried and failed before) to make their lives better in some way. This includes the accountant who gets frustrated that their software can’t do what they want so they are left solving problems by hand. Or scientists who want to analyze their data quickly, but existing tools aren’t capable of doing what they want. We also imagine the office manager who feels limited by what their spreadsheet software can do and wants a better way to gain insight from their data. Additionally, we imagine the exec at a small company who wants to be notified when something is said publicly on social media about their company but can’t afford to pay a software engineering team to write the tool for them. And we imagine the hobbyist of any age who just wants to write software for fun—whether it be for making their own small video games, storytelling with pictures, or creating fun family photo collages. These are just some of the people who want to write software to improve some element of their professional or personal lives. The second is the student who is considering a career in software engineer- ing or programming and wants to learn how to write software. They want to learn the basics and start creating interesting software, without the trappings of a classic computer science class. Certainly, there will be more courses or books that will follow this first book on the road to becoming a professional software developer, but this will hopefully be a fun and rewarding first step. What we expect from you This book requires no background whatsoever in programming. If you learned some programming and forgotten or it didn’t go well the first time, we think this is a great place to resume your learning. This book does require basic computer literacy. This means you should be comfortable installing software, copying files between folders, and opening files on your computer. If you don’t have those skills, you could still start this book, but realize there may be moments when you need to look to outside resources (e.g., YouTube videos on how to copy a file from one folder to another).
📄 Page 17
xvi introduction You’ll also need a computer where you have permission to install software so you can follow along and apply the ideas we’re learning. Any Windows, Mac, or Linux personal computer or laptop will work. What you will be able to do after reading this book In this book, we’re going to teach you how to use Copilot to write Python code. We’ll teach you how to identify whether that code does what you want, and what to do when it doesn’t. We’ll teach you enough about Python to be able to read it for a general understanding of what it does and whether it is doing something potentially meaningful. We won’t, however, teach you how to program in Python entirely from scratch. You’ll be in a good position to learn to do that with other resources fol- lowing this book if you like—but for many tasks, as we will show you, it may not be necessary. We don’t know exactly what it will look like to be a professional programmer or software engineer in light of AI coding assistants. That role is already chang- ing and will change further as the AI technology improves. For now, we will say that you need more than this book to be a professional programmer or software engineer. You’ll need to know a great deal more about Python and other com- puter science topics to get there. The good news is that learning how to program using Copilot will make you capable of writing basic software to address common needs. The software will be more complex than what we typically teach in an introductory course, and you’ll be able to write these useful programs without banging your head on syn- tax or spending months learning just Python. If you wish to continue learning about writing professional software, this will be your first step toward mastery. By the end of this book, you will be able to write basic software capable of data analysis, automating repetitive tasks, and creating simple games, among many others. The challenge in working with AI assistants We expect you’re ready to jump into a technology that is maturing and chang- ing quickly. What you see from Copilot may not match what you see in the book. Copilot is advancing and changing daily, and we cannot possibly keep up to the minute with such a moving target. More than that, Copilot is nondeterministic, which means that if you ask it to solve the same task multiple times, it may not give you the same code each time. And sometimes you’ll get correct code for a task, but then if you ask again, you get code that is not correct. So even if you use the exact same prompts we do, you will likely see different code responses than we do. Much of this book is devoted to ensuring you learn how to determine
📄 Page 18
xviiintroduction whether the answer from Copilot is right or not and, if it isn’t, how to fix it. In short, we hope you’re ready for what it means to learn on the leading edge of technology. Why we wrote this book Both of us have been professors for over a decade and programmers for a decade longer than that. Our care for our students’ success led us to become researchers studying how students learn computing and how to improve their outcomes. Between the two of us, we’ve written nearly a hundred articles in our field exploring pedagogies, student beliefs, and assessments—all with the goal of improving the student experience. We’ve also had students in our office hours who struggled to learn how to program, even when we are employing best practices in teaching computing. These are intelligent students who want to learn, but who are tripped up on some part of the programming process. The programming process has many steps, from understanding a problem, to coming up with a solution, to impart- ing the process of solving the problem to a computer. So, when we began work- ing with AI assistants, specifically Copilot, we instantly saw how it could be a game changer for students, particularly in improving that last step “imparting the process of solving the problem to a computer”. We want our students to suc- ceed. We want you to succeed. And we believe AI assistants can help. Warning: beware of elitism One of the saddest things we see in our classes at our universities is students intimidating other students. We’ve heard students in our introductory Python programming courses try to show off how they already learned to program in such-and-such programming language and the affect that has on the other stu- dents in the course. Although we try to gently point these students to other, more appropriate courses, we’ve also seen that the students bragging in this way are often the students struggling to pass at the end of the term, hav- ing vastly over-estimated their proficiency at the start. And it doesn’t take a licensed psychologist to see that this kind of posturing comes from a place of low self-esteem. Beyond students in our introductory courses, we see how different kinds of programmers treat each other and their respective fields. For example, Human-Computer Interaction (HCI) professionals study how to improve the design of software to make it better for its human users. Sounds important, right? Unfortunately, that field was put down by computer scientists as merely “applied psychology” for years, and then major companies showed that maybe, just maybe, if you care about the users of your technology, those people might
📄 Page 19
xviii introduction just appreciate it more and be inclined to buy it. It’s not surprising that HCI quickly became mainstream in computer science. This snobbery isn’t limited to specific fields. We even see it occurring between programmers of different languages. For example, we’ve seen C++ (one programming language) pro- grammers say silly things like JavaScript (another programming language) pro- gramming isn’t real programming. (It definitely is real programming, whatever that might mean!) All of this, in our opinion, is unproductive and unfortunate posturing that pushes people away from the field. A comic we both enjoy called XKCD, cap- tured the ludicrousness of this posturing well in “Real Programmers” [2]. In the comic, programmers argue about what the best text editor app is for pro- gramming. Programmers need to use a text editor to enter their code, which is exactly what you’ll start doing in chapter 2. There’s been a long-standing, and mostly unserious, debate over the best editors (“emacs” is one of many editors). The comic is making light of the meaninglessness of the debate in a truly clever way. The reason we’re talking about this unfortunate aspect of our field is we know what some people will say about learning to program with Copilot. They’ll say that to learn to write software, you have to learn how to write code entirely from scratch. And for future professional engineers, we actually agree that at some point in your career, you should learn to write code from scratch. But, for most people and even people starting their studies in software engineering, we wholeheartedly disagree that writing code entirely from scratch makes sense anymore as a starting place. So, if someone criticizes you for doing something to make yourself or your life or the world better, we encourage you to look to the immortal wisdom of Taylor Swift and just “Shake it off”. How this book is organized: a roadmap This book is divided into 11 chapters. We recommend that you read this book from beginning to end, rather than skipping around. That’s because most chapters introduce skills that will be assumed in later chapters: ¡ Chapter 1 describes what AI code assistants are, how they work, and why they are irrevocably changing how programming is done. It also explores the concerns we need to keep in mind when using AI coding assistants. ¡ Chapter 2 helps you set up your computer to be able to program with GitHub Copilot (that’s your AI coding assistant) and Python (that’s the programming language we’ll use). Once your computer is set up, we’ll use Copilot in our first programming example: doing some analysis on freely available sports data.
📄 Page 20
xixintroduction ¡ Chapter 3 teaches you all about functions, which help you organize your code and make it easier for Copilot to write code for you. It also uses many examples to demonstrate the general workflow we’ll use in order to be productive with Copilot. ¡ Chapter 4 is the first of two chapters that teaches you how to read Python code. It’s true that Copilot will be writing code for you, but you need to be able to read that code to help you determine whether that code is going to do what you want. And don’t worry: Copilot can help you read code, too! ¡ Chapter 5 is the second of two chapters that teaches you how to read Python code. ¡ Chapter 6 is a primer on two critical skills that you need to hone when working with AI coding assistants: testing and prompt engineering. Test- ing involves checking that your code operates correctly; prompt engi- neering involves changing the words you use in order to communicate more effectively with your AI assistant. ¡ Chapter 7 is all about breaking large problems down into smaller prob- lems that are easier for Copilot to handle. The technique is called top- down design, and in this chapter, you’ll use it to design a complete program to identify the author of mystery books. ¡ Chapter 8 is a deep dive into bugs (errors in your code!), how to find them, and how to fix them. You’ll learn how to step line by line through your code to pinpoint exactly what’s going wrong and even how to ask Copilot to help you fix bugs. ¡ Chapter 9 puts Copilot to work to help you automate tedious tasks. You’ll see three examples—cleaning up emails that have been forwarded many times, adding cover pages to hundreds of PDF files, and removing dupli- cate images—and you’ll be able to apply the principles to your own spe- cific tasks as well. ¡ Chapter 10 shows you how to use Copilot to write computer games. You’ll use the skills you developed throughout the book to write two games: a logic game similar to Wordle, and a two-player, press-your-luck board game. ¡ Chapter 11 delves into the fledgling field of prompt patterns, which are tools to help you get even more out of your AI assistant. It also summarizes the current limitations of AI coding assistants and looks at what may be on the horizon.
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List