Build Anything With ChatGPT, Here’s How

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
with ch GPD and vs code you can build literally anything even if you know nothing about pyone on programming unfortunately a lot of people are still afraid to start any project that involves code and my goal with this video is to completely break those limiting beliefs and to show you that programming with ch gbt is actually not only easy but very fulfilling and you will learn a lot in fact I don't even have any project chosen I will let chgb choose my project and I will do everything I can and if I don't know how to do something I will simply ask jgpt and it will tell me let's start by choosing the project so I want to create some small project with python give me 10 ideas it's literally as simple as that okay so we have 10 ideas from cgbd Tod Do List application I'm not really feeling that web scraper we could do that simple chat bot um I mean that's you know that's probably a bit too much for a simple tutorial expense tracker we could do that although that sounds a bit boring game death that's definitely more exciting but again maybe a bit too advanced although we could definitely make a snake that's easy out of these 10 I'm probably most interested in the morco translator to be honest tell me a bit more about the mors how would that look let's keep it simple and fun after we get the basic outline we're going to use vs C you can see I have completely empty project again like you don't need you don't need to know anything about programming or python like even you don't even need to know what a variable is like you can just ask jbt to explain it and it will do that okay so it's going a bit too much so I'm going to stop it right here and we now that we know what our project is we're just going to copy this and use it as a comment so you know in Python anything with that starts with a hashtag as a comment so I'm going to add this at the top that way we can see what we're building right before we start coding is I'm going to actually create a custom instructions so control shift I brings up custom instructions now if you're going to do some project that's you know longer than 30 minutes let's say it's a good idea to create a new set of custom instructions just for this project so I am building uh more scod translator okay in Python I am using vs code and I am a beginner when it comes to Python and programming now how would we like jgb to respond again like customer instructions don't have to be over complicated but like just doing this is already much better than not having any custom instructions if you're actually trying to learn something as well you don't want it to code everything and you just you know get a block of code and you don't understand anything so like don't reveal the complete solution just give me hints every time you write code include explanatory comments so it's important to you know you're building something leaving comments it's not for some other people it's for you in the future you want to go back you want to see what you wrote it's very good habit to have comments in your code keep your answers concise and relevant to my prompts so we don't want like super long answers okay so save and now we have custom instructions which means we have to reload because every time you update the custom instruction is jgpt they don't apply to this chat because this chat you know as you can see at the top I created it without any custom instructions so I have to go and create a new chat and now all the new chats will be using the cust custom instructions we just created so you know every time you make a change you have to start a new chat if you want those instructions to take effect so we have a project chosen I'm just going to keep it super simple so that it's not confusing L show like this by the way whenever you see this gray text that's just my co-pilot suggesting what I should do so you can ignore that for now by the way I'm going to include the custom instructions as well as whatever we code uh in a GitHub repo which is going to be the first link in the description we could use Advanced Data analysis but I think it's better to use the default one because of the GPT Vision which allows us to actually take screenshots and just paste them here which is going to be even faster so yeah default gbd4 and let's get started so I'm going to copy this project because I don't want to type it so I want to build a simple mope translator in Python help me create an outline for this project boom and let's see what gbd4 comes up with look at this it even tells you to install Python and set up vs code so if you don't have vs code set up just ask CH GPT and it will guide you through the process it's literally so good because you know whenever you're asking a person you're kind of you don't want to look stupid or like asking dumb questions but CH gbd like it's a language model like it doesn't care you can ask it as many dumb questions and as you want until you understand it and trust me like I ask a dumb questions I'm not a like I'm a bad programmer to be honest so I often like want to know the difference between a topple and a list so like okay so topples are immutable lists are mutable I ask CH gbt and I don't have to remember that stuff and it tells me exactly what I need to know so this is amazing so like let's say you don't have vs installed just ask jgpt how to install it and it will it will do this stepbystep process for anything so like installing python ask ggbd setting up vs code ask ggbd and that's how you get to this position and right now as you can see in the previous chat we didn't have this icon but right now we do so we can hover over it and we see our custom instructions and that's how we know that we're actually using the new custom instructions that we created and that chbt knows all this so for example here I didn't say anything about vs code and it referenced vs code because it knows it from the custom instructions this is the outline for project project setup we have that so okay right now we just look at it and this might seem overwhelming right so if something seems too much or you know you just want to break it down say like this outline feels overwhelming can you give me a can you make it simpler and more high level that way I know where to start again you literally don't have to know anything about programming like this is insane because two years ago obviously there wasn't any even a year ago jgpt wasn't released right it was released in November so like we couldn't do this and now anybody can create any program obviously you're probably not going to make a compiler with ch gbd but 95% of programs that you can make that you can code you can can do even if you don't know the language and if you don't know anything about programming so okay let's see simp this already looks like much more you know this is 10 steps whatever and this is five steps simplify it okay so we have that create a dictionary for English to mors and mors to English translation so okay so we probably need two dictionaries user input as the user what they want to translate and get the text to be translated okay so to keep it super simple we're probably going to start with English to mors maybe we can add this uh later so we're going to take user input and translate that to Morse now personally I know like almost nothing about mors so that's why I find this interesting because I'm going to learn something you know that's the amazing thing about programming is that if you if you're doing something that's outside of your comfort zone you're like actually learning useful stuff and like even people think like there's not going to be programmers programmers are going to be people who know how to use these chat Bots and like the more you know the more you like the more limiting beliefs you destroy and like the more projects you can build so it's not about like remembering syntax that that's the old way the new way is like having an idea or you know like just just deciding to do something like as you like I didn't even have an idea to do this like I I had no clue that I'm going to make a Mor code translator but this was what J gbd suggested and I thought it was a cool project so like all you have to do is decide and just use use these tools which are so good so okay we have that step one create a dictionary so we're going to create a dictionary super simple obviously English toor so we can actually call it English toor that's co-pilot uh a little bit cheating but I'm I'm going to keep it simple now if you don't know how to create dictionary you can ask jgpt obviously but you know it's it's literally two curly brackets that's how we create an empty dictionary now we obviously don't want it to be empty because we wanted to map the key value pairs of English characters to Morse characters but we're going to do that no worries that so we can actually do this um we need need a dictionary for most code exactly exactly like this is this is why co-al is so huge like it's $10 a month and it's like saves you so much time for coding but I'm I'm going to try to use it only a little bit so that you see even if you can replicate it even if you don't have it but again like see like I didn't have to type this comment out uh it did it for me so here uh that's the first step so obviously this is not going to be enough but I'm just going to lay it out so we have it in vs code data mapping that's what we did user input all right so we have to store user input into a variable and then convert it through the dictionary so we're going to just do a simple uh uh uh user string equals boom okay let's write it out so simple so input is the way you know to get user input in Python so obviously if you if you enter uh string into input it displays a message so this actually doesn't do anything you can just like do this you know and this is just if we run it if we run the code we're going to see this nonsense and that's just you know what you can output to the user so here we're going to like enter uh random uh uh English text boom and then when we run it as you can see uh uh where am I okay wait boom here enter a random English text so here it waiting for the user input so I can just do like one two three blah blah enter and obviously since we don't have anything else it's going to take the input store it into a variable and that's it so we need to obviously do something with this so here we get get user input so this is the part where we get user input and obviously as as I said we're going to expand all this I'm just going to lay out the plan into vs code that way we actually get moving because we like right now we have been stuck in jgpt and you know we actually have to put put it into code and guess the text to be translated okay translation write a function o okay we're going to write a function so if you don't you know if you don't know what a function is you're going to learn and again you don't have to know any of this if something isn't clear if you don't know how to set up a empty dictionary or how to get user input in Python just ask jgpt don't be afraid to ask like that's how you learn you have to ask dumb questions to get better and you know the more you understand the fundamentals the better you are cuz like if you try to skip the fundamentals it's a bad idea and you're going to get caught and you know exposed or stuck later on and that's bad so okay next step is translation bright function so I can just copy this now now you know obviously a co-pilot is going to suggest the entire function so if I was you know in a hurry or whatever I would just steal this function but we're not going to do that but I can just you know def an empty function so we can do Dev and we can do um we can name it translate but we can do we can do I mean actually translate is kind of a good name so I'm just going to do translate and then us the string is going to be actually let's name it something else translate we going to do text and we're going to do return uh return empty for now we're going to keep it super simple so this is obviously a useless function but I'm just you know again I'm just creating the layout so this function this function is going to take a text uh argument so right now it's parameter parameter when setting up and it's going to return the translated value based on the dictionary and output so obviously you know output show the translated text to the user so this is very simple we're just going to do print and then we call the function but let's just do a simple empty print which doesn't do anything so okay let's test that our code works as it is so it's super basic so right now obviously this doesn't do anything it just uh initiates an empty dictionary here we take a user input which is string and we store it in a variable so what we could do like it's a very good idea to always test your code as your programming so we could just copy this and put it into our print statement now this is obviously useless but we're going to at least test that our user input works so right now it should ask us enter a random English text so we're going to do um castle house wall whatever enter and it gives us back castle house wall That's because we print out the string so we know that this works which is great so okay we have this basic and let's say we want to get started actually so we have to set up again if you don't have this just ask jgpt or Google it or there's infinite YouTube tutorials you can do you can set it up in less than 10 minutes installing Python and setting a vs code it might sound intimidating but trust me it's much easier than think now we have that so step one done let's uh let's go and code step two again I'm just going to tell it not to give me the complete solution because chbt is absolutely capable of doing all of this for us but we want to actually do something and we don't understand what we're doing that way we can build upon it and improve our skills because you don't have any advantage if you know all your skills can be done from jgb that's how people get replaced by AI now you you want to use AI to improve your skills and get even better at using Ai and you know just enhance yourself with AI not Outsource everything to Ai and like just stagnate and people like don't think so you have to keep your thinking and use AI to improve your skill set that way you can do more and more while people other people just rely on AI and don't use it to improve themselves so again this might seem intimidating so let's just do step by step we have step one done and let's do step by step let's go on step two tell me what to do okay actually no point me in the right direction without revealing complete solution again I have it in the custom instructions but I just want to clarify it that way C GPT you know doesn't just give me everything and then we don't have anything to do so boom okay so use SP five dictionary day structure we have that English tomor equals an empty dictionary so obviously you know that's how we do a dictionary if we wanted to do a list it would be this you we wanted to a tole uh topple it would be this just you know a quick guide on data structures now we want a dictionary because why why do we want a dictionary why does CH gbt just a dictionary again we could ask it but you know I'm I know it so I'm just going to explain it the reason why is because we want to map English characters to more code so dictionary is great that it's a collection of key value pairs which is perfect because we want to give it a key in this case an English character and it's going to give us a value so that corresponding Mor code so dictionary is the perfect data structure for this now obviously we don't have to know any of that and actually I you know I can pretend that I didn't because here in our previous prompt ggpt actually suggested it so you can ask it like why a dictionary and not a list if you want to know but I just explain it so okay who we already getting some code but yeah okay in we to create dictionaries obviously that map each English letter and number two it's a m code counterpart in vice versa now actually we don't probably need the vice versa again maybe we can add that at the end but let's just keep it simple and let's just do English to mors for now hint use Python okay that's correct each key value pair should be an English character as the key and it's mors code yep now I'm just what I'm wondering right now is that where are we going to get it should I get it from Google or should I get jgpt I mean okay that's kind of you know obviously we're not going to ask jgpt to give us the actual Morse code characters because you know typing out like what the entire alphabet is like 30 characters or whatever manually let's be honest like it's 2023 which're just going to let AI do that okay so each key value pair should be an English character as the key and it's more so okay I'm going to show you how it looks right so it's going to be literally key and then value as U co-al just it and then comma and key value right so super example is going to look like this right f copal is or just but okay a is Dot and dash so a and then Dot and dash oops dot and dash is going to be the value so this is a key and this is a value and then we have B and boom C and D I mean I could type it out with co-pilot obviously I could get it to create the entire function so I could literally do this like U you know create a dictionary of. Maps English characters toor codee and it's going to do that but actually you know um C- palet is using gbd codex it's using gbd4 so it's basically very similar to what we're getting in ch gbd so as you can see it did that for us but I'm going to discard it and I'm going to show you how to do this with ch gbd because that's you know that's the point of the video okay so we have the outline here obviously our code nothing so let's actually make progress here you might consider adding space adding a space character mapping for both diction as well oh this is an interesting hint um actually I didn't think of this so very good suggestion from ggbd so here is a small snippet of an example for English to mors right now this is you know obviously this is adding the this is adding it manually so this is a slow way but we just want to you know we want we don't want to type out manually every single character uh in Morse code so we're going to ask jgpt to do that so okay we have an empty dictionary so I have an empty dictionary can you please uh generate uh the mapping of English to mors S key value pairs here is is my code and I'm actually going to show you how gbt vision is so great when coding because you don't even have to copy it over you can just take a screenshot and I can do boom taking a screenshot of our code it's saved in my clipboard and boom I just paste it here and it's going to see that code I don't even have to copy obviously I could copy paste it and that's also easy but this is even better because you know it's kind of more visual I'll provide you with a starting set of key value pairs for the English tumors so this is exactly the type of stuff that you don't want to do manually like let's be honest a human like no human wants to do this like that manually mapping A2 do db2 D do do dot it's like this is perfect task for AI so we're going to get this and did it SP did it map the space oh wait it's mapping the numbers wait is this zero or O Okay so it suggested to map space character but I don't think it did CU I don't see see it right now okay either way we can copy the code obviously and we can replace our empty um dictionary control+ V with the code so wait let me delete this so again super simple what we did we just asked cgbd to do the most boring part for us because like I don't I don't know about you but I don't remember every single Mor code character so instead of you know trying to Google it and then manually typing it out or trying to search if someone on stack Overflow already did that which probably they did um it's much simpler to do everything from jgb now I I'm actually curious right it suggested this so I'm going to ask it earlier you suggested this boom why did you suggest that and have you um and have you okay okay so and why did you not include it in the dictionary I mean obvious it's kind of obvious why you know it's just that because while translating text we are we are going to have some spaces so it's good to have that map because if we didn't have that map we would get an error obviously when we call the dictionary create catch so again jgpt isn't perfect so it's actually good to pay attention and read what it's saying that way you know you still have some leverage as a person like long-term memory is something that chbd sucks at so if you pay attention you're going to catch mistakes that it does so the reason I suggested adding a space character is that a typical modation individual letters Within A Word are separated by spaces so we're taking input text from a user which is probably going to include spaces so we need to have that mapped entire words are separated by three spaces okay I did not know that but we can definitely program that yeah that's a good point we need a way to see when you know there is a actual space and where is a words because like each of these characters are separated by a space or like a gap or a pae you know because like there's pauses between each now the pause has to be longer if it's words so we have to code uh three spaces to be equivalent equivalent to a space between words okay it's going to explain what it does this free spaces H English tors okay wait it's actually kind of suggesting something else right now but for the purpose of Simplicity of inner translator we can use a single space to denote the end of and some other character like a forward slash end of a letter what okay so it's actually I think it says it's more straightforward but it might be more complex okay so I I think adding a slash is actually more complex let's do this the legit way what a prompt but okay so again we can do we can just take it boom say take a screenshot of it so it knows our current state of code obviously it knows it from before but let's say we changed something so let's do this the legit way what should I change about my dictionary to include Ming of the space character whatever it doesn't need to be grammatically correct so it just you know obviously we have already the entire alphabet and we have the numbers which is great but we also need to add the mapping of a space so it's going to take one space into three right you can see one two three so we're going to copy this line of code and going to paste it here now as you can see it's going to be an error and why is that because we need to add a comma you know between every key value pair so have key value key value there need to be a comma in a dictionary so this is just python syntax but again like if you tried running this you would see an error in the terminal and it would tell you or you can just always ask ggbd why am I getting this error and will tell you so this looks good to me again maybe I'm wrong so we can uh move on to the next step so we have the dictionary for moros code we have the entire alphabet numbers and the space bar so this is basically you know whatever you're going to type this is going to map it now actually this is all capital numbers so I'm just going to capital letters I'm just going to ask a clarifying question because I don't know this myself in mors is there any difference between capital and non capital letters it probably isn't but I just want to clarify it okay so there isn't that's why it's doing caps because you know it's it's basically more visible I guess or more traditional it's like you know you see a capital A it's much more recognizable than lowercase so this is good to know like obviously when you're trying to code it you have to learn some facts about the project so I did not know this I mean in hindsight it's kind of self-explanatory but yeah again there are no dumb questions when it comes to programming just like it's much better to ask it Than to Assume right so a capital and lowercase both translate to dot dash beautiful so we have this outline let's move to the next step which is get user input which we are getting already so we can actually probably move On To The Next Step um writing the function so right now we we take user input but we don't do anything with it so we need to actually do something use this dictionary in some way on the user input and then print out the result so let's see we can just tell it tell CH gbt the exact uh State we're in so okay it let's go back here because it it laid out a stepbystep plan D Bank user input okay so again Step One is this could just you know make it a bit more um organized step one this is step two get user input that's done and this is step three write a function and this is step four so actually you can do everything in four steps which is beautiful so we have step two done you know this is very simple one line of code call an input which gets stored into the user string we already tested that that it works so let's go into the function which is probably the most complex part of the code but again if you don't know anything you can just ask so I'm just going to copy this because I don't want to type it out I have completed steps one and two now I want to do and paste boom step three wrer function again I'm just going to say that give me hints and pointers how to do this but do do not reveal the complete solution because I actually want to do some programming I want to learn I want to get better at Python and I want to you know expand my knowledge what's what's possible because if you like copy paste everything you're not going to learn anything and you're not going to expand your possibilities and you're going to be just as limited as everybody else we don't want that we want to become better okaye in okay okay so let's here's a breakdown of what you can consider for step three so okay if we know that if we know that everything is caps we're probably going to uh call a method that's built in into python that's going to take the user input or like take the parameter in the function it's going to make every letter uppercase so I'm going to show you how to do that so we can do text and we can do text Dot and obviously you can see that co-pilot is or is suggesting it but if you don't know what it is then you can just do Dot and wait I think with co-al it doesn't even suggest that okay so if you don't have co-al it should probably be suggesting the possible methods on the text but yeah it's text. uper um again chgb is probably going to suggest this right conver to text to consistent case okay beautiful so it it gives us the layout it doesn't do the uh it doesn't do the actual what's it called coding it doesn't do actual coding but it just tells us WEA comments what to do so we can even copy those so let's let's like read it case inity okay so we need to convert the text into single case which in this case it's going to be uppercase because we have the dictionary in uppercase again that's why it's good to understand your code because if you're just copy pasting everything I think you're going to miss out on these important details looping through the text so then we Loop through the text and look for each character in the input so this is a string user string we're getting a string from the user but these are individual characters so we probably need to process that string somehow and we're going to do that by splitting it up into characters so we're going to Loop through every single character in the user string and then we're going to map each character into mors because if we try doing this which is a string it would be an error because we don't have mapped every single string which is that that would be impossible to map that in your dictionary you know because like you can enter any text you can enter your name or whatever you want and it's going to map it to mors so we have to break into characters so the first step which which iied earlier but gbt confirmed it is to convert text into a uppercase the second step is to Loop through every character in the user string now let's see what hbt does looping through text handling spaces encounter space in the user text uh I don't know why this suggested as a extra step because we have the space mapped in the dictionary so that's kind of a weird stuff maybe I can ask it why I did that consider what would happen if a character in the user Tex is not found in your dictionary okay that's true that's true very good want we yeah we definitely want to handle errors we're going we probably don't need to do that at the start but we're going to add that later on to improve our code and WR a better program return the transl text function signature so this is you know just gives out and then test so yeah this kind of laid it out it probably should should be simpler but okay let's not just be blind and let um okay so actually here this is a good idea so we're going to follow cgbd so right now we have the layout over here uh convert the text into uppercase so we can slowly start implementing that uh so by the way this is just the name of the parameter you know we're obviously going to pass the user string in in there but right now we're coding within a function and the function is just a small piece of code that you can reuse over and over that way you don't have to rewrite it right because like if this program get gets longer we don't have to copy this copy paste this we can just call the name of the translate function and it's going to execute this block of code every time so we have to work with text so text. uper now this is not going to do anything because we have to do text equals text. uper so not right now it update updates the text into uppercase so so we can actually even we can actually even test this right and return text so this is a super dumb function that just takes text takes any text and makes it uppercase so let's let's even test this by taking a user input and then right now we have to do print and then exactly this right so copil let just do that so we print it we're going to do print and then we call the translate function and this is going to execute this and as the argument with passing the user string so we can actually test even this so I'm just going to do python I'm just going to type Python and let's see it capitalized it so we know that this works we know that this simple step Works which this is why it's good to always test in small increments because you know if you write 50 lines of code or like 100 and then you run the um test like this is the likelihood of there being something wrong is much higher than if you just write a couple of lines run the test okay it works and continue so obviously we don't need this so we can delete this and then we can continue so this is the first converted text into consistent case okay we did that initialize an empty string for the morse code results so how do we do an empty string well it's very simple right so we can do we can do uh Mor string doesn't really matter what we name it and this is how we do an empty string you do two quotation marks and you don't put anything in it so if you do it a or like ABC this would be a string with ABC inside or like David my name obviously or like python so this would be exactly this string would be equivalent to our previous user input because we typed in Python but we want an empty so we delete everything and there is not even a space see like there is nothing here so this is an empty string so that's we just initialize it now we're going to return this at the end but you don't have to know that right now so we can delete this so okay okay co- pallot get out right this is just ignore the text because co-al is already getting ahead but yeah let's let's use Chad GPT even if you don't have co- palot you can still do all of this from jgb convert text into consistent case check so actually I'm going to make it like I'm going to do it super I'm going to include all the comments so you know what each line does so this line takes the text and just saves saves it like updates it right so text equals text. upper so this takes the text and calls the upper method which makes every single character uppercase the entire string uppercase and it saves it back into the text variable so right now that what is which is what we already tested right now the text is all upcase which is good now next step is we did we have the initialized empty string which is what we have here so I'm I'm adding these comments so that you can see you know this like this line does this so if you're super beginner you see everything clearly now we do Loop through each character in the text so we have a couple of options obviously there's like while loop for Loop but as as you can see see copal is already suggesting the for Loop now why is the for Loop good well because in this case we know the length of the stuff We're looping through right because while loop is usually where you don't know how many times you're going to Loop but for Loop most in most cases basically in most cases you're going to use a for Loop but again if you don't know which one to use just ask jgpt and it's going to explain which one is better so here Loop through each character in the text so we just going to do for character or we can do c that way is not named the same way as Co say it for C in text now you might be confused how uh you know how python knows that C stands for character because you can just name this literally anything and this is going to still work so how does it know that this should be a character cuz it doesn't matter what you name it well it knows that because every object or you know data type if it's iterable it's it has a basically python knows like what you're iterating through right so let's say in a dictionary if we were going through the dictionary it would be going through the keys that's for the dictionary if we're going through the list it's going through the values in the list but you know let's say you have a string so you might say well string what's it going through well every string has characters right so it's it automatically knows that this means characters even though it's a completely stupid name python automatically knows that you know text if that's a string it's going to go through the characters but we're going to name it we're going to name it actually car that way it's you know it's a a pneumonic name or whatever you understand what it is if you name it some blah blah blah like you you wouldn't understand later on and it just leads to confusion so for in text it means for every character text what do we want to happen what do we want to happen for each character in the text co-pilot already tells us what we should do but let's not get ahead of ourselves right your translation logic here so this is good because I asked jbt to give me hints and pointers but not reveal the complete solution and the forloop is actually the main part of the code of this function so this is where like we have to do thinking because this is the main purpose of the function and return the mor code result so obviously as I said we're going to return the more string but right now more string isn't anything it's still an empty string so we have to update the for Loop to do something so for character in text what do we want to do with every character we want to change it we or like we want to update the more string to using using this dictionary on our text so I'm actually kind of you know short circuiting even though it's kind of obvious but as you can see co- pallet tells us to do what we need to do so more string okay I'm going to break it down super simply right so Loop through each character in the text and let's do comment no we're going to add that later on WE this is good this like it's already suggesting us like stuff that's really good to implement like checking and you know um catching errors but like let's keep it super simple so I'm going to do uh update the uh bro copil is amazing I just can't resist update the more string uh variable with the mor code for the character so Mor string we could do equals but actually we want to add to it so we do plus equals which basically means like you know you take the like basically here we take like obviously you can't do it because it's a you're calling a method but like plus equals means you take the same number and you assign something to it so let's say like 1 + equal 1 is two CU you take one and it basically say it basically says like 1 = 1 + x so here we do plus equals I mean I can just write it out because is this is just like exactly this like this is beautiful plus equals means this so it takes the more string and it adds something to it but this like this is long so you just do plus equals right so right now we we we have we're updating the more string with something so what what do we want it update how do we want to update it right so we have the dictionary so what can we do right well we want to use the dictionary to find the character because keep in mind we're in the for Loop so inside of the for Loop for every character we want to add to the mor string dictionary it's equivalent in Morse code so we call call the English toor dictionary and then using this syntax which is how you specialize which key to call you Ty in car now obviously you might say well car it's not mapped in here but we act car is just you know the Alias it's the variable name inside of that variable it's going to be the value and that's going to be again every character in the text so it's not like that we're literally passing car which obviously isn't mapped in our dictionary it's going to represent one character so this is going to run for every character in the text and I don't actually feel like we okay do we need to add a space we probably do right we probably do need to add a space right so yeah we need to add a space so the reason we why we need to add a space is because you know we have this for the okay so this is actually might cause problems this might okay let's see okay some I'm going to do 30 more minutes yeah all right so let's think for a second you might not like realize this but you would see is later on but right now if we if we do it like this adding a space it's good but then again if we're doing this uh it might it might be trouble because it would add a third space which could mean that we could technically make this two spaces only okay we'll see let's let's keep it like this I I don't want to make it too comp complex for the first try but like we can I can already see that this might be an issue because if this is is a space bar it would add another space bar which would mean it would not be three which is the mor Cod equivalent it would be four h okay so let's actually handle this right now so if if car uh uh uh equals space oops come on man let let me code uh no we're going to skip this what's the best way what's the simplest way to code this if characters equal space okay yeah so if character equals space then we do just this part then we should do just this part without the space and then we do else else and in the else we do this so if the character is a space bar we don't add the extra space bar because we already have that mapped but if it's any other character we need to add the space bar that way each letter is actually separated so we're using a simple if else statement that handles this I unfortunately I don't think how to make this like we could probably make this simpler but I think this is for now pretty simple so okay next step okay actually what am I saying this is finished so now we know this is how we like this is the return is the keyboard it's a reserved keyboard in Python which you know signalizes what the function actually gives back so you know make the function give back the new Morse string so that's how we do this so this is our function it's still quite a simple function but for our purpose it's useful now let's test it before we do anything else Let's test it so we're asking for the user input which is a string and then let's pass it so let's then let's print it out print translate and then us a string so again what this does you can even break it I mean probably like this is already pretty simple but I'm trying to explain it even simply right even more simply so we're printing something out right we're printing something right now this would print nothing we just print an next line just an empty line we want to print something so we call the function but right now if we did this the function doesn't have any argument so it wouldn't give us anything so we want to put the argument as the user string which we get earlier by asking for the input so this actually doesn't run here it's only written here in the code it doesn't run here it runs after we call it so when this when we the code gets to line 43 you know like when the code is going from the top obviously so here it initializes the dictionary here it asks us for the input this only stores it into memory but it doesn't do anything with the function only here when we're calling the print so it wants to print something but then it needs to call the function in order to print the value so it passes the user string and then calls the function only here it goes back the code and executes this converts it to uppercase initializes an empty string which is going to store the new Mor characters and for every character in the text that we pass which in this case as you can see translate and boom here the argument is used user string so for this text just imagine this is user string so uppercase boom bo Boom for every character in text it's going to break it down if it's a space it's just going to add three spaces which is the mapping but if it's not a space it's going to do is going to visit this dictionary pass the key which the key is the character final the value which is the morse code equivalent and then add the space bar which is how you separate in Mor code which you know I personally didn't realize it but again jgpt helps out with that now wait hopefully my camera isn't Block in yeah okay it's all good actually it's all good so all right okay so yeah let's test it out enter a random English text so we can literally do a random English text AB BC afg whatever so this is a random English text you do enter and we have the morse code beautiful beautiful is literally obviously you probably won't U you know maybe you can just implement this in your website or whatever but it's already pretty amazing right what you can do with jbt with zero knowledge so you can see um our input was our random English text so it takes character by character and we can see R indeed this is R indeed this is a and as you can see it's one space between the characters and then three space okay so this is actually still four spaces because it's a space after I don't know if this is the best way to handle this h it probably isn't it's probably okay so I'm just going to because right okay so this is as you can see 1 two 3 4 and that's the reason why that occurs is because we are uh passing the space which is after the character so in this case it's m and then it has the space bar so we can just you know do a super simple test you can just literally select this copy go into gbt and then is this correct Morse or not boom okay so let's say I don't know if it's an issue so I'm just going to ask but but isn't it an issue that we have four spaces between the words instead of three okay so we can let's fix it right so actually I don't think this is the best way to do it we're going to delete that this simplifies our function only adding the letters and numbers now we're going to handle it in here so if a character is a space which means it's a space in text we're going to do more string plus equals and we're going to do three spaces 1 2 three actually sorry only two because before a space well unless we're starting you know the sentence with a space which is very unlikely we're going to have a um the space so because after we're already here we're ordering a space but after every single normal letter and number right so if we want to have three spaces in the gaps between words we only need to add two so if a character is a space bar as you can see see beautiful uh vs code makes it visualized we only add two spaces so now we should add hello world one two 3 we get the morse code and we can copy this again and ask is this better oops I didn't include it is this better boom save and submit and it's I don't know why it's so slow okay yes that looks better so we have the basic functionality done I mean okay I don't know why I put it here digitally step four so let's take a look we initialize the dictionary we take user input store it into a string we set up a function called Translate which takes the text and translates it to mors now let's say we want to do back we want to take we want to take mors and put it into English wait one oh it's okay so this is quite long all right so this is already a really nice program that's only 42 lines of code including the comments obviously we could make it less but this is much more um visual so how could we improve it we could so okay before we add the bigger functionality we should probably add um handling errors because let's say I type in hello world smiley face ah we get an error why because you know obviously this is not included in the mapping because modos code doesn't include smiley faces at least I think so I'm just going to ask what if the user input is Hello World smiley face does Morse code include special characters or should we handle that differently okay so morod does have some special characters but not all of them so yeah I probably would lean towards updating the dictionary to adding the most like you know punctuation exactly so again um co- palet does that for us but we're going to we're not going to use this or I'm just going to do special characters special characters boom and then um I'm going to ask it to do it so give me the key value mappings for our dictionary for all the special characters that are uh included in Morse code because I don't know the like what obviously there's going to be Dot and like the most used ones like exclamation question mark but you know comma exactly those the most Ed the most used ones are going to be mapped but you know you probably you're not going to probably have like I don't know percentage point I guess not or like reverse Dash or like Curly braces Pro some programming um letters probably won't be mapped I don't know what's going on here so something went wrong I'm just going to do regenerate hopefully CH GPT doesn't crash on me so okay beautiful special to mors I don't know why it's doesn't matter it we're just going to add it into the single dictionary to make it simpler but yeah English to mors so let's think about how we would do mors to English right we don't have to actually initialize a new dictionary we can uh use uh list comprehensions or like just comprehension not list because it's going to be a dictionary again but basically we can create the mapping very easily and without whoa whoa whoa okay I was wrong oh my God we have so many more characters in more SC than I thought we did oh my dude okay so apparently more SC okay it doesn't have percentage points so I was right about that and it doesn't have C bases so I'm going to copy this obviously we're going to include it in our dictionary so I'm just going to paste it in here oops uh okay actually let's only copy this we have to make sure that it's all I mean obviously here it doesn't matter but like it's nice to have it organized this is an unofficial code but it's sometimes used it's often used okay so these two are unofficial but these are official so as you can see the dictionary has expanded but it doesn't matter because um it we we like you know putting everything on a single line which is only done for um you know Simplicity because you can see the commments from jgpt it explains every single like how each character is called and the moros code equivalent so this is good we have updated the dictionary so now actually we do include uh colon and we do include the smiley face so if we run the same test and we do hello hello oh hello what the okay oops I that was a mistake the cursor should go in here so hello world smiley face this should no longer be an error as you can see it's not an error because we have added this into the dictionary so python knows what to do now we should still you know let's try something else obviously we know that percentage Point come on we know that percentage point is not in dictionary so we can do 1+ 2 equal 5 this should work right but if we do five% okay if we do like uh let's see if we do 10% of 100 this isn't going to throw an error because we have we don't have percentage handled so we should update our function for error handling and you know obviously we can do a try accept and check if the character is part of uh part of the dictionary but let's say we don't know that we should do that let's say we we're getting this error and we don't know how to fix it but we're just going to show jgpt the current code so this is how my current for Loop looks like I want to somehow uh catch errors like when the user includes characters such as percentage that isn't in mors how do I do that give me do not reveal the solution just give hints because like if I don't repeat this jgpt is going to try to solve it as fast as possible and it's going to give me the you know exact code which you know takes away from the fun of coding so right now you know we're on the right track we want to make it bulletproof that way if some user wants to troll Us by adding characters that aren't in the in Morse code we don't get an error and our code doesn't break we want to catch that obviously and let's see using dictionary methods there's a method for dictionaries let you check if a key exists so this is the get this is the get method I don't think that's good here conditionals you can add an if statement but I think the best way is actually to do the exception handling I think that's the best way I mean again I might be completely WR but you can grab the code where you access dictionary and try block and catch the specific exception so this is very good point this actually you know a lot of people just do try accept and they don't specialize specific they don't include like specify the actual exception they just make it General which is bad practice because the longer your code is it can catch errors that you don't want to catch and then you don't know why your code isn't working because you're like try accepting everything and not just the correct stuff so we need to look what type of exception is it so if we include percentage point we're getting key error okay so we're going to copy that and we only want to catch key errors so this needs to be looped oops sorry let's follow what h this is us we want to use try accept so we want to try something and if it works then beautiful but if it throws an exception we want to do something else so try and then we need to tab it out because python is sensitive on indentation and then we do accept beautiful um obviously co- palot already knows but like most people would do this right most people would just do accept and this is General so no matter what error happens this would print out out invalid character but there could be a different error so we want to actually specify the key error so only when key error happens we get this because we don't want to print out invalid character if it's an different error because that's just you know makes our code confusing so what this is going to do is we're going to try this piece of code and if it works without issues beautiful we just skip this and we return the more string but if it for some reason you know obviously we know that this is a key error this is not going to happen and we're just going to print out this so we can try it so again we can do like 1 2 3 four all of these are legit and then we do curly braces which are not legit because they are not in moros code and enter invalid character and it still did one yeah it still did the one two 3 4 because um it was before you know like it's doing that for every character so wait actually okay this is I don't know if this is the best way to do it because you know if we include the invalid character at the start it's not going to convert the rest of the text because before it was at the end so I'm thinking we should change this actually we should okay let's delete it and inside of the for Loop we should do it inside of the for Loop that way it only you know it like it only accepts for that specific character [Music] so no okay actually doesn't need to anything uh I don't know why it suggests me to nothing but let's see let's see we should do bum bum oops all of this is legit all of this is legit and then we do curly braces and we do some text and it points it out and it ignores it oh wait what this is 1 2 3 4 One Two Three 4 five uh is that because of the character oh it's because the space bars right right right H that's unfortunate but I think if it's extra character it should delete it yeah so if it's an extra character if it's an extra character it should probably delete from the last two string it it should it should RP the string so okay so we should we need to remove the last space bar CU if you're going to ignore it or I guess we could replace it with I don't know we could just replace it with X maybe we could just like you choose you know we can decide which of these characters or maybe question mark you know we whatever we can choose one of them to be as like a placeholder that we give that way our moros code is still you know still works maybe we can do this actually and percent I had no clue that it was called m% but okay okay I don't know I'm just going to like let's say I don't want to think like I'm just going to ask jgb so we are successfully catching the invalid characters however the mors now includes Extra Spaces because if I do ABC percentage ABC the space bars around the invalid character percentage are still included what do you think is the best approach removing the space bars using a placeholder letter or character for all the invalid ones or some and entirely different which is going to make chgb think and explain its reasoning it's actually good point we can like we can initialize our own new moros code character for I think option four is actually kind of good because it you know includes the invalid character in the more string so we can actually you know we can [Music] actually you know we can do this and then yeah so this should probably work so we should do you know python percentage Python and it outputs the percentage obviously you know if we want to send raw mors code and this is bad but for our purposes this should be good so let's see we have a dictionary that's pretty beefy because we include every single letter every single number and all the special characters which are included in mors code including these two which apparently are not usually included but I don't know jgpt somehow pulled them out some jgpt knows something we don't now this is interesting because you know whenever you use the different quotation marks you have to use like in Python you have the single or a double straight you have to use the different mod so as you can see here double quotation mark is in singles but the single has to be in doubles so like you can see all of these are singles but when you do want to do the aposto whatever single you have to use doubles to check it but I think this is honestly really solid like this we have did this in like less than 90 minutes and if you don't know anything about programming anything about python like this is pretty solid first project to build you know taking a string from the user like Hello World my name is David enter and you get the morse code so like you don't have to know Mor code and you have this program to do that for you is pretty damn neat so 70 lines of code including you know spaces and comments whatever and nice formatting but dude we have a dictionary which is very large we have a we take the input from a user we use we create a function where we put the where we make the entire string uppercase we initialize an empty string and then we use a for Loop where we use a TR accept so this is like here you learn how to use a for Loop how what try accept does if else statements so like dude in this single function you learn so much about programming it's it's amazing and again if you don't know what for Loop does if you don't know what Tri accept does just like literally take a screenshot jgpt can you explain what the try does in this code ask a question it doesn't matter how dumb it sounds it's going to look at it use use this Vision capabilities and it's going to explain try is being used it's executed first if everything executed found errors except block is skipped as I explained if there is an error then the code stops executing so boom bo boom there is an error it stops executing and goes immediately into accept and it execute these two lines so you can again I'm going to leave Link in the description which goes to the GitHub repository so I'm actually going to you know terminal new terminal and I'm going to do git add Dot and then I'm going to do git commit and this is going to be actually this is kind of a bad practice because I should have been committing committing throughout but I'm going to do project complete and this is going to you know do the commit I'm just going to push and that's it and this is going to be the link so this is going to be in the description uh the repo is public so you can take this code do whatever you want with it and if you want to build it this yourself or if you want to build anything else literally you can do anything with j gbt and hopefully I've proven that with this video like you could have built this with zero knowledge of python zero knowledge of programming zero knowledge of Morse code which is basically me and you know you have a working Morse code translator in less than 90 minutes now if you're new to programming this like this could break so many of your beliefs and show you what's possible with the use of CH GPT and gp4 so if you want me to build this in if you want me to like improve this project and add you know uh mors to English or some more functionalities make it visual you know add some GUI some maybe sound so it's actually more schol like like we can do that if you want me to do that let me know in the comments if you want me to build a different project or show you how to do something completely else with J gbd I'm going to do that like the opportunities are literally endless and you can build anything you want just all it takes is a decision you can decide to do something if you don't have even you don't even need the idea like that's crazy like you can just ask jgb for ideas choose the one which suits you the best which is exactly what I did over here I've selected you know asked it for 10 ideas the first nine I decided not to do I chose the morc translator I asked for a bit more info you know it kind of laid it out for me and then or started giving me the code so I stopped it then we created the custom instructions you know super simple I'm going to also include this in the GitHub repo and you know these are specifically for this project so whenever you're starting some different project that's going to take you know a couple of hours it's definitely worth spending 5 10 minutes setting up your custom instructions so that jgpt knows what you're working out and what you want it to respond like and then you know I switched up the chat because I I wanted to have the new custom instructions and I Lally build the entire thing from the ground up using just jgpt like you don't have to know any of this you can ask gbt what def means what input means what if else means like it's literally the best time to be a programmer because you don't have to remember syntax all you have to do is decide to build something and just go and start building it that's it like this is a new era programming in the past you had to remember all syntax and you know understand the semantics and just memorize so much info but today all you have to do is decide to build something if you have an idea amazing if you don't whatever and just go and build it just take action don't be afraid to ask questions don't be afraid to learn and build something so yeah I think this is amazing result for you know inless 90 minutes so if you enjoyed it please subscribe and again if you want me to make more St more videos in this style let me know in the comments bye
Info
Channel: David Ondrej
Views: 865,184
Rating: undefined out of 5
Keywords: David Ondrej, david ondrej, AI, ChatGPT, artificial intelligence, ai, Artificial Intelligence, OpenAI, chatgpt, chat gpt, Chat GPT, Elon Musk, Sam Altman, sam altman, AGI, midjourney, david ondrej podcast, Emad Mostaque, GPT-4, GPT, AI revolution, python, vs code, vscode, chatgpt programming, python programming, chatgpt python, build anything with chatgpt, coding with chatgpt, chatgpt api, openai api, morse code translator, morse code converter, python tutorial, coding tutorial
Id: N_P4pJjVTKc
Channel Id: undefined
Length: 84min 4sec (5044 seconds)
Published: Sat Nov 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.