Learn AI-assisted Python Programming: With GitHub Copilot and ChatGPT

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

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 working apps for data analysis, automating tedious tasks, and even video games. Foreword by Beth Simon, Ph.D. About the technology The way people write computer programs has changed forever. Using GitHub Copilot, you describe in plain English what you want your program to do, and the AI generates it instantly. About the book This book shows you how to create and improve Python programs using AI—even if you’ve never written a line of computer code before. Spend less time on the slow, low-level programming details and instead learn how an AI assistant can bring your ideas to life immediately. As you go, you’ll even learn enough of the Python language to understand and improve what your AI assistant creates. What's inside • Prompts for working code • Tweak code manually and with AI help • AI-test your programs • Let AI handle tedious details About the reader If you can move files around on your computer and install new programs, you can learn to write useful software! About the author Dr. Leo Porter is a Teaching Professor at UC San Diego. Dr. Daniel Zingaro is an Associate Teaching Professor at the University of Toronto. The technical editor on this book was Peter Morgan.

Author(s): Leo Porter, Daniel Zingaro
Edition: 1
Publisher: Manning Publications
Year: 2023

Language: English
Commentary: Publisher's PDF
Pages: 296
City: Shelter Island, NY
Tags: Programming; Debugging; Python; Automation; Testing; Elementary; ChatGPT; GitHub Copilot; Prompt Engineering

Learn AI-Assisted Python Programming
dedication
contents
foreword
acknowledgments
introduction
AI assistants change how programming is done
Audience
What we expect from you
What you will be able to do after reading this book
The challenge in working with AI assistants
Why we wrote this book
Warning: beware of elitism
How this book is organized: a roadmap
Source code downloads
Software/hardware requirements
liveBook discussion forum
about the authors
about the cover illustration
1 Introducing AI-assisted programming with Copilot
How we talk to computers
Making it a little easier
Making it a lot easier
About the technology
Copilot, your AI Assistant
How Copilot works behind the scenes—in 30 seconds
How Copilot changes how we learn to program
What else can Copilot do for us?
Risks and challenges when using Copilot
The skills we need
Societal concerns about AI code assistants like Copilot
Summary
2 Getting started with Copilot
Time to set up your computer to start learning
Overview of the software in your programming environment
Getting your system set up
Working with Copilot in Visual Studio Code
Set up your working folder
Check to see if your setup is working properly
Addressing common Copilot challenges
Our first programming problem
Showcasing Copilot’s value in a data processing task
Summary
3 Designing functions
Functions
The components of a function
Using a function
Benefits of functions
Roles of functions
What’s a reasonable task for a function?
Attributes of good functions
Examples of good (and bad) leaf functions
The cycle of design of functions with Copilot
Examples of creating good functions with Copilot
Dan’s stock pick
Leo’s password
Getting a strong password
Scrabble scoring
The best word
Summary
4 Reading Python code: Part 1
Why we need to read code
Asking Copilot to explain code
Top 10 programming features you need to know: Part 1
#1. Functions
#2. Variables
#3. Conditionals
#4. Strings
#5. Lists
Conclusion
Summary
5 Reading Python code: Part 2
Top 10 programming features you need to know: Part 2
#6. Loops
#7. Indentation
#8. Dictionaries
#9. Files
#10. Modules
Summary
6 Testing and prompt engineering
Why it is crucial to test code
Closed-box and open-box testing
Closed-box testing
How do we know which test cases to use?
Open-box testing
How to test your code
Testing using the Python prompt
Testing in your Python file (we won’t be doing it this way)
doctest
Revisiting the cycle of designing functions with Copilot
Full testing example
Finding the most students we can add to a row
Improving the prompt to find a better solution
Testing the new solution
Another full testing example—Testing with files
What tests should we run?
Creating the function
Testing the function
Common challenges with doctest
Summary
7 Problem decomposition
Problem decomposition
Small examples of top-down design
Authorship identification
Authorship identification using top-down design
Breaking down the process subproblem
Figuring out the signature for the mystery book
Summary of our top-down design
Implementing our functions
clean_word
average_word_length
different_to_total
exactly_once_to_total
split_string
get_sentences
average_sentence_length
get_phrases
average_sentence_complexity
make_signature
get_all_signatures
get_score
lowest_score
process_data
make_guess
Going further
Summary
8 Debugging and better understanding your code
What causes errors (bugs)?
How to find the bug
Using print statements to learn about the code behavior
Using VS Code’s debugger to learn about the code behavior
How to fix a bug (once found)
Asking Copilot to fix your bug via chat
Giving Copilot a new prompt for the whole function
Giving Copilot a targeted prompt for part of a function
Modifying the code to fix the bug yourself
Modifying our workflow in light of our new skills
Applying our debugging skills to a new problem
Using the debugger to better understand code
A caution about debugging
Summary
9 Automating tedious tasks
Why programmers make tools
How to use Copilot to write tools
Example 1: Cleaning up email text
Conversing with Copilot
Writing the tool to clean up email
Example 2: Adding cover pages to PDF files
Conversing with Copilot
Writing the tool
Example 3: Merging phone picture libraries
Conversing with Copilot
Top-down design
Writing the tool
Summary
10 Making some games
Game programs
Adding randomness
Example 1: Bulls and Cows
How the game works
Top-down design
Parameters and return types
Implementing our functions
Adding a graphical interface for Bulls and Cows
Example 2: Bogart
How the game works
Top-down design
Implementing our functions
Summary
11 Future directions
Prompt patterns
Flipped interaction pattern
Persona pattern
Limitations and future directions
Where Copilot (currently) struggles
Is Copilot a new programming language?
Summary
references
index