3 Simple Ways ChatGPT Can Make You a Better Coder

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
ChatGPT! I'm sure you've heard of it by now.  It can do a lot of awesome things such as answering questions, writing book reports, writing  awesome poems, and of course, it can code. So,   I know a lot of people are scared that chat GPT is  going to take over coding completely and we're all   gonna lose our jobs. This is horrible. I'm here  to say, calm down, it's not that bad. In fact,   there are many ways chat GPT can help us become  better coders. That's why, in this video, I'm   going to show you three ways that you can use chat  GPT right now to make yourself a better coder. Number one: adding comments to code. So, here I  have an example function where I'm given a file   name, I open that file, and I print out each line  in that file until the end. Let's go over here to   chatGPT and tell it: can you add comments to  this python code to make it more readable?   Let's put things in triple quotes so it's  easier to know that this is a code block.   And it's done giving the solution, let's copy  this over into my notebook. And you can see it's   added comments to each line. There's a little  bit of over-commenting, and of course, it's up   to you to double check the comments to make sure  they're right, but it can save you some time. Now, another way that this could also be  helpful is if you have a bunch of code that   you don't understand how it works. You can  ask chat GPT to write the comments for you,   and then it'll give you a better idea,  potentially, of how the code works. Number two: using chat GPT to make your  code easier to read. This is just a fake,   complex function that has a lot of bad practices.  We see that we're checking A and B separately,   and then we're also using this if return  and then if not return back to back. Let's   give this to chat GPT and see if it can  make it more pythonic and easier to read. Here's the amazing thing about this: not  only did chat GPT give us a more pythonic,   easier-to-read function, but it also listed  out all the changes it made and explained   why that makes it more pythonic and easier  to read, all the way down to removing this   one blank line in the code. Of course,  you need to know how your code works,   so don't just rely on chat GPT to  do it for you, but in this example,   it's clear that chat GPT was able to take this  simple function and make it more pythonic. The third thing I want to show you that chat  GPT can help you with is writing unit tests.   This is something that many coders just avoid  doing altogether, but it's very good practice   to write unit tests for your code. So, we  have an example class here called Rectangle,   where we give it a height and width, and the  get_area method should multiply the height and   width. We also have some setters here. So, let's  give this to chat GPT and see how well it does. And there we go! It's provided us a unit test for  this and also is explaining that the unit test   covers these three methods for the Rectangle  class: get_area, set_width, and set_height.   So, there you have three examples of how you  can use chat GPT to make your coding better.
Info
Channel: Rob Mulla
Views: 21,796
Rating: undefined out of 5
Keywords: coding with chatgpt, chatgpt, python coding, coding with ai, ai assisted coding, rob mulla, how to improve coding with chatgpt, use ai to improve your code, automatically generate code comments, auto generated code, code help, how to write better code, pythonic code help, automatically improve code with chatgpt, chatgpt make imrpove your code, python, data science, openai, chat gpt ai, open ai chat gpt, openai chatgpt, code better
Id: NcCNw_UXnOc
Channel Id: undefined
Length: 3min 25sec (205 seconds)
Published: Sun Dec 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.