The Complete Python Course For Beginners

Tech With Tim · Beginner ·🧠 Large Language Models ·6y ago

Key Takeaways

This video course covers the basics of Python programming, including data types, variables, operators, control structures, and functions, providing a comprehensive introduction to the language for beginners.

Full Transcript

hello everyone and welcome to the complete python course this course is designed to teach you everything you need to know about the Python programming language this is going to assume you're a complete beginner you have no knowledge of python and bring you through right from the beginning all the way up to expert and advanced level features so this course is actually a combination of a bunch of videos that I've created over the past few years it starts with beginner Python Programming goes to object-oriented programming then into intermediate and advanced level features so those are the four main section of this course it's kind of split up in those four sections and within those sections there's a bunch of topics now if you want to figure out what section to jump to or you want to see what's involved in the course look in the description there'll be a bunch of different timestamps that show all of the different topics that are covered and feel free to skip through and go to the ones that you find the most interesting so with that being said this video is taking a very long time to compile and create so I would appreciate if you guys leave a like you subscribe and you consider becoming a channel member if you want to support me on a monthly basis so with that being said let's go ahead and get into the full python course hey guys so welcome back um today I'm going to be doing a Python tutorial Series so this is the first episode in the series it's kind of an introduction showing you how to download python how to install it and then going into data types and variables so the first important thing to understand about the Python programming language so don't worry if you've never programmed before um I'm going to be going over everything very slowly and in depth so that you can understand I recommend that you follow along with everything I'm doing in the tutorial uh pause the video at certain points rewind if you don't understand um it's important you understand these parts so that we can move forward into more complex ideas so obviously the first um thing that we're going to have to do if we're going to learn python is we have to install it on our computer so uh we're just going to go to the python website up here python.org downloads right here and all you're going to do is just click download python 3.6.1 now I'm not going to do that because I already have python installed and downloaded on my computer but pretty much once you uh download this it's going to pop up down here in your downloads folder just run the exe it's very simple um and you'll be running python in no time so now pause the video go ahead and do that and then we can go to the next steps okay so once you've done that you're going to notice that you have an application that looks like this it's called idle um Python and then it'll have the version so I'm using version 3.5 um don't worry if you have a version that is larger than that so 3.6 or even one that's before that most of the things that I do in this will work in all the versions of python okay so go ahead and run the idle you'll notice the first thing that pops up is the python shell as you can see at the top here the shell now this right here is not where we're going to write all our programs it's the console kind of so here I can type any lines of code for example I want to print a name like this and it'll run right away so that's not what we're going to do you can play around with this if you want but we're going to go to file and we're going to click new file and then here we go so now we have a new document that we're going to be working on and we're going to be programming in so I'm going to go ahead and I'm going to save this right away as tutorial one into my tutorial folder which I believe is on my desktop right here yep right there awesome okay so there we go we've saved it and now we're ready to learn a little bit about data types so pretty much python is a fairly basic language in comparison to a lot of other ones a lot of things that it does is uh more simple than other languages but it is important to understand the basic data type so there's four main data types in Python there is a few more but we're just going to talk about these ones right now um the first one is an integer so that can be uh a short form int that stands for integer now um an integer is any number so such as 1 4 76 any whole number it's important that is a whole number it could be a negative number as well5 um zero those are are all integers okay now we have strings now the short form for Strings is St now pretty much a string is anything embedded in quotations so like this uh this is my name Tim that is a string and then we also have something like this this would be a string and even like this this would be a string so although there is a number in here since it is between these two quotations here it is a string so even if I did another number like like that string um now it's also important to understand that it doesn't matter if you use the single quotations or the double quotations sometimes we use the single quotations because inside of our actual quotations we want to use double quotations or maybe um if we use the double quotations because we want to use the single quotations inside of our actual string like that okay so those are just a few examples um now we have Boolean variables uh or data types sorry so Boolean data types is something like true and false so true and false pretty basic um these are reserved words in Python um meaning that they're highlighted in yellow and that you cannot use them for variable names that's going to be important later on um just know that they are important words uh true and false and they do start with capitals so um for example if I typee true like this uh it's not highlighting Orange right so that's because true um in Python the keyword for that starts with a capital so true and false um then we have the um decimals which are the float uh data type like this so anything with a decimal floating point so 1.23 um anything like that any decimal number with a floating decimal point uh would be a float okay so those are the four basic um data types um there is a few more that I'll go on to later on but you just have to understand these ones right now so now that we know these data types I'll give a quick little quiz here so I'm just going to put a few things right here and then I want you to pause the video and go ahead and try to determine what type of data type these things are okay so go ahead pause the video and then I'll go over the answers in a second okay so we'll start with the first one here uh hello it's the same example that I have up here except in single quotations so we can see that it is a string data type okay so that is the short form Str Str now we have the number 123 that would be the integer data type we have another number here that has a decimal point so 3.22 that would be a float we have the keyword true this data type is a Boolean data type then we have two in quotations this is very important we don't want to get this mixed up this is a string some people may think that it's an integer because it's two but no it actually is a string because it is inside of the quotations and then same thing here three inside of the double quotations again is a string not an integer okay so now that we have an idea of the basic data types um I'm going to show you how to create a variable so pretty much you may have heard of variables before in math or something like that um in math we tend to use X as a variable we say x may be five x may be four anything like that um it's the same thing in Python now declaring a variable in Python is very easy all you have to do is type the variable name so in this case I'm going to use name and then simply give it a value so this value as you may remember is a string this is my name and I'm just storing it in the variable name now if I want to access that variable I want to see what that variable is I can print it to the console by simply typing the variable name which is name so now we'll see what happens um if I run the program just going run run module I'm going to use F5 from now on so that's the uh thing and you can see it prints out Tim just like that okay now um say we did that we have name equals Tim we printed it to the screen now maybe we want to change that variable well it's very easy again all we have to do is just type the value name and now maybe we're going to change it to Bob and now we want to see what the new VAR new variable is so we will print it to the screen we'll print name cck F5 to run that and we'll see name and or sorry Tim and then Bob so like we have here name equals Tim print name name equals Bob print name right so we've set it like that okay so that's pretty basic um now you can create variables of different data types so for example if we had a variable age I would use an integer data type so like 18 for that variable and then again if I wanted to print into the screen I would type print and then the variable name like that okay 18 perfect right so we printed that to the screen um again if the variable names um there's a few restrictions on variable names so here you just see I've used three lowercase letters um your variable names can contain underscores um they cannot contain dashes um they can only contain underscores text and they cannot start with a number I believe so if I try to do one one name equals 2 for example I run into an invalid syntax error because we can't name a variable starting with a number now I can end it with a number I believe let us try yep so that's fine it's let us do that name equals one I could do name underscore um person maybe yeah namore person you see if I run that program everything's fine there um but I can't put something like a star in my variable name you see how we've got an invalid syntax there right this is because these symbols represent something else in the Python language so just know for names um we can use capitals if we'd like I could use name like that run the program that works fine but I cannot start it with numbers so I cannot put a number there um and I cannot contain anything other than underscores texts and numbers in or at the end of the variable name now here's a quiz for you if I make a variable called name and do another variable called name um are they the same thing now that's a good question um are these two the same thing um no they are not the same thing so capitals do matter in Python the all capitals variable name is different than the variable name so again name like this is different than all of those variables there okay so I think I've covered um a little bit on variables and data types today um this is the complete Basics just wanting to get everyone caught up um in the next video we'll go into some more advanced things maybe uh operations of variables adding them together subtracting multiplying um buing conditions things like that okay so I hope you enjoyed the video today um stay tuned and we're going to have another one out tomorrow um and like the video if you if it was good and subscribe so yeah thank you hey guys so welcome to the second video in the series um if you remember in the last video we talked about data types and variables uh we went briefly into some of the things that python can do um today I'm going to be talking about operators and we're going to be doing some print statements some input um a little a few small console applications just applying some of the knowledge that we've learned so pretty much the first thing I want to do is I want to go back and I want to review what we did in the last lesson very quickly so we talked about variables and data types so for example the X variable we could set it to something equal to two like that uh a name we may equal to our name right so I make that equal to Tim um so there we go we have the name right there equal to 10 we'll start with that okay now if you remember in the last one I didn't talk about this but I used something called print now the print statement pretty much takes an argument so inside of these brackets the thing that is inside that brackets is called the argument so it takes a uh a string argument usually so I will give it the name so now you'll see again we did this in the last one just want to review I'm clicking F5 simply to run the program when I go to the console it simply puts Tim onto the console just like that right okay um very basic we already did that so now let's say well we want to do something else so let's let's print here and we're just going to put a string and we're just going to type this in ourselves so let's say hello comma what is your name that's going to print to the console now we want to get what the user's name is now there's a way to do this in Python it's very simple we're going to make a variable name it makes sense to put the variable name here and do an equal sign because it's a variable right we're going to type the word input just like this now what's going to happen if I run the program here I'll show you is it's going to say hello what is your name and it's going to actually allow me now to type into the console which I couldn't do before now nothing happens after when I click enter because we don't have anything else after that but it's allowing me to type okay so now well we want to print out what the name is that was said so let's just simply type print and then name all right and we have hello what is your name I say oh well my name's Tim it says Tim all right now well we just printed out the name but maybe we want to go a little more advanced than that we want to say well hello Tim how are you doing Tim something like that right so I'm going to just put a comma here going to separate these two things and I'm going to put in a string and I'm just going to type what I like to type so I'm going to say hello with a comma and then you see that I have this other comma here that is outside of the quotations meaning it's not a string it's actually just separating the two arguments in here and you'll notice what happens now when I print is it goes hello what is your name so I say oh my name's Tim it says hello Tim right so that's pretty straightforward I hope that's easy to understand we're just using the input to get an input and then we're printing it back out to the screen okay so let's do um let's go into the next part of this now we'll use that again later but let's talk about operators so operator that term may sound familiar to you um in math uh we use things called operators so these four operators hopefully should look familiar to you um this is a plus sign this is the addition operator we have the minus sign which is the subtraction operator the division sign which is the well division operator and then the multiplication sign which is again the multiplication uh operator so there's a few more operators that we'll talk about but these are the four basic ones in Python now you remember how I talked to you about data types this is where this comes in when we use these operators it's important that we use them on certain data types so for example um in math I could do something like 3 + 4 right so what is 3 + 4 equal well that is equal to 7 so the computer can actually do that math operation by using that operator to return those values so let's let's give an example here quickly so I have uh let's do num one we're going to use variables here uh remember I can use a number in the variable as long as it's not at the beginning and I'm going to give it a value of 45 and then we'll do num two and we're going to give it a value of three now if I want to print to the console um let's say num one plus num 2 well you can guess what that's going to give us it's going to give us 45 + 3 I hope if this is not an error yeah so that gave us 48 right so oops didn't mean to make that full screen num 1 plus num two is 48 all right so now what about minus let's try this 42 basic um we can do multiplication here with the multiplication sign there we go 135 and then we'll try again with the division sign just to show you all of them we get 15.0 like that okay so that's pretty straightforward um those four basic operators now in Python there's a few more operators that we want to talk about now for example in math we have something called exponents right so how do we do exponents in Python well it's actually two stars is how you do an exponent all right and now maybe there's something called integer division um which I'll get into later but I'll just show you the operator for it right now it's two slashes that means uh I'll give you an example a math example here 64 / by um let's do 10 um would give us usually in math a value of 6.4 right that's if you use one division sign sorry what am I doing times I mean divided by would give us 64 I have 6.4 but now if we do two division signs here like this it actually gives us a value of six that's because it just um it doesn't worry about the remainder at all it just tells us um how many times 10 can go into 64 um and that's all it can go in six times evenly so it gives us a whole number as our answer that's called integer division this double double slash like this okay and then we have another operator which is actually the modulus operator um so this is the percentage sign and this gives us the remainder so here if I do five 5 modulus 2 then the remainder of that is actually 1 because 5 / two is four then with a remainder of one right so it's not going to give us the decimal points it's again just going to give us the remainder if I did five / by four again the remainder is one 5id by 3 the remainder would be two like that okay so that's what the modulus sign um gives us so we'll put modulus here and then there's probably a few others that I'm forgetting about but we can go into those later so now um same thing let's keep using our number variables here and now let's introduce a third variable called num3 now um I want to show you how we can use the variables so num one and let's see if you remember what this operator is uh so that's the exponent operator so that means num one which is going to be our base uh which is 45 raised to the power of four because we're going to use num two and we can print num three press okay and you can see we get a pretty large number um that's because of how exponents work and then same thing here if we want to do maybe integer division see what we're going to get we get 11 right a whole number and then say we want to do modulus we get one okay so now let's tie all these things together with the operators that we've used the variables the prints and the inputs so um let's start by just get doing a little print statement and saying pick a number okay pretty basic we're going to pick a number and then we're going to take the input so we're going to say num one again is equal to the input of that okay so we got the input in Num one um now let's say print pick another number all right so now we're going to pick another number so we're going to do num two is equal to input like that and now what we're going to do is we're going to introduce our third variable so we'll call it sum because we're going to add these is equal to num one plus num 2 and now actually you can't use sum because it's a reserve word so let's just do in all capital sum because remember how we talked about variables capitals and lowercase are different and then we're going to print to the console the sum like that okay so we run the program says pick a number uh let's pick a number let's say four and let's do 32 now what do you think it's going to be oh oops okay so yeah someone equal num one plus num two okay so this is why um I talked about data types so I'm actually uh Happy this happened it's because what actually happens when we get the input of something is it gives us the type of a string um which in this case is not what we wanted to do so um you saw there I'll run it again um it's a good mistake that this happened actually we have four and we have a three and it gave us 43 that's just because we added the string four to the string three um so that simply gave us 43 but now we know in actual math that 4 + 3 equal 7 so if we want to do um the integers we have to actually convert these variables into integers so in order to do that remember I showed you the keyword um int like this before we're just going to put brackets around our two variables here like this integers and now hopefully we should get the correct answer when we do four and we do three and you can see we've got seven so um I didn't mean for that to happen originally but I'm happy it did because it shows us why data types are important so when we take the input of something we're typing it from the keyboard and that is actually a string so um here we can print again um don't worry about what I'm doing right now but I just want to show you the type which is going to give us if it's a string if it's an integer of num two just to show you what the type actually is so we pick a number we pick two and we pick three it tells us that three is actually a string so that's why when we added originally three and two or two and three or whatever it was um it gave us just them added together so two and three rather than what it should be which is five okay now same thing here if we had a number and we wanted to convert it into a string all we would do is we would type Str Str around the number so for example three and then that would give us three just like that so A String so now we've kind of gone over a conversion of variables um conversion of numbers data types how to get input from the console using the input like this um and some basic operators of python so uh review this I hope you followed along and then in the next next lesson we'll move into some more advanced operators and we'll maybe start with conditions okay I hope you enjoyed uh please subscribe like the video and I'll see you in the next video hey guys uh welcome back to the third video in my Python Programming tutorial series um today we're going to be talking about something called conditions so I hope you remember from the other videos we talked about input printing we did variables data types and then we talked about operators so operators like plus minus um division integer division modulus right uh multiplication all those operators today we're going to be talking about a few more operators and then getting into conditions so here in my file right here um I've put down four basic comparison operators so pretty much a comparison is something that's going to return a value of true or false so here we have um let's say if a real world example is Tim equal to Joe well no they're not because Tim obviously spelled differently than Joe so that's going to be giving us a value of false um same thing if we want to go into numbers we say 18 is greater than two well is that true yes it is so that condition gives us a value of true uh it's a very simple concept but it's something that we have to understand as we go into decision Visions later on which will be in the next video okay so these comparison operators I'll read them off and just kind of give a definition of each of them so the first one can e be a less than or a greater than sign uh same thing with the second one right so it's just going to compare if something's less than greater than um usually these are used for integer values um that data type uh we also can use them for Strings but it's a little more complex and I'm not going to get into that right now maybe in a more advanced tutorial later on now the equivalent operator so the equal sign here now a lot of people think well if I'm comparing something why wouldn't I just use one equal sign like this well that's a very good question and a lot of people get mixed up on this it is actually two equal signs that's because in Python um the one equal sign is a declaration um declaration operator so for example if I put a variable X and I want to set it equal to four right um this is is what we do with the one equal sign we're setting values right so when we did name is equal to Tim things like that we're using one equal sign now if we're going to check something we're going to compare them we have to use two because two equal signs and one equal sign have a very different meaning so it's important to keep that in mind that the comparison operator for equivalency is two equal signs okay the next one is not equal to um so we have an exclamation mark and then we have the equal sign like this okay so an example of not equal to because some people may get confused here is say if four not equal to 5 oops what did I type there not equal to 5 okay so what do you think this would give us just think about it for a second well what it's actually going to return to us is true because the condition is if four is not equal to 5 and here we can see obviously four is not equal to 5 so now again if I give another example we put five here we say five not equal to 5 well that would return a value of false because five is indeed equal to five now we can do the same thing with strings so for example we have hello oops spelled incorrectly there we go and Tim uh now you can probably guess by yourself that this is going to return true because him is indeed not equal to hello okay uh it's pretty straightforward um but a lot of people may get mixed up with the not equal to if it's returning true or false okay so those are the four basic comparison operators that we're going to use so we have equal to U not equal to and then greater than and less than so greater than and less than again we use for numbers so one less than two again that's going to return true like that okay so now um we're going to start printing from some things to the console and maybe doing a little bit of a quiz here um just to see how you guys are going to do so a booing condition I'm going to store it in a variable so I'm going to say name uh oops actually we're not going to do that we're just going to print to the console 2 less than three okay now you guys guess and uh tell me what you think is going to be returned to the console it's either going to be true or false I'll give you a hint right now now it gives us a value of true that's because this condition 2 is less than three um is true it's equal to three right um so now if we switch the sign and we make it greater than like that well you can guess what's going to come up so we click enter and we get false that's because this condition returns a value of false okay now we'll do another condition here all right um hello equal to Hilo okay um and guess yourself what this one's going to return false okay that's because they are spelled differently um now we're going to do the not equal sign just to show that one as well hello not equal to hello and we'll see that gives us true because they are not the same um fairly straightforward but a lot of people do get these things mixed up now I'll show you what happens when I try to just do one equal sign like this see we get keyword can't be an expression that's because we're trying to declare a variable here but we cannot do that okay because we're just using one equal sign here we need to use two all right okay so now let's try another example maybe a more advanced one uh this is a little bit of a trick okay I want to see if you guys remember from my last tutorial what I talked about so take a guess right now what you think is going to be returned you think it's going to be true or do you think it's going to be false well it was false okay um that's because again what we talked about in Python um capitals matter right so any capital letter is different than a lowercase letter so something like this um yeah it's going to return false all right it's important to understand that okay so we' very briefly uh gone into conditions now um I'm going to write a few on the side here you guys can go ahead um I'll put them in print statements and test yourself and see if you get them right or not okay I'm going to add a few tricks from the other lesson um try to kind of apply some of our knowledge and see if we can get them correct okay so just give me a minute here I'm just going to write a few out and then we'll go through the answers afterwards okay so you know what we'll just we'll just do these ones for right now and we'll do a few other examples okay so these are a little more advanced than what I was talking about before but they are conditions we have a left side of the condition and we have a right side of the condition so I hope you've taken a guess now of what you think these are going to be cuz I'm about to print out the answer right now Okay so we've gotten true false and false all right so for the first one two less than three that's an example I already gave that gives us a value of true because that condition is true uh now we have two - 3 + 4 greater than 5 um so you can do the math there and see that that is going to be false and then this one some people may have gotten a little bit of a little bit confused on cuz I actually use the words false and true in my condition that's going to return false or true so I have print false equals equals true well is false the same thing as true no it's not so obviously we going to be returned with the value false Okay so we've talked a little bit about conditions now um in the next tutorial we're going to be doing something called decision so I'll give you a sneak peek on what that is something like this okay so stay tuned for that um the next episode should be up tomorrow um and yeah I hope you guys enjoyed the video go ahead like And subscribe and yeah share with your friends thanks bye hey guys guys uh welcome back to the fourth video in my Python Programming tutorial Series today we're going to be talking about decisions so we're going to be using the if else and L if statements in Python so pretty much I gave you a little example last time on what these are but if condition equals true then do this sorry not his do this okay so pretty much the syntax for the basic if statement which is what we are going to cover first is like this so if you remember my last tutorial I talked about conditions if you haven't seen that go back and look at that first because that's going to be an important part of today's lesson and you have to understand that so if condition is true then we are going to do this now let's just dig into the syntax a little bit here um so you're going to start with the keyword if then we're going to put a condition so the condition could be something like this if 1 is less than two if tree is equal to plant something like that okay anything that can return a true or false value you can use variable names you can say if x is equal to Y anything like that is condition and it uses a conditional operator like I talked about in the last video and then you are going to end your condition with a semicolon or sorry not a semicolon like this with a regular colon and then you going to Simply click enter and it should tab you in one line now it's very important that you have this indentation um if you have your code like this it's not going to work python reads the lines because of indentation so it's very important that you have whatever statements you want to run after the condition returns true indented properly and this will also be very important as we move further on in different tutorials and we have have lots of different indentation levels within the program okay so let's do a real example now instead of uh this kind of pseudo code here so we'll start off by just getting some input from the user so let's say let's get their age okay so age is equal to input like this and then just if you put something inside of the input like this uh it actually gives a prompt to the user so we'll say input your AG like that and then we will say if the age is equal to 16 then we will print to the screen hey your oops 16 like that okay um all right so let's go ahead and just test it out right away I know I haven't really explained it but I just want to show you how this works okay so we have input put your age so I'll say two as my age and we can see that nothing happens okay um now I want to show you one more I hope you've caught this trick already from what I talked about in the last videos but we'll see now you notice here I'm going to put in 16 and nothing's going to happen now the reason for that is because 16 here is different than the 16 that we get from age if you remember whenever we're getting a number or anything from the console we actually get it as a string so this 16 that we're getting actually looks like this now in Python again we have different data types right so this is an integer data type well this is a string so when we're comparing integers and strings um they're different so we have to convert our age variable into an integer before we can compare it like that okay now we'll try again say if int age equals 16 so now we put 16 in and says hey you're 16 like that okay um perfect so that's pretty straightforward um now we can also do some other conditions so let's do a greater than 16 now okay so this is another conditional operator that we talked about before um and yeah we'll go ahead we'll try it now so we'll say 15 now nothing happened because obviously 15 is not greater than 16 now if we put in 17 it works okay great um all right and also uh I just want to show you there's another operator that we didn't talk about last time a conditional operator and it's the greater than or equal to and the less than or equal to so to convert your um greater than sign into a greater than or equal to sign all you have to do is add an equal sign like this and now anything greater than or equal to 16 will work whereas before it had to be strictly greater than 16 and same thing with the less than sign like that okay uh I just forgot to talk about in the other video so I figured I'd put it in here all right um great so let's go into another example then so let's say um it's great it's telling us we're 16 um or let's in this case we're going to be older than 16 right so hey you're older than 16 but what if we want to message when we are younger than 16 well the way to do this is using something called an lse statement so the Syntax for this uh it simply has to come after an if statement you can't just leave your own else statement like this that will not work it has to be after an if statement is placed and then all you have to do is put a call in and click enter and make sure the indentation is the same as the indentation for the first if okay so now we're just going to print you are younger than 16 okay and we can go ahead we can try this to see if the else is going to work and we say well we're 15 and you are younger than 16 great okay um so just to explain this a little more how this really works when we're reading through the code well python reads code line by line like this now when it reaches this if statement it checks this condition to see if it is true or false so since this condition um was false in the last example we say if false it says Okay so we're not going to run this line of code we're going to skip to the else statement and we're going to do this okay so if we had typed anything in that does not return true so makes this condition not return true then it would go to this else statement like this okay um yeah and then same thing say we type in a number 17 um and that is greater than 16 it's not going to do the L statement it's just going to do the if statement okay um I hope that makes sense now we're going to go into another layer okay so let's get into a new example here um let's talk about height for a roller coaster okay so for some roller coasters uh you have to be taller than a certain height and you actually can't be too tall right so again we'll get the input from the console so we'll just say height is equal to input and we're just going to do this in meters like 1 meter 2 meter 3 meter just to make it really easy okay I know that's not a realistic height but just for the purpose of this example so we say height is equal to input um again we have to remember that when we're going to check the condition we have to make sure we put it in the int because as we get it from the console it's going to be a string okay so we'll say if height is less than 1 M we're going to say you cannot ride so we're going to print to the screen you cannot ride okay now we only want to allow the user to ride if their height is in between 1 M but less than 2 m okay so as you can see I've introduced a new word here called L if all right so this means if this condition up here is false then we're going to go to this one we're going to check if this condition is true or false if it's true we're going to run whatever's in here um otherwise we're going to keep going so you can have as many l ifs as you possibly want um in a decision statement like this okay um you can only have one else though because else is just the default so anything you type in um that doesn't equal any of these statements so like if isn't true Al if isn't true the other L if isn't true then it'll go to the lse statement okay so L if the height is so if it's less than one you can't ride and if it is greater greater than two you also can't ride so we're going to say you cannot ride I'm going to say and we'll say over 2 m and then we'll put here just so we can distinct them under one meter okay and then now we're going to add in the lse statement like this and we're going to say print you can write okay so I know I just did a lot there so we'll go through it quickly we pretty much have a condition up here we already talked about the if statement so if this condition is true we're going to print this and we're going to skip everything else we're not even going to bother reading it because we know that it's not going to be any of those conditions okay so now we do the L if here right so we say well if this condition is false we're going to go ahead and we're going to check this condition so we say oh well this one's true so then we're going to execute this line of code which is the print and we're not not going to do this else statement now say we go through these two and they're both false okay so this returned false and this return false then we're going to go to the else and we're automatically just going to print whatever is in the else statement like that okay so we'll go ahead uh we'll run the program and we'll try it out make sure I haven't made any errors here okay so the input um I didn't give a prompt so I'm just going to type in the height uh a number all right so we'll say one you can ride great okay um that is because again we have the strictly less than sign now if we wanted it to be you have to be over one foot we just put an equal sign here and then same thing here okay so we'll do that and now I'll show you again if I put in one you cannot ride under 1 meter okay so less than or equal to one right okay um let's try again now we'll do it maybe a number greater than two so let's say put four it says you cannot ride because you are over 2 m and then again if we do like a decimal number maybe uh 1.1 Okay so we've run into an error there that's fine just because we can't convert a floating decimal point into an integer but yeah I hope you get the point from that example here um these are just the basic if L if and L statements I'll do one more just to show you here we could do another L if here saying for example um if in height is equal to remember we do two equal signs right not one then we're going to say print while you are tall okay so as you can see we can do infinite elf State L if statements like this and we can only have one lse statement and one if statement at the beginning okay uh so we'll run this one just to show you one more time how this works I'll put in five so five uh you cannot write over two 2 m okay so that's because what actually happened here is we went if we checked this condition now it turns out that um five is greater than two so we did this one and we didn't bother reading the rest now if I wanted to change this uh so that it would check the five first all I would have to do is put this LF statement I'll do it right now above the other L if statement like this and now if I type in 5 it'll work wow you are tall okay so uh that's it for the if L if and L statements um in the next tutorial we're going to go into something called chain conditionals and do some more advanced examples of this we're going to do some addition subtraction and some more things with other operators okay so I hope you enjoyed um please don't forget to like And subscribe the video and I'll see you again tomorrow in another video hey guys uh welcome back to another video this is the fifth video in my Python Programming series and today we're going to be talking about chained conditionals and nested if statements um so pretty much chained conditionals are just adding multiple conditions in one uh one line with using words like and and or okay uh we also have keyword not that we're going to talk about as well so if you haven't seen the last videos in my series go ahead and get watch those now because they are prerequisite for this video all right so let's get right ahead and start um so if you remember before we have something called conditions so for example if we have the variable X I'll set that to two and the variable Y which is equal to three we could have a condition like xal equal y now obviously we know from the last video that this is going to give us a value of false oops and I cannot type today sorry um and that is because two is not equal to three pretty straightforward I hope you have all understood that from the last video all right so what we want to do in this now is we're going to want to check multiple conditions um so we'll put a condition here so if x is equal to Y and then we can put a word in like this the and word um now we'll add another condition so if x + y is equal to 5 Okay so this first condition is going to give us a value of false so if x is equal to Y because they are not the same but now x + y does indeed equal 5 so that is going to give us a value of true so where I'm highlighting we have true and then where I'm highlighting now again we have false so because we have the keyword and this if statement is not going to run so I'll put a print here just to show you we're going to print out true or let's just say ran and you'll see when I run the program nothing is going to happen happen that is because when we use the and keyword it means both conditions on either side must be true so if we change this to something like if Y is equal to 3 now that is going to be true and we'll print out ran okay so that's pretty basic now let's do the or keyword so we'll put or right here and we'll change this condition back to if Y is equal to X and now take a guess on what you think is going to happen well pretty much with the or keyword it means either of the conditions have to be true so if Y is equal to X or x + y is equal to 5 then we are going to run this line now since X+ y does equal 5 we have a true here and again Y is not equal to X so we have a false and you'll see that the program is going to run that's because only one of the condition conditions has to be true for it to run okay so that is the and in the OR keyword they are pretty straightforward and pretty basic now I'd like to point out that you can actually add as many conditions as You' like so now I can have an or I can have an and um I could have another condition I could do as many as I'd possibly can imagine as many as I'd like to do um so now we'll put an lse statement in here and we'll change this just a little bit to use another keyword we'll just put a side face here to show that we didn't run it that we ran the else okay um so now there's something called the not word okay so we're going to put not right here around it and then I will show you what it does so pretty much not reverses anything that you have inside of the brackets of the knot so in here we have if Y is equal to X or x + y is equal to 5 so we know again that this gives us a value of true um so now since true is inside of the KN true becomes false now we have if false um so obviously that's going to bring us to the else statement um which is going to print the sad face so I'll show you that that does indeed work so we have the sad face right now if we change these so that both of these conditions are false you'll see that we have false false um which is going to give us an overall value of false um and then we're going to have the not which is going to change that into a true and will allow us to run it just like that ran um um so yeah so that's how the not the and and the ore work uh and now let's get into nested Loops or sorry not nested Loops Nest nested if statements so we'll do a basic if statement here if x is equal to 2 um if Y is equal to 3 um and then we'll add our El's like this and we'll put some print statements in here okay uh just give me a second while I type out the print statements and then we will go into what this is going to do x = 2 and Y = 3 um so you may have guessed already but pretty much we can actually add as many if statements embedded or nested as we'd like so I could add another if statement here and just constantly keep checking um now the reason I showed you chain conditionals is because if I didn't want to go through the hassle of adding all of these uh nested statements I could just do an and right here and check for another condition but sometimes we do want to do uh nested statements so we'll say here x = 2 y does not equal uh what is it three okay so uh I know I just did that pretty quickly but let's walk through it now so we have if x is equal to 2 then we're going to run whatever is in here because it is indented uh so now we come in here and we say well is y equal to 3 let's say it is now we're going to print out this statement and we're going to be done with this loop with this uh bit of codes we're going to skip down to the end of the program where we have nothing else um then so let's say we do another example X is equal to 2 but y equal 4 so that means we're actually going to run the else which means now we've got print X is equal to 2 but y does not equal 3 and then the last case is X is not equal to 2 so we don't even bother checking if Y is equal to 3 we just go down and we print X does not equal 2 so we'll change around the variables and we'll show you how this works just very quickly so we can see X is equal to 2 and Y is equal to 3 that is because obviously up here two and three now if I want to change Y and we change it to four we get X is equal to two but Y is not equal to three so that means we ran this one in here now let's change it so that X is equal to 4 as well and we can see we get X does not equal 2 all right so that's uh the basics on nested statements and chained conditionals I hope you found this video helpful um stay tuned for more videos we're going to be getting into some more advanced topics and in the next video we're going to be covering Loops um yeah so if you like the video uh please subscribe and like and I'll see you in the next one hey guys welcome back to another video this is the sixth video in my Python Programming series and today we're going to be talking about for Loops again if you missed the other videos in the series please go back and watch them first as it's going to be hard to understand if you haven't seen them already Okay so let's get right into it today we're going to be talking about four Loops um and a loop is a new thing now if you're a beginner in Python and I'll talk about how they work we're going to start off by just writing one out um getting right into it with the syntax so 4X in range and then we're going to put a number which is going to be our starting position so in this case I'm going to put zero um and then a stop point so 10 okay and then we're simply going to print out X now I know we did this pretty quickly but let's talk about what this is and the syntax so a for Loop is going to run a certain amount of times so in this case we're going to start at zero and we're going to go to 10 this means the for Loop is actually going to run 10 times so what's going to happen is we are going to have our variable X which is right here and every time the for Loop runs X is going to be increased by one now we can increase it by more if we'd like to by adding another comma here but by default it is set to one like this I've just put it in so that you can visualize it so really we have something start a stop Oops stop and an end start stop step sorry my bad and I'll just put commas here to show you how it works so you can see we have our zero that's our starting number our stop which is 10 and our step which is going to be one so I know you don't quite understand yet but you will after I show you a few examples so we have X is our variable which is going to be holding the number um of what iteration we are through now iteration uh just means how many times we've already looped through this Loop okay so let's uh do an example here all right so we have X and we've just started running this for Loop now right now X is zero we're going to print X we're going to print zero to the screen and then we're going to add one to X now this time we come through the loop we say well is X less than 10 yes it is so now we're going to print x x is one now we're adding um two okay so now X is 2 is 2 less than 10 yes 2 is less than 10 so let's print two okay and we keep going until eve

Original Description

This python course is designed to take you from beginner to pro in the python language. This python course is designed to teach you everything you need to know about python. It assumes no prior knowledge and is a perfect python tutorial for beginners. This course is split into 4 main sections: Beginner Python Programming, Object Oriented Programming, Intermediate Python Programming and Expert Python Features. 🎙 Subscribe to my second channel for weekly podcasts! https://www.youtube.com/channel/UCSATlCAUi7R0Ik-wsZb2gOA 🔗 Python Download: https://www.python.org/downloads/ Note: There may be some missing links and resources. Leave a comment if so and I'll try my best to add them! ⭐️ Time Stamps ⭐️ 📕 Beginner Python Programming 📕 (00:00:00) Introduction (00:01:12) Variables & Data Types (00:12:21) Basic Operators & Input (00:24:11) Conditions (00:32:54) if-elif-else (00:45:56) Chained Conditionals & Nested Statements (00:53:29) For Loops (00:59:29) While Loops (01:05:51) List's and Tuples (01:14:09) Iteration by Item (01:20:13) String Methods (01:26:38) Slice Operator (01:33:41) Functions (01:42:10) How to Read a Text File (01:50:31) Writing to a Text File (01:54:50) Using .count() and .find() (02:01:47) Introduction to Modular Programming (02:09:28) Optional Parameters (02:15:36) Try and Except (Error Handling) (02:20:29) Global vs Local Variables 📗 Object Oriented Programming 📗 (02:29:16) Introduction to Objects (02:39:02) Creating Classes (02:50:37) Inheritance (03:03:13) Overloading Methods (03:16:01) Static Methods and Class Methods (03:25:44) Private and Public Classes 📘 Intermediate Python 📘 (03:31:40) Optional Parameters (03:41:13) Static and Class Methods (03:50:24) Map Function (03:56:15) Filter Function (04:03:12) Lambda Function (04:10:12) Introduction to Collections (04:22:17) Named Tuple (04:30:20) Deque 📙 Advanced Python 📙 (04:40:12) Overview of Python (04:58:34) Dunder/Magic Methods (05:12:23) Metaclasses (05:34:10) Decorators (05:50:29
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video course teaches the basics of Python programming, covering topics such as data types, variables, operators, control structures, and functions. It provides a comprehensive introduction to the language for beginners, with hands-on examples and exercises.

Key Takeaways
  1. Download and install Python from python.org
  2. Run Python in IDLE
  3. Create a new file in IDLE
  4. Save a file in IDLE
  5. Declare variables and assign values
  6. Use print statements to output strings
  7. Use input function to get user input
  8. Write conditional statements using if-else
  9. Use loops and iteration
  10. Write nested statements
💡 Python is a versatile and easy-to-learn language, and this course provides a comprehensive introduction to its basics, including data types, variables, operators, control structures, and functions.

Related AI Lessons

Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →