Python In 90 Minutes | Max S | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

25 Lessons (1h 35m)
    • 1. Course Intro

      1:03
    • 2. Copy of 01GettingTheInterpreter

      1:17
    • 3. Copy of 02Comments

      2:52
    • 4. Copy of 03Indentations

      1:25
    • 5. Copy of 04PrintingToTheScreen

      1:40
    • 6. Copy of 05VariablesAndStrings

      3:08
    • 7. Copy of 06OperationsOnStrings

      5:48
    • 8. Copy of 07IntegersAndFloats

      2:26
    • 9. Copy of 08ArithmeticOperations

      7:25
    • 10. Copy of 09Booleans

      2:02
    • 11. Copy of 10Lists

      2:32
    • 12. Copy of 11ListOperations

      7:24
    • 13. Copy of 12Dictionaries

      5:08
    • 14. Copy of 13Tuples

      3:12
    • 15. 14TypeConversion

      6:19
    • 16. 15UserInput

      3:23
    • 17. Copy of 16GlobalVariables

      0:50
    • 18. 17Functions

      5:41
    • 19. 18BooleanExpressions

      4:23
    • 20. 19IfElifElseStatements

      7:45
    • 21. 20ForLoops

      5:16
    • 22. 21WhileLoops

      3:05
    • 23. 22BreakContinue

      6:13
    • 24. 23Modules

      4:25
    • 25. Course Outro

      0:37
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

4,586

Students

2

Projects

About This Class

With the digitalization of the modern world, programming is becoming a lot more important. It's versatility allows you to solve simple repetitive, as well as long and complex problems, and its power and breadth of application is solely dependent on the programmer.

Python is a scripting language that has a very large community. It allows for very fast and easy prototyping, and the community makes complex things, such as machine learning and artificial intelligence, readily useable for the public. Python is a great language to learn, as it's much easier to read and understand, but it still allows you to do whatever you want. It's perfect for your first programming language, because it has great readability, but also as your second, third, or fourth (or even more), because of how quickly you can develop in it.

This course will take you through a lot of the essentials of what you'll need to be able to program, and at the end should leave you with solid fundamentals and an understanding which you can then apply to create your own programs, or which you can use to continue your learning endeavours into more advanced areas.

This course is designed to not beat around the bush, and will teach you Python programming in a very short time. It does this through lectures that are to the point, as well as by providing you extra material and practice sheets that you can use to solidify your knowledge.

Meet Your Teacher

Teacher Profile Image

Max S

Power through programming

Teacher

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Course Intro: everyone, It's Max. And welcome to my course Python and 90 minutes. This course is made for beginners. So anyone who has little or even no programming experience and you're gonna learn to code in python from the ground up. So you're gonna learn about the fundamental code structure that we use in pythons. So how do you make sure that your code looks and works properly? You're gonna learn about the different data types and variables that you use in python. You're gonna learn about loops, about functions and about conditional logic, among other things. Now, by the end of this course, you're going to be able to write code in Python. You're gonna learn how to use libraries in python, which is important because if you want to do anything else later on with programming such as, maybe start Web development or something like that, all of that is based upon knowing how to use an important library. So we're gonna learn about libraries and also how to import those in python. And along the way, you're also going to solve a series of exercises to make sure that you actually apply the knowledge that you're learning so that you feel comfortable coding and python 2. Copy of 01GettingTheInterpreter: everyone, It's Max. And welcome to my python tutorial. So to start programming in Python, we're gonna need a software that's gonna allow us to start writing things and pretty much an interpreter. So something where we can write code in and something that can then interpret this code and that can perform all of these operations and execute code for us. And so to get that, we're gonna get go and head over to python dot or here and then Murray to go to the Donald section, and we're just going to click on Python 3.6 point one here. And as you may have noticed, it already recognized the operating system that using. So in case you're not using a Mac, it will just automatically. You know, see if if you're using a one knows if using the Lennox or something and then you can just click on patent 3.6 point one here. Alternatively, if it doesn't detect it, you can also just choose your operating system here on the side. But let's test it up for Max. So we're going here and you'll see that automatically downloads this package for me, which I can then open up and it will pretty much walking through the installation process. So yeah, go ahead and download this on. Guy just walked through the installation process. This is just gonna install the standard python interpreter that we can then use to write code and and execute covered in 3. Copy of 02Comments: everyone and smacks and welcome back to my path and tutorial. So let's go ahead and open the interpreter that you've just downloaded eso this interpreters called idle. And for me, the easiest way open it is if I just go into my search bar and I search for Idol. Now, you'll notice I have different versions installed here for different versions of Python. But we're gonna be using Python version 3.6 point one as we've downloaded in the last lecture. Say, I just go ahead and open this one, and then you'll get all of the stuff that opens up here. Actually, you probably only get though the show, but you could see that it's also packing 3.6 point one, as that's indicated in the title here to get a new file, we're gonna head over to file, and then we're just gonna open a new file like this, and then it just a blank filed a pop up, and then you can just go ahead and save it like I've done over here and now you're ready to code. Make sure that when you say that you actually have the stock P y extension because that indicates to the interpreter that this is gonna be a python file. So it's gonna contain python code. And so that's why we're gonna have this python extension here. All right, great. So now that we've done that, let's go ahead and learn the first thing about programming. You know, the first thing that we're gonna do is we're gonna look at commenting now. What company does is it allows us to write expert comments that aren't read at a computer, and a lot is to communicate either with other users or allowed us to take notes for self so that we can understand the code when we get back to it later. This is gonna be really important later on, especially if you do big projects because you want to make sure you keep everything organized. And in case you're unsure why you did something or you may want to leave a reference, you can do all of that using comments. So how do you create a comment? Well, to create a comment, you're just gonna hit in the pound key here and know everything that you write on this line after the pound is gonna be commented out. So, for example, I can type in here. Hello, everyone. And the computer isn't gonna read any of this. Now note that anything I put in front of the comment is gonna be right by the computer, so you'll notice a difference in coloring here too. And if I try to run this so if I save and go over here and click run, I'm gonna get an error because it doesn't really understand what hello, This. But if I take this away and I saved run this again, everything's gonna be fine because the computer doesn't even try to read this because it's just a comment. And so that's how you can go about commenting and you can put them in the middle of the line. You can also just put them at the beginning of the line. Can also make comments across multiple lines. So the standard is always using this pound symbol wherever you want. Um created comment, and as soon as you have the pound symbol in the line, everything that follows that is gonna be commented out 4. Copy of 03Indentations: everyone, it's Max and welcome back to my practice tutorial. So now one more thing that we need to note before we really jump into coding is we need to talk a little bit about indentations. Now indentations play a very important part in python or white spaces and General, and you can't just go around and put in nets and everything. So, for example, if we have our first line of code over here and then we go down and we put in here in ending and have a second line of code, we need to have a very good reason to have an indent here. Because in India and usually makes something a subgroup of something else, and only certain things can have subgroups. So even though it may look nice or sometimes toe have indentations contrary to other programming languages where you can just kind of put that in. That's not the case in Python. So in Piketon, you want to make sure that you know you stay aware of using these white spaces and of using these indentations, and I'll show you the scenarios where we do use indentations and where he should use them. But besides, from that, try to avoid using them because otherwise they'll just cause errors in your program, because Pipeline's gonna be confused. Why you have an indentation there? Because it's gonna try to read it as something else that it's really not. So this indentation thing is something that you should keep in mind and don't just go ahead and then everything, because python, in terms of white spaces, works a little bit different than other programming languages. 5. Copy of 04PrintingToTheScreen: everyone, It's Max and a welcome back to my pipe in tutorial. So in this lecture, we're gonna look at user output to the screen andan terms of Pathan That's called printing to scream. So we're gonna learn how we can make text or other things appear here on the screen. And so to do that, we're gonna type in the print keyword, which, as you can see, our platforms actually get a color code. That's also because we have this P Y extension and because we're using an interpreter that understands python code. And it realizes that print, for example, is a python keyword. So we're gonna put in here this this print word and then we're gonna open and close parentheses behind it. And however, now whatever we put inside here, that's what's gonna be up. Put it to the screen. Once we have on our code. Now there are some special requirements. Eso we're gonna just gonna start off and we're gonna put everything that we want to write to screen in quotation marks, and we'll learn more about this later and why we need to do this. But right now that's the former that we're gonna be using. So what we're gonna do is we're gonna let our program say hello, world. And the way to do that is inside of these quotation marks. We're just gonna type in hello world like this, and we can put in spaces and capital letters. We can even put in other symbols like exclamation marks and stuff. We just want to make sure we have this prince statement in front here. And then we got it surrounded by these brackets and everything inside is in quotation marks . All right, so let's go ahead and save this and let's run our code and then we see we've no written hello world. 6. Copy of 05VariablesAndStrings: everyone, it's Max. And welcome back to my path into torque. So in this tutorial, we're gonna learn about variables and Ross gonna look at our first object, which are going to be straight now. What variables allow us to do is they allow us to save information so that we can use it later on our coat. So that's something that's really important. This is pretty much as a lot of this toe, you know, store information or data, and then we can carry that down and we can use it later on. So that's pretty much essential to coding. And now the other thing that we're gonna look at strings is going to be something that we actually saw in the last lecture when we printed to the screen. But let's just go ahead and take a look at everything, so to create a variable, what we're gonna do is I'm gonna put the general format in comments above so that we can reference it. We're gonna have a variable name, and they were gonna have this equal sign, which is like an assignment operation. And then we're gonna put on the right side the value that we're gonna assigned to this name and what's really cool is now we can always just reference this name, and we're always going to get the value that's associate with. So let's see that in an example. In terms of strings, let's go ahead and create a Hello Very well. So the variable that we're gonna create it's gonna be called Hello. And now we're gonna assign this the value of a string and now a string is what we saw in the last lecture, which is, if we have double quotation marks, we can put words or sentences or even just single characters inside so that we can have, well, these words or sentences. So that's what strings were used for. So, for example, I can now put in the screen hello world like I did last time. And if I go into a new line and up, print out just the variable hello rather than putting in the string hello world as I did last time. If I save and run this, you'll see that I still get Hello world printed to the screen. And that's because this variable hello has stored the value of hello world as we see it in here now I can also overwrite my variable. So, for example, I can do goodbye world. And that was this capitalization here. And so if I save and run this, you'll see that now my hello variable is good bye world. So it starts office Hello world, And then it gets over written to Good bye world. And that's what we see is output over here Now note for strings that we can both use double quotation marks or we can use single quotation works. But it's important that we start and end with the same quotation marks. So, for example, if I know put it in here a double quotation marks like this then but we're gonna get is if I save and run this. We're actually going to get this double quotation mark as a symbol inside. And so that's one of the perks of being able to use thes double as we have few. Or these single Tik create the strings. We just want to make sure that were consistent, that we start and end with the same style of quotation marks 7. Copy of 06OperationsOnStrings: everyone, It's Max. And welcome back to my python tutorial. So in the last lecture, we've seen what strings are. And now we're going to learn about some operations that we can do it. So we're gonna actually look at four different types of operations, and we're going to start with addition of two strings. So let's go ahead and create two strings that we're going to save in two different variables. So what is call it? He's very bulls. Um, first string and the second very we're gonna call Second string and let's assignments and values. So let's just stick with the hello world example that we're using and a first string is gonna have the value of the string. Hello. And our second string is gonna have the value world almost issues on double and single quotation marks here just to really show you that they're pretty much interchangeable, right? So let's create our first edition street. And so we're going to save this in another variable that we're gonna call Edition Stream. And what we're gonna do is we're gonna add are first dream and our second string together. So what, you can really think of what I'm doing this is or when I'm putting in these variables is that I'm taking whatever the content is. So this really is the same as having over here Hello plus world like this. So that's what I'm doing. And I was print out the results of our a different structure. Don't save and run this. What we see is that the tea strings that we had have been joined together also in the order that we've created it. So we see Hello and world have been joined together. This is also known as strength in coordination. Now you notice also that there's no space here and that's because I didn't put a space anywhere here. So for example, if I put a space before the w here and I said run this, then I'll get this space between hello world. But I could just a swell also put the space after the hello and save and run this and then we'll see that I also get the same result here. So that's it. In terms of addition, the next thing will look at is the multiplication of strings on or repetition. So we'll call this variable multiple string and we're gonna have this be equal to the first trip, and then we're gonna just multiply it by a number. And so what we have here is we have this Asterix, which indicates multiplication, and then we can just put in here a number. And if we save this and then if we print out the value of our multiple string and then we save and run this, then what we get first as we get hello world. And then we get hello three times and you'll notice that the space is also stood here. So as the name already suggests, with this repetition, is that what this multiple string is that we're doing repetition here? Someone, he added, Comment We're doing string repetition, and we'll see that the string that we have repeats exactly three times just as we've defined it here. All right, so there to local things to look out, the first thing is gonna be string splicing. Um, so let's print out and we're just gonna print out the results here. If we go into our first dream, we can actually open and close square brackets after it, and we can just put in a number between zero and one lesson the length of our string and weaken Select out on the second character. So the first character, for example, is gonna have the index zero. So if you want to pick out the H from our first string, we're gonna put in here a zero in these square parentheses himself. We save and run this. Then we'll see. We get the hello world from this print or hello, hello, hello from or multiple strings. And then we got the age that we picked out over here. I can also pick out the second character, for example, which has the index one. So it's important to note that the way that strings are counted more generally, the way that things were counted, programming is you go 01234 and so on. So you start counting up zero rather than I want. So if we do this for the next one, which is going to give us a second character here, we get the E. Now, if I want the last character, for example, I can put in a negative one. So a negative one means I start counting from the back, which is actually just gonna give us a space in this case. But I can also put in the negative, too. And I'll run this and forgot to save, which will give us Theo at the end. Here, um, you want to make sure that the value that you put in here doesn't exceed one lesson the length of the string. So, for example, here we have six characters, five for hello in one of the space. So if I put in here the number six, that's actually gonna be the seventh character. If I try this, if I save run, I'm gonna get an error because this index doesn't exist because the string is not that long . Now there's one more type of operation that we can do, and that's range spicing. So if you look at our first dream and we don't just want to pick out a single character but rather a subset, we can say we want to start at, for example, character zero we want to go up to, but not including the character within next three. So the fourth character and then we save and run this and I should remove this or else we're not going to get any further because we're encounter with air. If I save and run this, then we'll see that we get characters 01 and two. So we go up to but not including three. 8. Copy of 07IntegersAndFloats: everyone, it's Max and welcome back to my Python tutorial. So now that we've learned about strings, let's learn about some other types that we have in private. Now we're gonna look at introduce and floats. So let's again create these in the variable, and the first single create is going to be in invariable. That's gonna create a container integer, and let's also create a float. Very born that's gonna create are floating point number. All right, so an integer is really just a whole number. So, for example, we can do one, two or three or anything like that. We can also do negative three negative five u zero All of these things that are whole numbers. That's what's considered an interview. A floating point number is a decimal number, so anything that has a decimal in it so this could be things like, let's say 6.3 or 2.7 negative 9.1. You can even have fractions over here if you want a love and help, um, 11/7 or stuff like that. Don't worry about this, this divide dividing thing and this is used perfections, but we'll also take a look at this later on. But you can have this as floating point numbers, so you'll just get Ah, number here rather than keeping affection. Eso there All of these things are floating point numbers, even things like 7.0, even though it's technically the value of a whole number. So seven and 7.0 are the same because we have a decimal point here. It's actually floating point number. That's because we have this extract extract we received that. We know that there is a zero after this decimal point, So let's stick with something like, say, 6.3. So that's what we have in terms of integers as well as in terms of flips. So let's see an example on its print out are in very goal on one line and then on the next line that's print out our float variable like this. And so if you just think that into the print statements we see, we get seven us not put here, and we also get 6.3 as an output down here. So but also maybe try something like 6.0 and we'll save and run this and we'll see that We also still got 6.0 here, so there's nothing that's being rounded for us or so. And here we have the integer and here we have the floating point number. 9. Copy of 08ArithmeticOperations: everyone, it's Max and welcome back to my python tutorial. So in this lecture, let's take a look at arithmetic operations on integers and floats. So let's create two variables. Let's create our invariable like we had it last time and let's have this be seven. And let's also create our float very warm and let's have the speed 6.3. And now we're gonna create a different series of variables that are gonna kind of be appropriate to the operations that we want to do. So the first thing we're gonna do is gonna be our plus result. And so as the name suggests, we're just gonna add these two variables together. We're gonna take the invariable and to it, we're gonna add the float variable, and that's gonna be stored in R plus results. So let's just print everything out as we do it. So it's pronounced, are in very boom that's pronounce our float variable. And I'll also add some comments above here just so that we can see you. Really? What we're doing so are invariable has the value seven as we have it up here and then our float very bone has the value 6.3, as we have up here. So really, what we're doing? We're doing seven plus 6.3, and then we can print out, um, are plus results. So we have this nice plus operation here that allows us to just add these two numbers together. So if we save and run this we see we have seven and 6.3, which is our into our float variables. And then we've got there some, which is 13.3. You can also do a substructure subtraction, so we'll create a subtraction result. Very boom. Which is gonna be We'll just take our in fairy boom, and this time we'll subtract from it are float variable. And what were the subtraction by using this minus symbol here or this? This dash and selling that's turned out are subtraction results, and the comments pretty much stayed the same. So we'll have, um, this up here, But in this case, we'll just have a minus rather than a plus of as we found it before, like this. All right, so if we save and run that so then we see we get something very close to 0.7 and What we see over here is actually due to computer error, because the computer can only look at a finite number of decimal places. And so in some cases you would actually get these rounding errors at the very end that are not due to something being wrong in the mathematics or the algorithm used here. It's just it just comes from computer rounding because of the precision is that computers can have. So that's something that you can see over here. And it could also well, be that when you do other things that you see something like lots of zeros on to at the end . And that's just that's just by nature of how the computer works. All right, so we've got a subtraction here. The next thing we can look at is, um, division, so we can look at our division result. Um, and that's gonna be we'll take our invariable. And this time, actually, let's just divided by a whole number. So what is divided by the number two in this case and let's print out are so print opening close parentheses are division results, and we'll save and run that. And so he received. We get seven divided by two is going to give us 3.5, which actually gives us a floating point number here, even though we started with this integer. All right, so in terms off, maybe also adding the comments again. So we've got our invariable, which is seven. And then we're just dividing by the number two, which is what we've put in right there. We can also do multiplication, so create a multiplication result very warm and here will take are in very warm. And this time let's just multiplied by the number two. And if we print out are multiplication results like this and we save and run, I forgot to save, so I save and run. We see we get 14 as a result of multiplying seven by two, which is exactly what we would expect. Now there are some other cool operations that we can do, and one of them is called a module ISS. So let me just write out the variable first. And what happens with the module is is that it's similar in terms of division, but it actually only looks at the remainder. So, for example, as we have here, we had seven divided by two, which gave us the result of 3.5. But if we do seven module ISS to what is going to give us is going to give us the remainder that we get from dividing seven by two. So let me just write this print statement first, and then let's go through it. So really, what happens is we divide seven by two, which gives us three and 1/2 and the remainder that we get is this number right here. And so that's the number that we're gonna be seeing by this module ist result. So if we save and run that we see, we get this one here. Same thing would happen if we put in here nine. So that would just give us four plus 1/2. And it would still give us the remainder of one. But if we put in something like eight, you know, just give us the number four and then we would have or rather it actually give us this so we would have a remainder of zero. And so that's exactly what would see here. Now, as you can guess, For example, if I increase this number here, and things are going to look a little bit different. So if we divide it by three, it's going to give us too. Plus 2/3 and sonar number from the module is is not limited between 01 but it could be 01 or two, depending on what remainder we have. And so that's what we see here. For example, if you do eight module is three. We get the remainder of that, which is what we have right here. All right, One more cool thing that we can do is taking feet power. And so the way that we can do them because we can just take our in very boom and to go to the power we're gonna do a double multiplication symbol. So double Asterix, and then on the right side, we're just gonna put whatever number we want to take to the power to. So, for example, if you wanna square what has put a number two here and then we can just print out the power result. So we're doing is we're taking or invariable, which is seven, and we're taking that to the power of To that were squaring it So let's add those comments here. So we're doing is we're taking seven and we're taking it. So another conventional symbol force for taking to the power is this kind of hat Cymbal. We're taking it to the power of to which is going to square things for us and maybe also here we can add comments on so here will do seven multiplied by two. So that's that's what's going on up here. Um, right. So let's save and run this and see the result of this power, which gives us 49 which is exactly what we expect. So that's seven squared, which is the same thing is seven multiplied by seven, which gives us 49. 10. Copy of 09Booleans: everyone, it's Max. And welcome back to my pipe editorial. So we've seen strings. We've seen integers. We seem floats. Now we'll look at another type, which is gonna be billions and let's create a bull variable. And so a boolean value can really just take on either true or it can take on false and know these values have to be capitalized. And I'll just also add them in the comments up here So we can either take on true or we can take on the value false. So that's what Boolean values can do. They're either true or false, and it could be really useful sometimes to just be able to differentiate between true and false. And we'll actually see you later on. They're gonna be many cases where we're just gonna be checking if something is true or if something is false. But that's really the essence of a Boolean variable. Either something is true or something is false, and it's important to note that we have the capitalization at the frontier. So capital T for true capital F for false, you notice that the color coding goes away when I put a lower case here, so Teoh, help the computer understand or the Python program. Understand that we're actually dealing with a Boolean variable, not just a general very bull that we've called lower case false. We want to put the upper case here, So if you want to see the result of this, let's just go ahead and print out, are full, very bone. And let's save our code and then run it and we'll see we get false printed out here, which is the current value of a true, very cool, very boom. We can also put in a true and we save and run that. And then we get true printed out. If I put in a lower case, True, probably gonna get an error because it's trying to understand this variable. True. So what it's looking for is something like true is equal to, and then whatever. So that's what it's looking for in case I have this lower case T. So that's why it's important that I have the upper case T for True in the upper case F for false 11. Copy of 10Lists: Hey, everyone, it's Max. And welcome back to my python tutorial. So now we've looked at the basic kind of data types that we haven't Python. So we've seen strings, integers, floats and billions. Now we'll look at a little bit more complex data type in some sense, on that's gonna be a list and list is really cool because also a data structure and what it allows us to do is it allows us to aggregate several different values together, and we can pretty much have it like a storage container. So let's see an example of that, though. Let's create our list variable and to create a list we're gonna open and close square parentheses after we have this equal sign here. And what's really cool is now we can put in values here, and so these values are going to be known as different elements, and each element needs to be separated by a comma Onda. We also don't end on a comma self. Let's just see this. So, for example, I can put in the number one, which is gonna be a list of one element, which is what we have here. If I want to add another element. Put a comma and that I can put in. For example, the number zero if I wants in on my list has two variables. If I want to put in 1/3 variable, I can put in And here is where it gets really cool. I don't just need to put in integers. I can also put in maybe afloat. So it's put in 5.7. I want to create another variable so we'll have my fourth. Very bold. I can even put in strings of I want so I can put in the word Hello. So what I've created here is I've created a list with four variables 105.7 and hello. And what's really cool about this is it allows you to group things together that are relevant. So in case you need a store, you know, mawr information. Maybe you're creating like, a form or something like that. And you want to save all of that. You are probably gonna save that in a list. And that's because all of the information that you're getting is very relevant to each other. So how does the list looked like if it printed out. Well, let's see. So we'll save and run this and we'll see that we have this square parentheses outside. And then we got a first element, which is one second element, which is 0/3 element, which is 5.7 and our fourth element, which is the string. Hello. If you want, we can also add a bowling very born here like this. True. Just so that we covered all of the types that we looked at before on DNA. We've got a list of five elements and you know that each element is separated by a comma. 12. Copy of 11ListOperations: everyone, It's Max. And welcome back to my python tutorial. So we've just seen what lists are. Let's take a look at you know what kind of list operations weaken. Do So how can we work with lists together? So let's create our first list, Variable. Just gets gonna be the basic list of 123 and others create our second list, which is going to contain the stream. Hello? And it's also going to contain the variable. True. All right, so the first thing that we're gonna look at in terms of list operations is joining lists together so very similar to strings where we had string concatenation here. We're gonna look at joining lists together. So we're create our joint list Very well, which is gonna be our list variable. And to it, we're gonna add our second list and then let's just print out are result, which is going to be the joint list. And so if we save and run this, then what we see is we have our list variable. So our first list and to it we've just added our second list, so just gives us a bigger list, and that's what we see right here. So the two lists have just been joined together. I could even extend this if I want and just add my own variable. And so to extend to a list. I want to make sure that the things I'm adding together are always of the same type. So I'm adding a list. Here are mounting list here, so if I want to add more to it, I have to add a list, even if I just want to add one element. So, for example, if I want to add the string end and that's part of a list, then I have to do it in this format. So I actually have to put it, inspire parentheses so that it becomes a list. And then if I save and run that, then we see. I also add the end string at the very end here. So that's what we get in terms of joint lists. The next thing we can do is we can do something called spicing, which we've already seen with Strings. Selfie print out our joint list like this and and then we put the open and close square parentheses at the end, just like we did with strings. We can actually access the different elements now in terms of counting for lists. So each element has a specific index, and the way that we would count them is the following way. So the first element of the list has index zero. The second element has index one, and the third element has index to like this. So if you want to take out the first very boom or the first element rather of our joint list will be looking at Index zero. Like this said, we save and run. And so that's going to give us the value One, which is the first element of our joint list. As we can see right here. If you want to look at, say, the third element, which is gonna be the string Hello, actually, the fourth element. So the element with the index three, which is gonna be the street. Hello. So 0123 We can save, save and run. And then we'll see. We get the hello spring here. We can also look at the last one just like we did was strings. But putting a negative one. Or we can also splice it if we want and say, Let's start at the third element So the element with the next two let's go up to but not including the fourth element and then we'll print out three and hello. So three is the third element element with next to up to, but not including the element with Index four, which is the fifth element. So 01234 So you start here and we got up to, but not including this, which gives us three and hello. And you'll also notice that what I've created here is actually a smaller list. So I've created a sub list self, and I'm not accessing one element directly by itself. Like I would, for example, if I just printed out joint list and then the third element. So the element with it next to that I'm actually getting a list. So here I'm just getting the value. But if I look at more than one element, I actually get the corresponding value in terms of a list. Now what we can also do is we can access specific elements by using the exact same method. And let's access, for example, the third element so the element with the next two and we can just reassign this, so give it a new value. So let's get the number three the value of the string three. And unless just print out our joint list again and let's see the effects that we've had. So if we save him, run it, we see that the element within next two. So the third element changed from the number three to the string three, as we could see right here. So that's how we can reassign things. And we should do this on in explaining neck spaces. Another cool thing that we can do is we can do something called a pending, which is kind of what we've done over here. So we've joined everything together. But instead of adding list together, we can just append certain values to it. So we don't need to actually out to us together. We can just add to the end of a list a another value. So if we take our joint list and we make this equal to the joint list and then to it, we call dot upend. So what we're doing is we're going into our joint list and because we want to upend something to it, we actually have to put a dot here, and we'll learn more about this later when we look at functions for a little bit. But what this thought does is it pretty much means this is what we want to do to joint list . And now lists generally have an operation called Pen that you could do to it, and the format that you do it is you have the list that you want to depend, too, and then you do dot upend and you open and close brackets, and then you put in here the value that you want to depend. So let's put him the number 10 for example. I'm a let's print out our joint list result. And so if we save and run this, we actually see something that's a little bit surprising. We get something that's none, and so why do we get this? Well, the reason that we got this is because this upend operation is actually done in place, and we've done a little bit too much by saying the joint list is equal to this, because really, what we said is the joint list is equal to whatever is returned by this operation, so that doesn't make a lot of sense right now, but we'll this will make a little bit more sentence when we go into functions. So that's something that we have to watch out for. If we do things like append, they're done in place, so we don't actually have to save it into the value. Actually, if we do that, we would get an error is not an error, but we would not get what we'd expect as we see here. And so to avoid that, we're gonna do it all in place. So actually don't need to overwrite the value as we've done. You are here, We've created it. But we could. Overriding it is technically what we're doing here. So we don't need to do that if we do something like a pendant. So if we save and run it now we see that now we've out of 10 to the end of it, and we didn't have to save it or anything. It's just all done in place for us. 13. Copy of 12Dictionaries: favor one, It's Max. And welcome back to my python tutorial. So we've seen a data structure already in the form of a list, but we're gonna look at some different data structures. Python also has something called a dictionary, which is a very interesting way of storing data, but yeah, let's just dive right in and let's just get a feel for what dictionaries can actually do. So to create a dictionary, um, were created in a variable called Dick Variable, and we'll have this be equal to And so to create a dictionary, we're gonna open and close these curly parentheses like this, Um, and no, rather than in lists. For example, when we created a just a general list, we had the open and close, great parentheses, and then we just put in the elements like this, um, for a dictionary. What we have is actually something known as a key value pair. So first we have a key, and then we have a colon, and then we have a corresponding value like this, and each key value pair. You can kind of imagine it being an element of, in this case, a dictionary. But you could imagine this, for example, being element of the list. Kind of that's that's kind of how it corresponds like that. And so if we want to add a second key value pair or second element, we're gonna put in here comma, and then we can have, for example, key to and unassociated value to. So that's how this dictionary is built up. So if we print out are variable like we have it right here and we save and run, then what we see is we get this output and we see we have these curly parentheses here, which tells us that we have a dictionary, and then we see we have the key and the value separated by a colon, and then that's their first key value pair. Then we have a comma to indicate that we're gonna have our 2nd 1 now and then. We've got a key to the value, too. So what does this key actually do, though? So what's cool about this is if you want to access the elements rather than by lists or strings, where we put in an index like, say, zero or one or two, or whatever, where we use these indices to access the elements that list a dictionary and Python isn't actually ordered. So even though we may put in the index zero, that doesn't mean that we would get key, for example, because the way that the dictionary is stored is random. There is there is inherently no order in it. And that's also why we can't use indices to access these elements. So if you want to access the value that corresponds to the key, we're actually gonna have to look at the key value here. And so if we save and run this, then we see first we have our dictionary here, and then we have the value that corresponds to the key that we've been looking at. So to make this a little bit more concrete, let's add another key value pair in here, and we'll just add our standard hello world and we'll have hell will be the key and we'll have a world me the value. So let's print out the value of the key. Hello, and you noticed that the way that we access the value is always the same with the open and close parentheses. After are variable name and so we save and run this and then we see that the corresponding value to the key Hello is the value world. Now, if you want to kind of extend our dictionary as we're going through it, we can do that very easily. We can go into a variable, and if you want to create a new key, we'll just put in the name of the new key. So you will just put on the new key name. And then here were put in the appropriate value that we want like this. And right now I'm putting in everything and strings. But they don't need to be strings. They can be any other data types so they could be introduce. They can be floats. They can even be lists if we wanted them to be. So let's do that. Let's add in the new key name, which is just going to be an extra key that we're gonna have here. And then let's give it this appropriate value. I don't Let's just print out are variable or our new dictionary that we've created. And so what we see here in the end is we've added a new keep and the valued has is the list with one element and the only element. It has the value of 0.1 so we can see that dictionaries are really cool. They're also very powerful, and you know we can mess around with them easily, and it's much easier to access the elements if we know what we're looking for. On the downside, they don't have order on DSO. That's something that a list has, and so usually you'll know when you want to use a dictionary and when you want to use a list. But it's always nice to know that you have options to use either. 14. Copy of 13Tuples: everyone, It's Max. And welcome back to my python tutorial. So in this tutorial, we're gonna look at two pools, which is another data structure. So we've already seen two data structures, one of them being the list, the other one being the dictionary. Now, 1/3 common data structure that's used in Python is a two bowl. So let's create a test to pull so created testable here now to create a tube or we're gonna just open and close parentheses. And so if we want to create an empty tube, all this would be the way to do it. Andan We can print out the test to pull like this, and we can save and run our code. And so he received. We've got an empty to bowl. Now, if we want to actually fill it up, though, we can start putting elements inside. And so if you want a 12 bull, we can put in a number or a pretty much we can put in any data type, but we're just gonna use numbers. But you can also put in strings, your lists or dictionaries or really, whatever you want. Let's just put in the number two right now. Now, the big difference between two poles and everything else is that if we have just one element inside, we still need to put a comma at the end. So to create a tupelov size one, we're gonna put parentheses and then we'll do two comma. And then if we save and run this, then we see here we have a to pull of sites one. Now, if you want to create a second to bowl, which will have be maybe hello and world as two elements. Now, once we have more than one element, we no longer need to end with a comma. So only for the case of the 12 But do we need a common at the end here? And then we can print out or second to pull if we want, like this and save and run it. And so he receive. We've gotta want to pull and or two to pull. Um, and we can also do some operations on them, like we can add them together, just like we know with lists. So at our test Tupelo and are second to pull together, and that would just join them together as we see here, we can also access certain elements. So in this case, we only have one element in the testable. So we'd be axing the zeroth element, which is what we see here. We can also access several elements or do spicing like we know it from, um, lists and strings so we can go zero up to. And actually, if we leave this blank, we're going to go up to all the way to the end. So if we save and run this, we see we actually get the original to pull back because we've just taken the whole to bowl . One thing that's important to know that we can't do with two pools is we can't reassign the values. So if I take my second to bowl and I wanna have a new value assigned to it, and then I tried to print out my second to bowl, I'm actually going to run into an era because that's where two poles differ from lists is that I can't change the values once I've defined them. And so that's one of the important differences between two Poles and lists is that they're both kind of groupings. But in two polls, it's very important that once I've created a value, I can't change the value anymore. 15. 14TypeConversion: everyone, it's Max and welcome back to my pipe editorial. So we've seen a lot of different types. But what's important in Python is we can't just join different types together. We have to do something called typecasting. And so what typecasting is is a lot of it allows us to convert one type into another. So let's see an example of this. Let's create an invariable and let's create a string variable. And we'll have this be equal to the interview one and here will have, um, let's just say the string very of what's gonna be score like this and so I don't want to do so. We want to create a score which is going to be equal to our string variable, plus our invariable. So really, what we want is we wanted to say score, score is one like this? So that's what we want from our score here. Now, if you try this and if we try to print out the score, if we save and run this, we're gonna get an error because these are different types. Here we have a string, and here we have an integer and this plus symbol me something different for strings Thanet does for integers. So what we're gonna need to do is we're gonna need to convert or integer to a string. So the way that we can do that is we can put this str in front and then we can put parentheses around what we want to convert to a string. So now what we're doing is we're converting this integer one. So with SGR around, one we're doing is we're converting the integer one to the string one which, if you print it out, doesn't look different. But the to the computer, it's completely different worlds. The difference between strings and integers is just immense for it. And so now we have a string here and a string here and the plus for string Clustering is easy. It just means drawing together. So if we save and run this, then we see we get the result that we've expected. Now we can also create a second test string and let's have this be an interview in this case. But it's gonna be a string, of course, and we're gonna try to do a test some and now we want to add the second test string. So you want to add the interview value of this Plus two are rather to our invariable like this. So we want to get the result. But again here, we're gonna have the problem that we're adding strings to introduce. So free save, run. We see we get the result of score one, which is what we have here. But now, once we reach this place here, our program crashes because we've got a string. An integer so we can do is we can convert this to an inter germ. And so this only works if the string actually contains interview values. So if we tried this on anything button integer, it's gonna fail because it doesn't know how to convert words two integers. That doesn't make sense. But in the cases where our string is actually just introduced or it can be floats, then this conversion works. So if we save and run this, then we see we get the result for no you mentioned floats. So let's have our float very born. Let's have this be equal to Rather will have a string float variable. So we're gonna have a string, but it's gonna contain a floating point number 4.7 like this and we're gonna have our second. Some is going to be equal to our strength flowed variable and we're just going to add to it are interred your variable. Now, the addition between integers and floating point numbers as well to find the computer knows exactly what that means. And if we print out second some, we're going to get an air, though, because again, we first need to convert this string here to an integer. So if we save and run this and try toe see what happens, we're going to get the same air that we always get. We have here a string here we have an integer the computer doesn't know what to do. You know, we can use float typecasting so we'll use the float type, and then we'll put in parentheses The thing that we want to convert to a floating point number and then what we're gonna what's gonna happen is 4.7 is gonna be converted to the float number 4.7. So float of the string 4.7 converts to a floating number 4.7 and we've got the same thing here. So end of the string Three converts to the interview three. So now if we save and run this we see we get the result 5.7. So we've seen these types of converse is in action, but we can also do is we can take it just a general float variable say 5.7 and then this create our third some And in this case, we want to convert our float to an integer and to it we want to end outer and variable. Now we want to print out the result of our there is some No, If I don't put into your it's not gonna make a difference because I can add a floating point number and interject together. But if I do put into your something interesting is gonna happen where the result I'm gonna get is gonna be six. And so what happens if I put an integer around a floating point number? I was gonna get the interviewer version of it. So the decimal part is all gonna be cut off and I'm just gonna get the integer Just gonna be five. So we get five plus one. We're just gonna give us six. This is how type conversion works and becomes important because, for example, in terms of printing things out like strings. And if you want to add some sentences together and all of these things, that it's important that we know how to convert different types so that we can join them together, or in case you're storing the numbers that strings for some reason where you're reading them in and then you want to be able to convert them to introduce. And so that's what we have here. You want to be able to convert them to floating point numbers, so type conversion is important to keep in mind, but it's also very cool to use. 16. 15UserInput: everyone, it's Max. And welcome back to my private tutorial. So let's go ahead and take a look at user input. Sometimes you want a program to be interactive with the user or we want to be able to ask the user to give us some of their information. And to do that, we're gonna need to be able to prompt the user to input stuff we're going to be needing to save this input. So we'll create a input variable that's just going to save whatever the user inputs, which will ask of them in a second and to ask them and put something. We're just gonna type the keyword input and we're gonna open and close parentheses. Now we can leave it just like that. But if we do that, then it's just gonna have kind of an empty prompt here. And the user won't really be sure if they need it and put something because it's just gonna be blank. So to help the user understand what to input, we're gonna put a string in here, and this string is going to be the prompt that the user is going to read. So, for example, I can write, Please enter your name and a four minute a bit nicely. And then on the next line, we'll just print out whatever we saved as their input. So if we save and run this, then what we see is we get the prompt. Please enter your name, which comes right from here and so I can enter my name Max, and then it's giving back to me on the next line. So what happened is I was prompted to enter my name. And once I type in my name, my press enter, all of that is saved in the input variable. And that's what I stored. And then I can kind of give it back if I want, or I can use it later on. Now, something else that we can do is we can have maybe a second input, and we'll have this be input. And you were gonna ask, How many donuts do you like to eat for breakfast? Um, and so that's good. The prompt that we're gonna give them. But we're expecting in number. So what we're gonna do is we're gonna automatically cast the input to an integer. So we're gonna put this interviewer around the input, and that's automatically going to convert the input to an integer. Now it's important to note that when you get input, it's usually where it's gonna be in the form of a string, and you're going to store it in the form of a string. So if you want it, um, in the form of something else, they're gonna need to cast it. However, it's also important to note that if I put this around here and they don't give me something that could be converted to integer, my program's gonna crash. So those are important things to keep in mind, All right, So if we save and run this and I've also added an extra line here, that's gonna kind of print their answers to both of them back. So first we answer my name. Max and I like Teoh Two doughnuts for breakfast. And so that's what you could see here. First you see Max and then you see the number two. So that's where how we can go about user input, ID like to show you what happens in case I don't input integer. So let's say Max. And in here, all types say none. Then my program's gonna crash because I'm going to get an error. So it's important to know, or it's important to make sure that the input integer on. Do you can do some checking And maybe if you want, you can use um loops and continues to check if what the imported is actually integer because otherwise, if the user doesn't follow your instructions, it could cause your program to crash. 17. Copy of 16GlobalVariables: everyone, it's Max. And welcome back to my python tutorial. So what we're gonna look at in this lecture is going to be global variables. Now, we've seen in general variables like this, for example, or rather, just a single variable, for example, like the number seven But we can do is we can actually create a global variable by adding the keyword global in front. And what this does is sometimes when we have things and we really expand or code, something's only have a local environment, for example, of function which we haven't seen yet. But we will see soon. So functions only have local variables. And so if you wanna have access to global variables, we have to put this global keyword inside. And that allows us to ecstasies variables, even if we're inside of a different environment. That on Lee has local variables inside it. 18. 17Functions: heroin. It's Max. And welcome back to my private editorial. In this lecture, we're gonna be looking at functions. So basically, what a function allows us to do is let all of us to define a little block of code that we want to repeat over and over. And rather than having to copy and paste the code or writing it over and over again every time we could just call the function by its name and all of the code that's contained inside of it will be executed. So the function has a general for meant, which is going to be starting with a deaf keyword. So we're gonna be defining a function. Then we have a function name. Um, and then we have a open and closed parentheses, and here we can put in input variables or weaken define, um, input variables. So if we cannot, for example, and put very one and input variable to like we have here separated by commas, every new input variable has to be separated by comma, just like elements, analyst. And then we've got a colon here and now we go onto the next line and then we have some code and here it's important to note that we're using indentation. So because we're in this function, we have to be indented, and then we can have some more code if you want in here. But as soon as we stop assumes we go out of the function. If you want to go out, we have to stop this indentation. So here we're no longer in the function. And so that's one of the examples where indentation plays a very important role. Don't leave us up here as common so that we can reference it. But let's go ahead and create our own function. So we're gonna create a function, and we'll just call this one. Add one, and it's gonna take one variable as input and we'll just call this Variable X and then we're gonna have our Colin here and we're gonna be indented. And then we're going to say something like Why is equal to start with the indignation again ? So why is gonna be equal to X plus one? So here we're creating a local variable. Why? So the function is one of the places where we have this local very born recruiting local very why which is gonna be equal to the value of X plus one. And now comes the very important part of the function, which is we want to give the final value back. And so the way that we can do that is we're gonna take the return key word, and we're just gonna return. Why? And so what that does is that we have this input here. All of this stuff is done inside here, and this is the final value that we get back from it. So in terms of an example, let's say our start variable or start number is gonna be one. And let's create our next number variable, which is gonna be. And now we're going to call the function, add one, and we're gonna give it the input of the start number like this and note that I don't have to have these variable name is the same here. This name is only important for what I'm refering to it inside of the function, but it doesn't actually have to be the name appear. This is just a placeholder name. And so that's what we've got here. So what we do is we start with the number one and then we create a variable called next number, which is going to be equal to whatever is returned from this ad One function which has the input of the start number. So if it print out, are next number, what we and save and run. This, we see, is we get the number to return or we get the number two. So what happened is that we went into our add one function and we've given the input of the start number, which is now equal toe acts and star start numbers one. So that means X is equal to one. And now we create a local variable in here called Why? Which is equal to X plus one and said Why is equal to one plus one which is equal to two and that's what we return. So we returned to. And so all of this is replaced by this value that we return here. So what we're really saying is next number is equal to return of why so we returned to the next number is equal to two. So all of this gets replaced, but too. And that's why we have the next number here being equal to two. Now if we see an example using the global variable so we can say, um, let's create a global X like this and let's give it the number five and then that's going here and call the global And then the actual name is the Global X. So what we're doing here is we're importing, in some sense, this global X variable. So now we have access to it locally, inside of our inside of our function here. And so what we can do is, rather than saying Y is equal to X plus one, we can also say why is equal to Global X plus one. Now you note that the input I have here is irrelevant because it's no longer used inside. But if I save and run this, then I'll see if I get the value six. And that's because I'm using this Global X that I've imported in here using the global keyword on DATs. What I also get returned, not here. But it's important to note that the way I didn't hear, for example, because I removed this input X and no longer shows up anywhere inside of this function it's no longer being considered anywhere. But that's how we would go ahead and use the global variable if we wanted to, for example. 19. 18BooleanExpressions: every woman. It's Max. And welcome back to my pipe, editorial. So we've seen Boolean variables before. Now we're gonna look at Bullen Expressions, which we can kind of think of the operation similar, how we looked at arithmetic operations for introducing floats, and we looked at string operations for strings. Now we're gonna be looking at Boolean expressions which are not completely operations on Boolean variables but their operations that are going to give us Boolean variables back. So let's just see this in action. So one of the things that we can look at, for example, or a lot of things that we're gonna be doing actually is gonna be comparisons. So let's look at an example of looking at greater than And so if we do a comparison of Les , say, six and seven if we put in here, eh, greater than symbol. What we're doing is we're checking if seven is greater than six. And if we print out the result of greater than and we save and run this, what we see is the response that we get is true. So seven is greater than six. If you put in here less than and we save and run this let me get the response false. So if we undo this and maybe create a new variable when we'll call it lesson and we'll have that be equal to seven. Lesson six and we print out the result in less than and we save him on this. So we see that are greater than has the value true and are less than has the value false. So we're not really putting Boolean values in here, but we're doing a comparison, and we're getting a BOOLEAN value out of it. So some other comparisons that we can do is, for example, equal to, um like this, and so will look at his seven equal to six. And now it's important to note, if I'm checking, equivalence actually have to use to equal signs rather than one. So the one equal sign means assignment. The double equal sign means equal comparison. So we're comparing if they're equal to each other and so I can print out the result of equal to and I can check this seven equal to six and here in this case, we again get the response false. I can also make a second equal to part two. And here we're going to compare seven to the number seven. And we can also print out equal to part two. Um And if we save and run this, then we see we get false here for comparing seven and six and we get true because seven is equal to seven. No, What if you want to do not equal to Well, the way that we can do that is we can look at seven and then we have an exclamation mark. Equal sign six and self free front out. Not people, too. And if we save and run this, then we see we get the response true here. So what we're saying here is we're saying, is seven not equal to six or seven is indeed not equal to six. So we get the value true out of here now, we can also do greater than or equal to so we can Sick Look, is seven greater than as we've had up here, or equal to having this equal symbol here? Six. And we could print out the greater than or equal to results we saved. Run this And we see that by this true respondents here seven is greater than or equal to six, which is true or weaken. Do less than or equal to, and so that will have is seven less than or equal to six and not the location of this greater than of this lesson. Simple. So it's important that it's always on the left side of this second equal, or this actually the second part of this equality check. So we're replacing one of the equal signs here with this greater than with this less than or with this exclamation mark for the case of not equal to. So it's part of the result of less than or equal to. And if we save and run this here we see, we get the result false. So seven is not less than or equal to six. 20. 19IfElifElseStatements: everyone, It's Max. And welcome back to my python tutorial. So now we're gonna be taking our first look at control flow in programming and the way that we're gonna be doing that is gonna be using if statements. So the general format is that we have an if statement here and then we have a boo in expression in here, and then we've got a colon. And then we've got some code that will execute if the if statement is in fact true or if this Boolean expression is true. So let's see an example of that. Let's create our test very warm. And let's have the speak to the number 10. And let's say if our test very bull is less than 10 let's print out the sentence Value is less than 10. So what we're doing is we've created our test variable, which has the value 10. Here we have our Boolean expression was checks. If the test variables less 10 which in this case it wouldn't be so if we save and run this , then we're actually not gonna be getting any output because they're test variable. It's not less than 10 but if we make our test variable nine, for example, and we save him with this. Then we see that we get the output, which says our values less than 10. So it's important to note that were also using the indentation here for the if statement. So just like we saw in functions where we added invitation for the if statement, we're also gonna have toe indentation. So if he wants looking at this kind of example appear, we can also add a more code, which is all fine as long as we're indented and as long as we're no longer indented, were no longer in the if statement. So it's important here. We could maybe add a second print statement se still in if and the McCain ad a final print statement outside or we say no longer. And if like this and so if we save and run this, then we'll see. If we have the test for about nine will see that the values loss of 10 and the most say we're still in the If and then we print out. We're no longer in the if, but if we have our test variable be equal to 10. For example, and we saved on this. They were not gonna print out the values less than 10 nor we're gonna print out. Still in if Because we never went into this. If statement because our test variable is not less than 10 we only print out no longer. And if so, we see that this is no longer part of this if statement. All right, so it is one thing, But what if, you know, we want to look for one thing, and if that's not the case, we want to do something else. So what we can do is we can add an else statement. This is so kind of like the default. So in case this doesn't work, so if this fails, then we'll revert to the default, which is gonna be this else case. And because it's the default, you'll notice that we don't need to add any Boolean expressions in here. So if we add in terms of comments that will have this else statement and then we'll have here some code now, it's also important is that I'm not allowed to put anything in between here, so I'm no code is allowed to go here if I want to use this l statement. So the else statement has to follow the if statement. The only thing that's in between is gonna be intended blocks. But it's important that the else follows the if and that there's nothing in between here, so comments are OK because they're ignored by the computer. But anything else is not. So. I can't have this print statement in here, for example, because otherwise the computer won't recognize that this else and this if that they're connected. So let's print out what happens. In case our test variable is not less than 10. We'll just print out very born, not less than 10. So either our test variables Lesson 10 in which case will print out these two values otherwise will say that are very bold is not less than 10. So we'll see that they were output here, which says the variable is not less intent. So we've entered this default kind of case. Now, another cool thing that we can do is we can use something called in l f statement and the form of the L F is going to be or what actually stands for else. If so, if this doesn't work, but we want to still check for other stuff, then we can look for else if and then we have a another Boolean expression here. And if this Boolean expression is, too if this boon expression is true, they were gonna execute some code in here. And if we want, we can also execute more code. And we can also do the same thing in the else statement. So if we have this l a few, for example, And then let's check if our test variable is equal to 10. Then let's print out. Very bowl is 10 like this. So now we have different cases. First, we're checking it for variables. Lesson 10. If it isn't, then we go into this else if and we check if our variables equal to 10. If it is, then we print out the very most 10. If neither of these cases are true, we're gonna enter the default case. So if we save and run, this we're going to see is we're going to get the output. Variable is 10 because that's the case that we're going to. And since we've executed one of these cases, we no longer have to revert to the default If we start off with mine like this. And if we save and run this, then we're going to get that the values lesson 10 and also the still in if statement that we have here. But because we've executed this if statement here, we're gonna be ignoring this else if or this default case because we've already executed the If so, we don't need to check for other else cases because we've already found the case that works . Now there is a difference in using L f and l on just if so, if I don't use LF here then I'm doing another check. And so I'm not doing either, or first I'm gonna check this, Then I'm gonna check this. So if I do, let's say less than 11 for example, and I make my test variable 10 and I save and run this. Then what I see is first I say the values less than well, I guess 11 would have been more appropriate here. So let's save and run that one more time. First I look at this f statement and I see the tennis lesson 11 which is what I get here. Then I go into this if statement and I see that the very blows 10 which is what I get here . And then I print out or well, then I don't go to the default case and then I print out that we're no longer in the If so that's the difference between us if, LF if, in case it or if otherwise, I had this LF statement here, then I wouldn't execute both of them. And so if I save and run this, then we see I no longer print out the very blows 10 which I had appear because I'm checking else. If so, otherwise, if in this case, the also statement isn't really useful, because if our variable value is less than 10 than if our values less than 11 than it may well be 10. But 10 is always less than 11. So we're never gonna execute this statement. So that's why it's important that we have our l o statements that they actually make sense that they can be executed because otherwise they would just fall into this case here and they would never be executed 21. 20ForLoops: everyone, it's Max. And welcome back to my private tutorial. So in this lecture, we're gonna be looking at another form of control flow, which is going to be loops, and we're gonna be looking at four lip service. So the general structure of A for loop is going to be the four key word that we're gonna have a looping variable, which is going to do all of the looping for us. And that's gonna store each of the variables or each of the values one by one that we're gonna use the in cured, and then over here we're gonna have what we loop over or other what we over. So that's what we're gonna have over here, and we're gonna have a colon, and then we're going to be indented, and we're gonna have some code. May will have some more code. So that's the general structure of a for loop. So let's see some examples of this. The first thing that we're gonna do is we're gonna be creating a test list with the values 15 hand seven and we're gonna use a for loop to loop over test list. So let's create a four and then we'll just create and looping variable. And we'll call this one element because that's an appropriate name because we're going through a test list element by element. So this is always gonna be an element in the list, and you can really call it whatever you want. I just call it elements because I think it's a good, appropriate name that if I read this code later, helps we understand what this what this variable really is. So for element in our test list, let's just print out the element like this and I save him. Run and I see I get one and five and seven. And if you haven't noticed by now, every time I do the print statement, I get a new line. And that's just inherent to the print statement that the Prince statement automatically adds in new line once you know every every statement. So it's just for formatting stuff to make output easier. If you want to change that, you can actually define the end very born here, and then you can put in whatever you want. You want a space, for example, then you can just put in a space like this and that's gonna change how your print statement ends. So we see that now we have no longer have these lines. We have these spaces you want to do, you know how to create a new line. You can just put a backslash. And so this backslash is a special escape character on DSO. That's what's gonna That's what it's gonna do here. And so then we have our new lines again. But anyway, so that was just a quick side note. So that's one of the loops that we can do. We can loop over lists. We can also create a test string on Let's call this one just hello like we used to. And then we'll say another full living will say for a character in our test string, we'll print out each character like this. And so if we save and run this, then we have our first output, which is 157 and then we see that we actually loop over the string character by character so we get H E l 00 each of the characters in Hello and you'll notice that the common theme between its twos that weaken do spicing so we can access individual indices. So you remember that we could do something like test string, too, so we could access in third element of the third character in our testing. And we could also do something like test list, too, so we could access the third element in our test list. So that's what we have here for different types of loops. If you want, we can also just create, and this is also a very common thing to do. We can create a number range so well, safer number in, and then we can use something called a range function where we can put in a starting number , a stopping number and a step size. And then we can just print out our number. So let's quickly define these variables that we've put in here. So are starting number that start at zero, are stopping number is gonna be 10 and let's have our step size be one for now. And it's important to note that are stopping. Number means we go up to, but not including this. So we're going to see the number nine, but we're not going to see the number 10 so we save him on this. Then we see we get the numbers one through nine. Um, but we are starting zero through nine because we started zero. We going step size of one, but we don't include 10. Even if we go into step size of two will go from 0 to 8. But we don't include 10 because it goes up to but not including. We don't have to include the step size. If we don't want to weaken, just do start and stop like this. So we started zero and then defaults to a step size of one. Or we can also just put in the stop, and then it defaults the starting at zero, and it defaults to a step size of one. It's important to note that if you have two elements, that means the 1st 1 is gonna be the start. Value in the 2nd 1 is going to be the stop. If you have three, then you have the start, stop and step size. But if you only have one, then you're only gonna have the stopping very one here 22. 21WhileLoops: everyone wants Max End. Welcome back to my piper editorial. So in the last video, we've seen four loops. Not we'll be looking at the other type of loop control full, which is gonna be wild loops. And so the general structure of a while loop is that we start off with while a keyword, and then we've got here a Boolean expression. Or actually, we have a Boolean value here which could also be a Boolean expression or could be the result of a bullet expression. And then we have some code and maybe some more code that we execute. So that's how Ah, while group looks like let's see an example, let's create our start variable, which is going to be zero. We're going to say, while our start is less than 10 let's print out our start variable, and we want to make sure that we don't stay in an infinite loop, and so we're gonna at the end increment are start variable by one. So we're going to say our start very bull, we're gonna override it to be its previous value, and we're gonna add one to it. And so this code or this loop is gonna execute until start is no longer less than 10. So if we save and run this we see we get the values from zero up to nine, you can also add, say, 1.5, for example. We can save him on this, and then we see we get from zero option line in a step size of 1.5. Um, So what else can we dio? Well, let's do this in a little bit of a short form. So what we can do is we can abbreviate. This start is equal to start plus 1.5 by saying start first equals 1.5. So, really, this is short form for this, So these mean the exact same thing. So if we saved in oneness, then we see we get the exact same results here. Now, you notice that I put in a bowling value here, and that's actually true for everything that has a bullet expression because the bullet expression just gives us back a Boolean value. So, really, if we don't even want to check for something, so I'll put this leave this here as a comment if I want to make an infinite loop, for example. I can just say while true and our wild was gonna execute until this value here is no longer true, which could change when we had this Boolean expression. But it cannot change when we have this true value here. So if you want to create an infinite loop, this is the way to do it. I'm not going to run this because it's just gonna fill my output. It's just gonna continue. Printing numbers is from zero up to infinity and steps out of the 1.5. This is one of the ways that you can create an infinite loop. If you put in here well, false. We're never actually gonna enter the loop because our expression here is already false and we only enter the loop and we only stay in it while we have a true value in here, which is what we get from our Boolean expression Here, for example, 23. 22BreakContinue: everyone, it's Max. And welcome back to my private tutorial. So we've recently seen loops. Now let's take a look at how we can manipulate our loop control flow. So how we can manipulate the way that groups flow. So let's take a look at our while. Look first, and let's create an infinite loop, which we didn't run last time. And let's create a start variable like we had last time. Let's started at zero. And every time we go through the loop, we want to increment are start variable by let's say one. And now something cool that we're gonna do is we're gonna every time we're in the loop are also gonna check if our start very bold is greater than 10. Now, if our start very bull is greater than 10 we're gonna put in here a new command, which is gonna be called break. And so what right does is it breaks out of the most inner loop. In this case, it's gonna be the wild. So in case for example, I have a second while loop over here. We're not gonna break out of that, but we would break out of the first loop but yeah, let's let's first try to understand what break even means And then we can look at the other cases, all right? And one thing that's also important to note is the indentation. So for the wild loop, we have this indentation here and we have the same indentation here. Now, for the if statement for the break here, we have actually an extra invitation. And so this means were inside of the loop, which is why we have this indentation. But we're also started the if statement, which is what this indentation that we have here if we want to continue on in the loop but no longer in the if statement we can print over here after if, for example, So we're no longer in the if statement, but we're still inside of the loop because we're still indented here. So if we save and run this gonna see we get after, if what should happen about 10 times 10 times and once our start variable is greater than 10 or I guess it should happen. Ah, 11 times, 10 times. And so once I start, variable is greater than 10. Then we're gonna break out of the group? Yes, So it happens 10 times on DSO. We see that we end this infinite loop, so we break out of it like that. So that's this break statement that we can do here. So if you want to add, are a second loop, for example. So that's created here. The bowling expression. Well, our start variable is less than 20 and then let's select all of this and let's invent it. Then we'll have our print after, if here and maybe let's print out the value of our start variable before until let's save and run this. And so we're gonna see is we're going to see an oscillation at the beginning between one and after it for between the number and after. If and then what we see is we no longer see after if because every time eso the first time we break out of it or start very bulls greater than 10. But we only break out of the innermost loop. And so as long as they're start variables less than 20 which is what we have going on here , we're gonna increment by one and we're going What? We're gonna enter this loop we're gonna increment by one. We're gonna print it out and then we're gonna check it for start variable. It's greater than 10. Just always What's gonna happen after the first time we break out of it. So we're gonna break out of the loop and we're never gonna print out this after If. But we're always gonna enter this loop again until our start variable is no longer less than 20. So we see that the break statement on Lee applies to the innermost loop. Alright, so that's four break statements. We can also use that for four loops. So Chelsea is the brake statement for four laps. Let's take a look at that that's created a test list again. Let's just have this be the values 157 like we have this last time. Let's go through it and say for element in our test list like this, and but same if, um, our element is equal to five. Then we're going to do something called continue. So we can also put the brakes statements into four loops here, and it would also break out of thumb. But we're gonna look at this. Continue statement here in four looks, So we're not gonna look at the bright and four loops even though you could as well do it. But we'll see the example of the continue statement in four loops, which, of course, you can also use in the while loop. But what to see an example of each and each. So what we're gonna do is we're gonna print out are elements, but we're going to do is if our elements equal to five, we're gonna do something called Continue. So let's just coming up these print statements. So the loops they're gonna run, but we're not gonna print anything out just so that we don't spam output and let's save and run. What we see is we get the outputs one and seven. So what happened with continue is that we don't stop the loop. But once this once we have this continue statement, we just skip the rest of the loop and we move on to the next element. So, in the case for the element being five, um, we're gonna enter the statement here, and we're gonna say the element is equal to five and then we're gonna do continue. And so we're going to skip the rest of the loop will which in this case is only the print statement. But if there was anything more below it, we would skip all of that to and our value here would just take on the last value if it already is the last value, that we would just go out of the loop completely, which we can see if we put in here the values seven, for example. So that's what we can use, break and continue for We can use it to control our loop control flow so that we can have things be really, really nice and we can make things do exactly the way it is. And this break statement is powerful in case, you know, something happened that we want to back out of. And this continue is also, you know, in certain situations you just don't want to execute the rest, and you just want to go on to the next part. So the brake and the continue statements are both very powerful and also very useful. 24. 23Modules: everyone, it's Max. And welcome back to my path, Editorial. Now we're gonna look at something extremely important to all programming languages, which is libraries or models or frameworks or whatever you like to call them, basically their packages that are written or their their programs that are written from outside, that have pre defined features that you can use and that you can import into your coat so that you don't have to write everything from scratch. Now this is really important because it allows programming communities to be built and everyone can write their own little programs and they can pass them on. And you can use all of these two. Do you know all types of cool things yourself? So like, for example, if you want to do some hard core math, you can import specific math packages so you don't have to right out how to calculate into girls and all of these things. So that's really at the heart of programming. Is this the sharing of information and the sharing of libraries or modules or frameworks, or whatever you like to call them, so you'll find a lot of these on get up and all of these sites that you can just download, and then you can import. Um, so we'll be taking a look at one of these simple packages that's actually included in Python. And it's called the Time Package. And to import one of these libraries, we just put in here the important name and then we just put in here the name of the library that we wanna import. In this case, it's gonna be time. So let's just print out the results. All right, So to get something from this package, we first have to go into it. So we're gonna put in here the name in which in this case is time and now we go into this time library and now we can access all of the features inside. Now, you don't really know what's inside, but you can find out. And usually all of these libraries contained documentation. So you can look at the documentation and you can see what types of features are, you know, part of this library. So I know, for example, that in this time library there is a function cold time, which gives you back the you next time. So if I save and run This what we get this number here, which is pretty much the UNIX time. So it's the time in seconds since the beginning of 1970 I believe. So that's what we get here, for example, from time dot time. Another thing that's included in this time library that we can do. There's something called timed up sleep. And so what this does is it causes a program to sleep for whatever many seconds we put in here. So let's say I want our program to sleep for five seconds. I'll put in here the number five. And then afterwards, I'll just print out. Done. So first we print out. Oh, I forgot the final parentheses. So save and run this first printing of the UNIX time. Now we're sleeping for five seconds, and then we're gonna print out. Done. All right. Um, yeah. We're also printing out the response that we get from here, so we didn't actually need to print this out. We could have just left it like this s O. That's what we get from that. You next time here and then we print out done because now we finished. So that's how packages work that you can import. Hm. And then you put go into the package by using the dot and then you can access all of the features inside. Now, there are different forms that you can import them. So there are different syntax is that you can use the one that we've seen up here was import time. Something else that you can do is say from time I can import a specific package. So, for example, from time, I only want this sleep that I could just do from time import sleep. And so, rather than having to go into time, what I can do is I can just say sleep five. And if I save, run this, then I see I don't need to go into the time because from this time in library, I'm directly importing this sleep function. So these air different forms off input that we can use or imports that we can use for packages. You know, each has their pros and cons, but whatever you need, you can use. So the problem with the one up here is that you're importing the whole library, which could take up more memory. The problem with the one down here. Is that your importing the function aimed directly so you can't create a function inside of your own code? That's called sleep, because otherwise the Python program would get confused, so you need to make sure that the names don't overlap. 25. Course Outro: Hey, everyone, it's Max. And I just wanted to say Congratulations on finishing the course now. I want to remind you, toe make sure to go through the exercises that I've put in the project section of. That way you're going to feel even more comfortable. No writing code, because you're gonna be practicing and applying what you've learned. And also you want to start applying this knowledge in different areas. So that could, for example, be automating just repetitive tasks either at your work or even for a hobby that you have, or something like that, or taking your programming knowledge further and learning even more in depth skills like Web development or data science.