Learn How to Code - Programming for Beginners Tutorial with Python and C#
Skills:
AI Tools for PMs80%Prompt Craft70%PM Basics60%Prompt Systems Engineering60%Agent Foundations50%
Key Takeaways
This video tutorial teaches programming fundamentals using Python and C#, covering topics such as Integrated Development Environments, syntax, data types, and variable initialization, with hands-on coding exercises and examples in both languages.
Full Transcript
if you are familiar with jabril's you know that he is one of the most entertaining tech creators out there youtube the company asked them to create a full programming course and we are proud to be able to release the entire course as one video on the free code camp channel yo guys all my life i was told programming was hard it's only for the nerds it takes so much maths your grades aren't good enough but having programmed now for 13 years i can confirm that all these assumptions are false and that is why when youtube recently approached me with the opportunity to create an entry-level programming course i knew this was my opportunity to try and correct some of the misconceptions that i'm sure are still preventing average people like you from diving into the amazing world of programming but first things first we have to knock it off with this hollywood dramatic feel so you want to learn the code i mean i don't blame you forge ranks computer science as the second most valuable major to learn now of course you could just go to your school and learn how to program or you could just learn how to program from a dunce like me that has no traditional schooling background wait wait hold on before you click off this video and sign up for a course at your local university let me at least try and win your hearts with a quick story geez it all started when i was about nine years old my friend invited me over to play this new game that i had never heard about yeah man it's crazy you get to play as donkey kong if you want and fight against link mario and pikachu and sure enough he was talking about the original [Applause] on the nintendo 64. and like i had always played video games but there was something about this game that from that day on had me obsessed with video games i remember when my family moved from virginia to california in 2000 the whole drive across the us i was designing my own smash bros levels using a little pin in notepad and when christmas came around i asked my mother for a nintendo 64 with super smash brothers and i played that game for countless hours absolutely captivated with the concept of it all iconic nintendo mascots all together battling it out in a video game in three dimensions how was something like this even possible this whole experience is what got me interested in wanting to understand more about how video games work no not to learn how to program because i was still at that age while still learning to read write and do basic maths again it got me interested in wanting to learn how games work and remember this because this will become important later it wasn't long after that until i came across a little website called newgrounds.com a place where people like me were making simple low budget games and interactive movies and i believe this truly to be the experience that planted the seed in my head that making video games like the ones that i loved playing was actually possible for someone like me so a little later in life when i came across something called game maker which advertised itself as you can start making games today no code required and after weeks of begging my mother to buy it for me she finally did and man that was such a fun time in my life i had absolutely no idea what i was doing but just doing the best that i could to create logical statements that would make a computer do what i wanted to do was enough to get me hooked feeling that sensation of being truly tired for the first time because i stayed up all night trying to understand how to create an inventory system is something that i will never forget from that day forward i continued to learn as much as i could asking all for help who are willing to help me learning more and more not about programming but about how games work because you see understanding how games work is what initially drew me to programming in the first place and without even knowing it that is what i would always fall back on when times got rough during my coding adventures and so moral the story is i know what it's like to have an extreme urge to learn this stuff while being not exactly sure where to start so i know exactly what you're missing and how to get you on this side of the fence and thankfully i've learned how to do all this stuff without traditional schooling which means you and i we speak the same language huh now if that story didn't win over your heart you probably don't have one no i'm just kidding i'm just kidding but i'm sure that this will this here's my friend zarglar zarglar is a highly intelligent programmer that has no joke programmed literal entire star systems solo using only a ti-80 calculator and when i told zarglar i was going to be making a programming course he would not shut up about wanting to teach it for me now sarglar is a quintillion times smarter than i am but why do you not want zaglar to teach this course well watch this zarglar what is an array well you see we need a bit of a backstory because traditionally memory can only store information at a 32 bit rate which made recursion difficult to pull off but when moore's law gained traction in 1996 we not only attain more power and memory use okay zark you've proved my point this audience didn't understand any of that phd programming slangmate it's time to go and next time remember to breathe oh man so welcome to my course in this series you will leave with everything you need to start programming yes you've read the title right this is not clickbait in fact by the end of this course you will write your very first application utilizing everything that we learned but if you are to remember anything from this course please let it be this ask yourself why are you here what has drove you to want to learn everything you need to start programming again for me it was to understand how games work whatever your reason may be i encourage you to write that reason in the comment section now and if at any point throughout this course or hell throughout anywhere in your programming adventures things get tough i want you to return to that comment to be reminded on the reason why you started trust me you got this i promise it's a lot easier than you think and i'm going to do the best i can on the communication side of things to make it even easier for you on this course i will see you on the next part yes it's so tight to see that you've clicked on this video and are interested in learning some programming principles well i'll tell you one thing if you want to become a programmer you aren't going to get very far without this thing this is called an ide there are many many many different types of ides some from large organizations that you've definitely heard of like visual studio for microsoft xcode from apple and android studio from google but there are also ids from various other organizations as well pycharm from jet brains eclipse from eclipse sublime from a couple of dudes adam from github just to name a few and as you've probably guessed today's lesson is all about ides hey uh what does ide mean oh duh of course how could i forget to cover that ide stands for integrated development environment and just as the name suggests it's a digital environment used to develop games software hardware just about anything with code really that offers integration or control over many aspects of development from debugging which means adding removing or changing code that prevents your program from running as intended all the way to compiling which roughly means taking your code and turning it into something that computers can understand some ides support just a single language for example idle which is an ide that is bundled with the language python when you downloaded and it only supports python but ides like xcode from apple supports a bunch of different languages like c c plus plus java python the list goes on but as you see my point here is that there are many different options when it comes to choosing your ide and honestly it can be a bit intimidating but again if you want to start programming you need an ide later when you get more experience under your belt you can use microsoft word to write your programs if you really wanted to the whole i would not recommend this no matter how much experience you get you'll be wasting a ton of time and that is what an ide is a digital environment that is a very essential parts of programming whether you want to code some games software hardware you name it and ide is your best friend to help ensuring your success it's now time to install your first ide are you ready let's do it and heads up there are many different ides out there but instead of walking you through each and every ide which would be a very boring lecture to sit through you're instead going to get my bias and i'm going to show you how to install my two favorite ides microsoft visual studio which should interest you if you want to get into windows development or want to make games using a popular engine called unity and will also be installing microsoft visual studio code which should interest you if you're interested in more general programming or data science as well as a slew of other tasks and yes they both have microsoft visual studio in their name and yes they are two separate ids now let's get started alright so the first thing you're going to want to do is open up your browser i'm going with google chrome as my browser you can choose whatever you want this part's not really important but you want to search visual studio in the search bar and then click downloads you'll see visual studio.microsoft.com click downloads and it'll take you straight to the page that you want to be on so as you see we have here visual studio 2019 the community edition let's hit free download there and then you also have your visual studio code ide well hold on one second you'll see that it pops up down here lets you know that it's downloading and then i'm gonna go back and then i'm gonna click uh visual studio code uh free download this is the second id we need and it'll pop up down here let you know that it's downloading and you just wait for that to download all right once those are done downloading you can either click on them from here in a google chrome if that's what you're using and they will start to install it but if you don't have google chrome then you're going to want to find wherever your default downloads folder is in most cases it should be downloads in in windows c downloads but if not you're going to want to find that so that you can install the ides so first let's install visual studio code i'm just going to double click on this and you'll see that we get a window here that says welcome to the windows studio code wizard setup wizard and this part's really easy it's just like any other installation you've ever done you just hit next then you agree read it if you want hit next and then here you want to leave this at the default location which is like see somewhere somewhere program files likely but because i already have this installed on my system i'm gonna install this in a very special location so it doesn't mess with my presets um so yeah just leave that how that is hit next and then just hit next and here i would recommend that you check uh open with code and on both of them and also make sure that add the path is uh checked as well uh and what these two do here is allows you for like let's say you have some python script and instead of having to open up first visual studio code and then hitting file and then open and then searching for it you can just go to like let's say one of these are a python script you can just right click on it and then you'll have this available right here where it's open with code so it will just open that file directly in in visual studio code it's very convenient you can also do that with directories in case you have a a file i'm sorry you have a folder with a lot of python scripts you can just right click somewhere in the folder it open with code very very useful i would i would definitely recommend checking both of these and then just hit next now i'm going to go back and remove these because again i don't want to mess up my presets but this is how your yours should look with of course this the nest destination being c c program files whatever whatever and then after that just click install install and then you can see that um it's going to install so i'm going to take a couple seconds i'm going to take terribly long and bad boom there you have it visual studio code has officially been installed we're going to hit finish and launch visual studio code i'm going to bring this oops wrong window i'm going to bring visual studio code over here this is what it looks like now before we get started there's a couple of things that you want to do you do definitely want to add python right here so click install in fact i'm going to show you how to do it traditionally just search python and then install just python this allows you to uh use python with visual studio code and there are a few options to do that but this one is straight from microsoft so just install the top one that's just called python and another extension that we're going to need is called code runner just search code runner open the extensions and download the first one this is going to allow us to run our python scripts within visual studio code without having to leave the ide it's very nice all right and there you have it visual studio code is installed if you want to do a new file just go to file up top new file and bada boom if you want to save an extension you simply save the file anywhere we'll just do documents for example and just do like my my file i don't know dot and dot pi we'll get you a python script hit save and now it's recognized as a python script and if you get this pop up here that tells you that python is not installed visual studio code is often really good with letting you know like what you need and what you uh well not so much don't need but they're really good with letting you know what you need so let's hit download here it's going to pop up a new window we're going to want to download python 3.7 and then i'm just going to hit what run oh it's hit save open folder here and i'm just going to double click that to run it next all you want to do is just hit add python 3.7 to path and then just click install now and it's just going to install now give a little time and python should be installed and just like that setup was successful so back in our downloads folder i'm just going to double click the visual studio installer and i'm not sure what you're seeing right now but it's asking me to type in my password so i'm going to do that let's see hold on no it's not all the pin sorry all right sorry i went black there for a second and then we have um visual studio installer just hit continue and it's going to start downloading and installing some stuff shouldn't take too long then you should see something like this pop up and they're going to give you a few options uh you can ignore most of them uh maybe come back to them later when you get a bit more experience but all you really need is this one right here.net desktop development because what we're looking for is the console applications using c-sharp so just click that one and then you just click install and let's see install on system drive it's recommended again i have this already installed so i'm going to place this in a very special location but definitely place this uh installed on your system drive where it's recommended so i'm gonna hit okay and um you get this that pops up thank you for installing take a survey not now and this will start installing it's probably gonna take a little while but once it's done you won't have much to worry about all right and once it's at 100 give it a second uh it's going to start automatically because we had that checked and bada boom now you have welcome connect all your develop services developer services just hit not now maybe later at some point they'll force you to make an account anyway so just for now we'll do not now start microsoft visual studio preparing your first time use and here we are now if you want to create a new project you simply just hit that hit create a new project and then it'll ask you what type of project you want to make we're just going to do a simple see a console project in c sharp here and then hit next and you can name it let's just name it i'll just leave you how it is console project one is fine and create console app sorry i don't know how to read give that a second and bada bing it'll start up and now you're officially in and uh that's pretty much all that you have to do for c sharp so if you want to program in c-sharp and or python it's important to understand their syntax but first off what is syntax well syntax in relation to programming is pretty much a set of rules that must be followed in order of operation that your code must abide by a process that must be respected if you want your program to run and so today we're going to look at the syntax for two different languages and see the differences between them because i think it could be really helpful for you to see how they compare and contrast and plus you'll pretty much learn two languages at once and so on the left is the language c-sharp using the ide visual studio which should interest you if you don't do any windows development or want to make games using a popular game engine called unity and on the right is language python 3 using the ide visual studio code which should interest you if you want to get into general programming or data science alright so here i have two brand new console projects so the first thing we'll look at today is how both languages go about utilizing data types now data types by themselves are useless you have to assign a data type to a variable now to get started in c sharp over here on the left i'm just going to get rid of these two lines because i no longer need them they come stuck with every new project and then we're going to use a boolean as our example today now a boolean is a type of data that can only be one of two types it's either true or it's false so let's initialize a boolean in c sharp uh let's call it do it and then we're going to assign um true to it so do it equals true now this is all great and all do it is a boolean that we assign to be true however c sharp will not recognize it as a boolean unless you cast its data type and in c sharp you simply cast the data type by going before the variable which again our variable is to do it before you just type whatever the data type is so this is bull which is short for boolean bull do it equals true see our error goes away and everything checks out and this very syntax goes for every variable for example if you want to initialize a string variable you have to cast it so i'm going to say this is a string i'm going to call str short for string and then i'm going to assign hello to it for example you have to do this for every single variable however there's a bit of a catch so i'm just get rid of this line because i don't need it anymore you only have to initialize your variables on their first use so like if i wanted to change the do-it-bullion variable i just have to come down here now i need to do it equals false for example and that's because when on this line right here the program knows what the data type for the do it variable is it knows that it's a bull so i don't have to do it again in fact if i try and do it again you'll see that i get an error this error is pretty much just telling me that like i can't create the same variable twice essentially so just remember you only have to initialize on the first use and this convention is for every single data type so it's booleans as strings that's integers as floats every single one now over in python things are a lot different so let's say we want to do the same example we just want to initialize a boolean variable well in python all you have to do is just write the name of your variable and then assign whatever value you want to it so in this case we're going to assign true to it and there we go we just initialize a boolean variable that's right in python you don't have to cast your variables you don't have to cast the data type of what you want your variable to be like you do in c sharp and this benefit comes from the fact that python is what's called an interpreted language and what that means is all you have to do is create a variable and then assign some value to it and depending on what value you assign to your variable python will interpret what type of data type that variable should have and with this syntax it enables a lot of flexibility with the python language it's one of the reasons why so many people love python because it's kind of like a breath of fresh air as far as computer languages are concerned and it's one of the reasons why a lot of developers that are into data science would not use python because as you can see you can save a lot of time not having to type you know the data type over and over and over for your variables however the flexibility doesn't stop there i'm going to simply print out what do it equals like so save it hit the play button and you'll see that do it equals true obviously that's what you expected but check this out if we want to reassign it to be false for example we just come down and say do it equals false save it hit the play button and we have a false value but this is where it gets really cool so currently as you understand it do it is a boolean variable but we can do do it equals um 13 037 for example so first we assign true and then we change the mind assigned to false and then we change mine again and assign it to 13 37. when i hit play no errors it just prints out that it's 1337 the last thing we assigned it to which is crazy flexibility over in c sharp we simply cannot do that if we want to change the do it to be a um like an integer for example we're simply just going to get an error saying that you know you cannot convert an integer into a bool once that variable has its data type it cannot be changed and this is probably one of the biggest differences between c sharp and python at the fact of how they go about casting their data types next i want to get into command terminations and the differences between c-sharp and python first things first what is a command well for example this bit of code here is a command and what it's saying is take our do-it variable and assign a false value to it same with up here take our do it variable assign a true value to it and also cast it as a boolean these are examples of commands so on a very low level the way a computer works is that it needs to know when these commands begin and end so it knows what it needs to process and so that is where a command termination comes into play we need something to be able to separate all these different commands and in c sharp the command termination is a semicolon these semicolons right here is what you have to add to the end of every single command to be able to tell the computer that hey this command is over you can process this before you process the next one i'm grossly simplifying it but that's how it works on a higher level and so with that in c sharp so long as you have a semicolon separating your previous command for your next one you can place your commands anywhere you want for example i can move this this command right here to be right after the previous command no errors no issues i can put it back on the next line and hit tab a bunch of times no issues no errors you have a lot of flexibility using the semicolon as a command termination c sharp has a lot of flexibility in this regard using the semicolon as a command termination now over in python they differ here a lot as well so you might look at c sharp and see okay semicolon that makes sense as a command termination to a python what how do they do that well the answer is quite simple actually instead of using semicolons they just use a line break so if you want to separate two commands you just put it on a new line easy as that in fact to demonstrate we can't do what we did over here in c sharp if we were to put these right next to each other and then save it you'll see that in the problems tab it says that we have invalid syntax because you can't it doesn't know what's going on here why is there a value and a variable afternoon it just doesn't understand how ever python kind of thought of all the stops um you can simply just add a semicolon and voila it will now act as a command termination in fact just to prove that it does what i say it does i'm going to bring them all in the same line to command terminations and then i'm going to press play and show you that it runs it prints out 1337. so yeah in this regard this makes python really really flexible because you can use semicolons if you want to however you'll find that most developers don't because it's often a lot faster to just use the new line command termination instead of the semicolons and allow me to demonstrate that so i'm just going to restore both scripts to back how they were this is a new line this is a new line this uh i'm just going to do this um all right so now they're back to their back restored so the reason why you can save a lot of time is because if you look at the two different scripts they kind of both just use a new line termination anyway even if you were to look at more complex c sharp script often times you'll find that over 90 percent of a c script is going to use like a new line as a command termination anyway so you're actually saving a lot of time without having to type you know semicolon semicolon semicolon and you'll see that it turns red in this context because it's letting you know that it's pretty much useless like we know that you want to terminate this command by going to new line and then if we were to hit a backspace see it turns white because like okay now it's in use we understand what you're trying to do here but please note this is a feature that comes with the visual studio code ide so take that information as you want but do know that most python developers will probably look at you sideways if they see any semicolons in your in your code so yeah there are a couple of syntax differences there next i want to go over how they differ in code blocking so first question what is code blocking well i'm gonna come up here and see sharp and give you a quick example first and foremost the way that you indicate a block of code is to use these braces anything that goes inside of these braces is a block of code so the general syntax you don't have to follow this but most developers will put a block of code one line in the middle is all the code that will be ran within that block code and then a brace at the end and so here we can like just move our do it equals false into here for example and of course get rid of this one because we don't need it and just like that we have a block of code in c sharp however a block of code like this is pretty useless to add because it's going to be ran regardless however what blocking off code allows you to do is you can add things like for example an if statement so we can say if do it then set do it to equals false and this block of code will only run if do it equals true and i want to prove this to you so i'm going to come up here and i'm going to write console.writeline this is going to print anything that we want to the console and i'm going to say checking and then i'm going to come down here and then do it again i'm going to say console dot right oh wait what is that console [Music] dot write line there we go um i'm just going to set to false right and then at the end we need a console console.read key this just makes sure that the terminal does not close when we hit the start button which is up here and i'm going to press boom uh terminal's off screen i'm going to bring it up and there we go you see that it goes checking and then it sets it to false but you are not convinced because we blocked out this code and it still ran so i'm going to change do it equals false and watch what happens when i hit the start button and bring the terminal over here it just that says checking because again uh do it equals false and we said if do it which is another way of saying if do it equals true then run this block of code and at the fact that do it equals false this block code has never ran and that's code blocking you'll find that code blocking is very important and very useful for all things programming but that's how you do it in c sharp now over in python it's again a lot different i'm going to get rid of these two lines just to make it a lot less confusing and so everything under the condition and indented will be counted as that block of code all right now i'm going to run that and you will see that we get checking set to false and then we also had an extra print down here that i'll remove next time but that also prints out false as well and again you're not convinced because this block of code was ran anyway so we're going to set this value to be false and then i'm also going to remove this just so it's not confusing when it prints and then save hit play and only checking and so that is how you do code blocking in python and so as you can see code blocking is another syntax that c sharp and python have a lot of differences between but it's very important to know how to code block in both languages because you'll be using it quite a lot for for loops for if statements for methods functions all types of stuff and the very last thing that i want to go over today is what's called variable scoping so what is variable scoping well with the introduction to code blocking that's this right here a block of code remember this is a block of code as well well more right here this is a block of code but with the introduction to these blocks of code now you have to worry about the scope of your variables so let me give you a quick example so let's say inside of this block of code here we want to initialize a new variable let's initialize and just do an integer we'll call it a just for an example and then we'll assign a zero value to it right well because we initialize this integer variable within this block of code it cannot be used outside of this block of code and to demonstrate i'm going to come down here and i'm going to do outside of the block of code console.rightline oops brightline a for example and you can see what happens is it says that this variable does not exist what do you mean it doesn't exist though we initialized it here well again like i said this variable because we initialized it within this block of code cannot leave this block of code if we wanted to leave this block of code we have to do it like this we come out here oops we come out here and we initialize int a equals let's just say five for example and then inside of this block of code we just change we just reassign it back to zero so because it's it's initialized within this block of code which is our main function we can use it outside of this block of code and that is variable scoping in a nutshell now over in c sharp this syntax is no different so if we were to come inside this block of code and initialize an a assign a zero to that and then come outside of this block of code and try and print that a variable you'll see that when we save and hit the play button that's we get an error syntax error saying that this a the variable a is not defined and again if we want to get around this we have to change the scope of the a variable so come out to the regular indentation and just do a equals five for example and then when we get into this scope we're simply just going to reassign it change it to zero and then we'll be able to print it and approve that i hit save and then i hit play and there you go checking five and again just want to make sure i cover all bases the reason why this prints out checking 5 is because we said do it to equals false and if do it is true then this block code will be ran but because do it is false this block code is not ran so it just skips this entire thing and it just prints out five which is what we assigned a2 and that's pretty much it that is everything that you need to know to start programming in regards to the syntax and so in conclusion even though c-sharp and python have differences in their syntax as you can see the differences are small enough to be able to remember the important stuff you have to cast data types in c-sharp python you do not and c-sharp you must use semicolons to terminate commands python uses new line breaks and c-sharp uses curly braces for code blocking while python uses indentation of course there are more differences in their syntax but these are the major differences that often confuse new developers all right all right all right it's that time to code your first program are you ready to do this get set let's go so we're gonna make a simple mad labs application in the console because it's simple doesn't require you to install a million things and it's something you can actually show off to your friends and family now before we jump into this first things first the code to this project is in the description also i think it's important to let you know that this lesson is kind of acting as a placement test if you're just beginning to program you might struggle with understanding what's going on in the code and if that is you well that's okay because i structure this lesson to be just a little bit difficult to follow once able to code a project like this by yourself then i don't think there's much this course can teach you at that point but i encourage you to watch the whole thing and follow along anyway again the code is in the description so you can just refer to that and follow along with me because if you do the following you will get the greatest inspiration to become a programmer after you struggle i encourage you to go through the rest of my course linked in the description or just check out the lessons on the stuff that wasn't easy to follow i have over 20 videos teaching you how to code and those videos go in depth about their respective topics then when you feel comfortable come back to this lesson and see how well you do a second or third time coding your first project and trust me when you're able to look at how much you didn't understand in comparison to the next time you try and code reverse project you will not want to stop programming having programmed for 15 years i can tell you that feeling pretty much summarizes programming very well it can become quite addicting to chase but an addiction in the best way possible however if this is your second or third or more times coding your first project i encourage you to not copy the code verbatim but maybe create your own story or add if statements and functions to this mad labs game who knows your experimentation could start a whole new programming trend lastly if you want to share your project with me feel free to tweet it to me and i'd be happy to reply back to you but now with all that stuff out the way let's get started on coding your first program and we're gonna make this application in two different languages because i think it can be really helpful for you to see how they compare and contrast and plus you'll pretty much learn two languages at once so on the left is a language c sharp using the ide visual studio which should interest you if you want to do windows development or if you want to make games using one of the most popular game engines called unity and on the right is the language python 3 using the ide visual studio code which should interest you if you want to get into more general programming or data science all right let's actually begin writing our madlibs program now before i write any project or program or prototype what have you i usually like to start what i like to call a skeleton and what a skeleton is it's pretty much just like a step-by-step process in which you can expect to have to do in order to complete the actual project and because this is a smaller simpler program we can simply do this by writing out a few comments so first i'm going to comment out uh initialize variables and it just stands for initialize it's shorter quicker to write then after that simply gets input from user so we're going to initialize the variables and then we're going to ask the user to fill out the data for those variables and then after that we need to initialize oops and knit story um and then after we initialize our story then we simply just need to print our story and in four parts our program will be done simple easy and to the point and now let's just do that same thing in python and do a comment and then init variables and then get oops get input from user and then after that we're going to emit our story and then after that we need to print story easy as that next thing i'll do real quick is just beautify our script i'm just going to add spaces between all the comments it just helps me read it and understand the different processes that need to take place perfect all right moving on uh now before we can do anything uh over here c sharp on the left we kind of need our story because everything depends on our story really so i'm gonna paste in a quote from the matrix i'm just gonna highlight all this real quick and hit tab a couple of times to beautify it make it easier for me to read but you are welcome to make up your own story you're welcome to grab anything from the internet whatever you want to use your mad lib story is completely fine i even put this story in the description if you want to use it as well but there we have it this is the story that we're going to use for c sharp and now i'm going to do the same for python just paste in that story string same exact thing just in the python format next thing you want to do is simply just print out our story and in c sharp you're going to want to do console.writeline and then madlib story mad lib story boom semicolon done and in python we're going to want to oh wait i'm going to change this to say mad lib story just so that it's the same mouthed matlab story perfect and in python it's really simple you simply just type prints and then mad lib story boom so next what we want to do is get input from user but we can't really get any input from the user because we have no variables to pass to the user to collect data from and so what our next actual step is we have to initialize our variables so that we can pass that to the user and to initialize our variables well we need to turn our madlib story into a bunch of variables and we can do that quite simply if you're at all familiar with the game mad libs then you know the whole fun of the game is that you have some story or some text or something like that and you replace all the verbs the nouns the adjectives etc with words that are similar context hopefully but not exactly and it makes for like really funny interesting stories and so what we want to do is we want to scroll through our text and essentially replace verbs nouns adjectives with variables and the first one i'm going to do is the matrix i'm just going to put curly braces around this oh yeah i need to make this into an interpolated string i'm gonna do that for all of these strings and this needs to be a variable which is one word the matrix boom uh and so i'm simply going to come to init variables i'm going to initialize the string data type and put the matrix in there and now the matrix is a variable that we can ask the user for and they can change to whatever they want and i kind of did this ahead of time i went through the text and picked a lot of verbs nouns adjectives that i thought would be interesting to change um so i'm going to go through and do that for example system is another one i'm going to change system into a variable just going to add that to this list and i'm just going to do that for the entire text i'm going to skip it though because it's not that fun to watch all right so i went through my story and replaced all of the interesting verbs nouns adjectives etc with variables so that we can pass that to the user and they can put whatever words they want there but now i want to show your first optimization trick if you look at this line here the sentence as businessmen teachers lawyers carpenters these are all professions that's that's what they all have in common and at the fact they go back to back to back we can do this really cool trick where we will initialize the string array and we'll call them profession and then oh boy i have to initialize it equals new string array of how many are there one two three four of four and so now we can do this really cool trick where we come in here and just make this an interpolated string and i'm gonna lowercase that just for good practice businessman and oops sorry that's not what i meant to do i wanted to do profession zero because we're gonna do a for loop which i'll get into in a second i'm gonna copy this because i am lazy and i'm going to paste this here i'm going to increment it and then i'll paste this here and then i'm going to increment it to 2 and then the final profession i'm going to increment this to three already start on zero simple and to the point and so now what we can do is when we get input from user since there are four professions they're all back to back we can simply just write a simple for loop and ask the user for four different different professions one after another and i'll show you how to do that in a bit but there's also two adjectives down here that i also want to do this with so i'm just going to initialize a new string array call this adjective a j a d j short adjective equals new string array of two there's only two in there and so here turn this into interpolated string it's going to be a d j zero and i'm gonna copy this because i am lazy and this is the second adjective i'm just going to increment and there you have it we now have our two string arrays uh and final note if you look down here you'll see a bunch of errors for unassigned local variables and that's only because we have not assigned these variables to anything yet i believe they're they're null at the moment which your program does not like but we will be assigning the variables when we get the input from user and over in python on the right it's a lot of the same uh first let's turn all of our strings into interpolated strings and it's just like c sharp except it's an f instead of a dollar sign so i'm going to add an f to all these strings perfect and let's pop out this variable right here the matrix or rather let's turn this into a a variable i'll call it the matrix and then let's initialize it up here i'm going to do the matrix equals empty string all right and then let's do system next interpolate interplay string system and then system like this paste equals empty string and i'm going to go through and do this for all the interesting verbs adjectives and nouns in this text all right so i pulled out all the interesting words and turned them into variables and now i'm going to show you how to do that optimization trick over in python so again we have these four professions and we want to turn that into a string array and to do that in python we're going to do profession equals brackets and there are four of them so we're going to do empty string empty string empty string empty string four empty strings and there we have a an array with four strings in it that we can pass the user and then they can change the beer whatever they want and it's the same as a sharp person use interplay to string profession zero i'm lazy i'ma copy this and paste it here increment it paste it here increment it paste it here increment it oops yeah it is three and then we also want our adjective array which is only two so we're gonna do brackets empty string and then another empty string two empty strings and then that goes here which is a edge zero i'm going to copy this because i'm lazy and then paste it on dependent and then increment that and bada boom now the scripts are in the same exact state all right the final stretch let's get that input from the user so first of all there are two functions that we need to familiarize ourselves with one we've already went over and that is console dot write line this is what we're going to use to print something to the console and the second one is console.readline this is where we're going to use well there's no input parameters but this is going to return to us a string that we can set our string variables to and this comes whatever the user types into the console presses enter that's what's going to be returned with console.readline so for example we can do the matrix equals console.readline it's easy as that so let's get started i kind of ahead of time crafted a little interesting story that the user can have with the terminal just to make sure i'm not stumbling on this part but uh let's start off with console.writeline uh let's just do like welcome user welcome user and then we can go down to another one console dot right line and then let's say let's play let's play a game of mad libs and then after that we can get their name so we can say um let's do another console.writeline and then please share with me your name and then here is where the terminal is going to stop and allow them to put in some input so here we can do um neo since that's the name of the the character in the text equals and we can do console.readline and whatever they return here is what the variable neo is going to be set as and just in case you don't believe me let's actually run this program and see that being printed on the screen um first thing we need to do though is with all these errors it won't allow us to actually run the program so let's just comment out this entire thing um whoops hold on a second i need to do that and comment this out come with that one all the way down the line so this doesn't get compiled and then let's replace this for now with uh with neo so whatever name that we we uh passed to the terminal it's just going to spit that right back at us and that's going to prove to you that we're able to set variables this way so i'm going to come up here to the top and hit start and my window actually goes out of frame i'll bring it on screen so as we put hello welcome user let's play game of mad libs share with me your name and i'm going to put my name jabrils up of course it's going to exit because we also didn't tell it to pause so let's um i think we do console.wait for no let's just do another read key console.read key that's going to wait for a key press and then it's going to exit the terminal so run it again bring it back on screen welcome user let's play a game with mad libs please share with us your name i'm going to put bros and it prints right back to us the same variable that we put in which is lets you know that it's actually working so now i'm just going to revert back to its original state and we can do z control z control z control z control z just a bunch of times and we are back well add semicolon and we are back to our original state and if you don't have control z i think on apple it's um apple z i believe uh but if you don't have either those buttons you can come up to edit and then hit uh undo up here and that will do the same thing that i did with my shortcut on the keyboard also real quick uh let's add at the very end of our process let's add console console.readkey this will make sure that it pauses the application before it quits okay so now over in python let's start to get input from users um so what we want to do here is instead of writing console.writeline again it's as simple as prints and we can do print welcome user come down to another print let's play a game of mad libs and then another print and say please please share with me your name and then we can simply do neo equals input well technically technically we can add this string into input and it'll be the same exact thing so we can do this and it it will print and then whatever the next line is it will get that input however we do need to add a line break here otherwise it's going to it's going to allow you to type right after uh the question mark we want to go to a new line just to make it a bit more cleaner and so now the cool thing is now that we have our actual name set in the variable neo we can use that with our printing function so if we do console.writeline for example uh let's interpolate the string and do hello and then we can do here neo and then exclamation point and then let's say something like uh are you ready are you ready and then what is something you want to know more running out of space so let me go to next line more about you learn how to spell more about and then next line when they answer what they want to know more about we can put that into the matrix so oh i found my semicolon so we can do the matrix equals console.readline easy as that and over in python it's pretty much the same exact deal we'll do print uh what is it when you interpolate the string with f hello and then this will be neo whoops neo and then are you ready are you ready and then actually i'm going to break this off whoops i'm going to break this off into another print actually i'm going to make this an input input and then this is uh what is something you want to know oops to know more about and of course we need to do the matrix variable equals whatever they want to know more about so just to make sure that you're still with me just remember that the only thing we're currently working on is get input from user that's this section right here ever
Original Description
This course teaches you everything you need to start programming! 💪😤
You will learn the difference between Python and C# and learn coding fundamentals.
✏️ Jabrils created this course. Check out his channel: https://www.youtube.com/c/Jabrils
Resources:
💻 Code: https://github.com/Jabrils/Everything-You-Need-To-Start-Programming
📄 Matrix Quote: https://github.com/Jabrils/Everything-You-Need-To-Start-Programming/blob/master/04-01%20-%20Your%20First%20Project/matrix_quote.txt
Install IDEs on Mac:
🔗 Visual Studio (Execute Automation): https://www.youtube.com/watch?v=DS4zGjyo4Zs
🔗 Visual Studio Code (Derek Banas): https://www.youtube.com/watch?v=SKV0npCFxFs
⭐️ Course Contents ⭐️
⌨️ (0:00:00) All my life I was told programming was hard
⌨️ (0:06:32) What is an IDE?
⌨️ (0:08:55) Installing Your First IDE ‼ (Windows)
⌨️ (0:17:29) The Differences Between C# & Python
⌨️ (0:34:44) Code Your First Program!
⌨️ (1:22:37) What Are Data Types?
⌨️ (1:26:29) What is a Bool?
⌨️ (1:44:57) What is a String?
⌨️ (2:07:14) What is a Char?
⌨️ (2:26:49) What is a Float?
⌨️ (2:42:41) What is an Array?
⌨️ (2:57:31) What is a Variable?
⌨️ (3:13:23) What is an If Statement?
⌨️ (3:21:55) What is an Else Statement?
⌨️ (3:30:11) What is an Else If Statement?
⌨️ (3:39:31) What is a For Loop?
⌨️ (3:53:36) What is a While Loop?
⌨️ (4:01:11) What is a Method?
⌨️ (4:27:40) What is a Function?
⌨️ (4:47:31) How to Comment Your Code!
⌨️ (5:03:28) You can code anything you can imagine!
🎉 Thanks to our Champion and Sponsor supporters:
👾 Wong Voon jinq
👾 hexploitation
👾 Katia Moran
👾 BlckPhantom
👾 Nick Raker
👾 Otis Morgan
👾 DeezMaster
👾 AppWrite
--
Learn to code for free and get a developer job: https://www.freecodecamp.org
Read hundreds of articles on programming: https://freecodecamp.org/news
❤️ Support for this channel comes from our friends at Scrimba – the coding platform that's reinvented interactive learning: https://scrimba.com/freecodecamp
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
Dates - Beau teaches JavaScript
freeCodeCamp.org
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
The Definition of Ready - Agile Software Development
freeCodeCamp.org
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
Working Agreement - Agile Software Development
freeCodeCamp.org
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
Definition of Done - Agile Software Development
freeCodeCamp.org
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
The INVEST approach to product backlog items
freeCodeCamp.org
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org
More on: AI Tools for PMs
View skill →
🎓
Tutor Explanation
DeepCamp AI