Learn Python - The Fundamentals of Python Programming Language | Derrick Sherrill | Skillshare

Learn Python - The Fundamentals of Python Programming Language

Derrick Sherrill, Learn to Code, Change the World

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
16 Lessons (49m)
    • 1. Python Intro Video Udemy Course

      0:27
    • 2. Download & Setup

      3:58
    • 3. Syntax and Commenting

      3:32
    • 4. Variables & Data types

      4:12
    • 5. Composite Data Types and Mutability

      4:48
    • 6. Numbers

      2:50
    • 7. Lists

      4:22
    • 8. Strings

      2:32
    • 9. Tuples

      1:30
    • 10. Sets and Frozensets

      3:27
    • 11. Dictionaries

      3:01
    • 12. If Statements

      3:06
    • 13. While Loops

      2:00
    • 14. For Loops

      2:48
    • 15. Python Functions video for courses

      2:19
    • 16. Class Objects Course Video

      4:07
45 students are watching this class

About This Class

In this class we'll go over the building blocks of python. Once we understand all of these concepts, we'll be able to build anything and everything in python. 

Here's what we'll cover:

1. Download and Install Python / Text Editor

 2. Syntax & Commenting

3. Variables & Data Types

4. Composite Data Types

5. Numbers

6. Lists

7. Strings

 8. Tuples

9. Sets & Frozensets

 10. Dictionaries 

 11. If Loops

12. While Loops

13. For Loops

14. Functions

15. Class Objects 

This will lead us into how we can utilize the true object oriented programming nature of python!

Transcripts

1. Python Intro Video Udemy Course: Hello, everyone. And welcome to the Channel. This video is a full course designed to take you from a beginner and right on to the intermediate level. My style for this tutorial on all my other ones is very quick and to the point. So if you'd like to stop a content, feel free to subscribe to my channel or drop a like on this video. But that being said, I hope this course teaches you python in the most effective and efficient way. 2. Download & Setup: Hello, everyone In this video, we'll talk about how we can download Python and start using it. You might already have python insulted in your system if you're using a Mac like I am. So if you open up a terminal, you might be able to type in python and see a python show. That's because a lot of Mac books already come pre installed with python on them. We see that this version, though, is piped on 2.7, and this isn't what we want to use. Python has two different versions. Python Twos. The legacy version of Python and Python 30 is the new version. We want to be sure to use the new version because this is what will be updated in the future. So let's go ahead and close out of this and then we'll open up a window and pull up the page. Python dot org's slash downloads, and we see that the news version of Python right now is 3.7 point three. Let's go ahead and download this and we see it downloading in the bottom left corner whenever it finishes will open it up. We'll go through the installer, a few moments later, it looks like we've successfully installed bottom 3.7. We'll close this and move it to the trash. Now that we have Python three installed, we should be able to open up a terminal again. In this time, instead of typing, Python will talk in Python 30. So this is denoting the Virgin Python three instead of the default factory of Hot on Version two. Well hit Enter. And now when we enter this into the terminal, we see that we're running piped on 3.7 and that means we get to proceed. We'll go ahead and close out of this and close out of this one as well. Now, the next step that I want to do is to get a text editor. Let's go back over to her window and type in Adam I. O. And this is the text editor that I'll be using in this course. So Adam is just an open source text editor, so that means that the community can build packages and themes for to improve our experience using it. We'll go ahead and click, do and download this already have it, so I'll just open up my Adam, text editor. This is what the default view of Adam looks like. We'll go ahead and click Adam, and then we'll drop down the preferences. And there's a few packages that I would recommend to install for this course. The 1st 1 is auto complete Dash Python, which is just an auto completion tool that we can use when recording and python and then platform io dash I. D Dash terminal. What this does is it gives us this little terminal down here in the bottom left corner that we can open whenever we want. This, by far, is one the most helpful packages for me whenever I'm coating, so I would encourage you to get those two. And then the things that I'm running if you want to follow along completely with how mine looks, is one dark in the user interface theme. And then, for the syntax thing, I use one dark as well. You don't have to choose these themes, and there's a lot of created things from the community as well that you can use. But these things are very nice for me because they show up brightly. Whenever I'm recording videos, go ahead and exit out of the settings and jump back up and create a new file. Oh, increase my fath sighs. First thing we should do Sit command s and we'll save this as a Python script. So every Python script ends with the extension P y. Well, say example, not people I and Click save. I already have one, so I'll replace it now. Adam automatically gives us a director here as well. So since I'm working in my desktop, everything on my desktop appears here. This is very useful for navigation whenever we have large projects. But for now, since we just have one script, I'll go ahead and close it. Let's go ahead and create our first Python script. So the very basic when that everyone does, and that you have to do as well is using the print function. A function is just the noted by the parentheses after a word. So here we have the function print, and we know it's a function because of the parentheses. This function takes him whatever you pass here of the same data type, imprints it to the terminal. So let's say hello world. We'll save her file. We'll go ahead and go down to that terminal and then we'll type in Python three and then the name of the file. So ours is example. DuPuy hit return and we see that the return to the terminal is the hello world that we passed through the print function here. And congratulations. You destroy your first Python script. We'll keep on building on this. But for this video, it's important that we have piped on downloaded and we have a text that it is ready to go. I'll see you in the next one. 3. Syntax and Commenting: Hey guys, welcome back and this video will talk syntax and call meeting. Let's get started. So back in our text editor here we have the print Hello World statement from the last video . Now let's talk about how we could make a comment and our Python scripts calm. And a Python script is just the line of code that isn't executed. So these air often notes for developers and programmers so we can leave notes and are part time scripts throughout to let us know what we were thinking at that time. If we wanted to put a comment above her first line of code, we could drop that line of code down and then use a number. Sign this number, son. Just a note to comment and this line is not read. Whenever we execute the Python script, what we'll do is we'll put the number side and then try to always put one space after your comment. Then we'll pass in the comment that we won't here. So this is our first piped on script, and that's how we would make a comment in python block comments and pipe thunder down the same way. So he wanted to do a block comment, we could drop down for another town son and then put in another line of text. This is a comment. The more comments you put in your script, the better it usually is because this means that someone else can pick up your Python script and understand what you were thinking. Whatever you were writing it. Since Python emphasizes the ability to be able to quickly look at a Python script and understand what's going on, comments are always a good thing. Now let's talk about the syntax of Python. Python is one of few programming languages that uses white space. Let's say that we have a blocking code that looks like this. We have a variable X is equal to one, and then we want to make a simple function. So if X is greater than zero will put a colon here. Now watch what happens in the text editor whenever I press enter at automatically spaces over four spaces. So whenever we have an indented block of code, we know that the control flow happens here. We know that anything that happens here belongs to this. If statement will use their function, print and then we'll say X is greater. Then zero we'll savour file will drop back down to our terminal, will execute the script again by pressing up and then we'll hit return. And now we see we get the return X is greater than zero. This is because X is equal to one so therefore it's greater than zero. So we get this command, we see that we were to change this to a different logic statement. So X is less than zero. It saved and execute again. We see that we don't get the return in this case, but we can drop down and put an else statement. So else here, we see is lined up with the if statement That just means that this new block of code doesn't belong to this. If statement, it's actually its own statement. But whenever we drop down to the next line, it should be indented, which it is. We see that anything we put here now belongs to the else statement. So this is a new block of code. We'll use the print function again. X is less than zero now. When we execute, we see that we get that return indentations could be thought of is just blocks of code. Here we have two blocks. Each control statement is at its own indentation level. We see that the if is lined up with the else. Each block of code following the logic statement is at its own indentation level. Each indentation level is just four spaces from the last one here. We may be tempted to hit tab whenever we're inventing, But tabs may not be consistent across operating systems, so it's encouraged that we use four spaces to do this indentation. It's OK if you don't quite understand the logic of the if and else. Right now, All that's important for this video is that we understand how we could make a comment and also how we can indent blocks a coat. In the next video, we'll dive into variables and data types. I'll see you then 4. Variables & Data types: everyone. Welcome to the next video, and this video will talk about variables and data types. Let's get started back in her parked on script where we left off Closer terminal and go ahead and delete everything in our Python script. So let's go ahead and drop down and create a variable. We already did this once where he said, X equal time one right? But variables and python need to be descriptive right now, since we're just starting out. Excess variable is fine, but in the future, available name should be something that actually makes sense. This could be something like age, maybe name or something along those lines. Right now, let's go ahead and use the age variable. The first thing about variables is that we should type them with lower cases here, up age with a lower case instead of age with an upper case with the capital. A. This may confuse people that have been using python for a while, because we tend to leave the capitalization to the class objects this guy had to change is the age with the lower case, and this is now a variable. The cool thing about Python is that we don't actually have to explicitly state what type of variable we have. All we have to do is type in what we want this variable to equal. You already saw how we set the last variable X equal and one. We can do the same thing with age here but saver file, and then we'll drop down and use the print function again. And now let's introduce a new function. Let's use the type function, and then we'll pass in the variable that we want to this function. Well, say age here. What the type function does is it returns the data type of the variable that we passed it. Let's open up terminal again and type in python three example dot pie. Make sure you have your file saved and then we'll execute. And now we see that were returned to class of an integer. Python has a lot of different data types, but let's just talk about three main ones right now. Integers air. Just positive or negative? Whole number values here, since one doesn't have a decimal place, it's an integer. If we were to change this to 1.5 and execute her script again, our class now changes to afloat. A flow is just any number that includes a decimal point. Lastly, let's talk about how we can make a string instead of typing in a number, let's put in something called a D limiter, which can either be a double quotation marks or a single quotation more. And then we'll pass in text, drop down and executing, and we see that we now have a string class. This is something that a lot of beginners really enjoy about python. We didn't need to do know anything other than what we wanted the value to be for a variable and other programming languages. You would typically have to state what type this value is whenever you assign it to this variable and python and does all the heavy lifting for us in automatically places the type to this value. This can get us in trouble sometimes, though, because what if we want afloat? Number and Python thinks it's an interview value. Let's drop down and say number. We'll set this equal to the number one, but let's say that we wanted this to be returned as a float number instead of an interview . Value we could just use something called casting and Python. What we'll do is we'll say, float and then use it as a function in passing. What we want to be a flow number. Now, instead of this returning as an integer, it should. Return is afloat type. We'll drop down and say Print type in the number. When we execute, we see that were given afloat even though the default behavior and python would have been an integer. We have access to do this with strength and and also float. Lastly, let's talk about how we should create multi word variables in python, this shop down and saying number. And then, for the second word, we should put in an underscore to separate the two words. So number. And then, let's say and age, we'll set this variable equal toe to pull, which will talk about later on the course, and we'll say, number an age. Now we can drop down and print number and age. When we do this, we get the return of both of these in A to pull their terminal. Don't worry, if you don't quite understand this people yet, we'll talk about that later on what we should take away from this lesson is that variables can be upper case. But we should keep in lower case in separate multi word variables using an underscore. We also have access to a lot of different data types and were able to explicitly state those data types using casting only if we want Teoh. Lastly, Python makes it very easy for us to create variables because automatically assigns a type depending on the value of the variable. If you got all this, you're going to move on to the next lesson. We'll talk about composite data types. I'll see you then. 5. Composite Data Types and Mutability: everyone, welcome back. Let's talk about composite data types in this lecture. The first thing we need to talk about is an immutable and immutable data type. Simply put, a mutable data type is something that we can change once we created as a variable. An immutable data type is one that we cannot change once we create the variable using that data type. We'll talk about this more whenever we get to the specific data types. But we just need to remember. Mutable means changeable and immutable means that we cannot change it. But for now, let's talk about the composite data types that we have available to us. We can create a list A to pull a dictionary I frozen set and also set. Let's go through the structure on. Each of these will start out with the list several creative arable and say our list will set this equal. And now list is denoted using square brackets. So we used to square brackets and everything that we put in between the square brackets belongs to the list. So let's say that we want to pass in a and then put a comma B and N C. While each of these composite data types do is allow us to put multiple values to one variable each one of these just allow us to do it in a different way for a list, were able to pass on multiple values and were able to keep the ordering of the values in list. So the first value will always be a in the second value. Always be be. A list is also able to store multiple data types. So if we were to put another common and put 1.5, drop down and say, Print our list saver file again and then we'll execute this trip. So Python three and then example dot pie and we see that our list is returned in square brackets of multiple different data types. We have strings here because we know the D limiter means a string, and we also have a float number because we have a decimal place here. A to pull was almost the same thing as a list, except that its immutable. We'll talk about that later on in our list video. But for right now, well, just look at how we create them. So I say are two people equals. And then instead of square brackets here, we'll use parentheses. Now we can do the same thing as we did before, so we'll say a B and then also see, we'll drop down in print. Our people executed to the terminal. We see that we get the same thing, except it has parentheses instead of the square brackets. Now let's talk about a dictionary so we'll say, our dictionary. And then we'll set the sequel toe curly brackets this time. And instead of just having one single value in a dictionary, a dictionary is composed of a value and a key. So these players are what make up a dictionary. We did note the's by using the key first a colon and then the value. So let's say our key is key, one as a string, and then our value will be value. One. Now dictionary is powerful because we can pass them multiple pairs into the dictionary for storage so we can say key to colon and value to We'll print this out, so our dictionary and we'll see what the return looks like. The dictionary is return the same way that we type it. Dictionaries are useful whenever we have multiple properties about something. So let's say we change the key to name and then we'll use my name. So when passing Derek, and then we can change the second key to another property of al meat. So let's say key to will be equal to hide and then we can say six foot. Now let's go ahead and talk about a set so we'll do this. One first were dropped down and say are set and then sets are created using curly brackets as well. But instead of key value pairs, it's just single elements. So I will say one. The 2nd 12 and then the 3rd 13 will go down in print our set, and when we print, we see that we have a set here. But what's the difference in using a set and using a list? Well, a set is a Nord erred. That means it doesn't keep the order here, so we see that, too, is in the first position instead of in the second position, like how we put it here and then also has to be unique if we were to include a repeat. So let's put two again and say this. We should only be returned one string to in her set. Here we see. That's exactly what we get these air used for for doing unions or intersections or something of that nature. Now for your last one, Let's say, are frozen set and a Frozen said, is just like a set in the same way that people is just like a list of Frozen said is just the immutable version of a set. But we can use frozen set and then passing the set value that we have. We'll drop down and say Print are frozen set and I should look very similar to our set. We see that it does, except that it has the parentheses around it did, noting it as a frozen set. We'll look at what we can do with mutable and immutable objects in the upcoming lectures. For now, we just need to know that there's a variety of different composite data types that we can use inner python scripts I'll see in the next video 6. Numbers: everyone. Let's talk about numbers in this lecture. Let's jump right in. Let's create a new pilot. Since I don't want to get rid of this one, we'll say This one has example to DuPuy. Close the terminal. And now let's go ahead and import our first package called math. To do this in Python, all we need to type in is import, and then the package. Everyone, this one is just called Matt, and the math packages gives us access to a lot of different operations that we couldn't do on. Our numbers will drop down, and we already know that we can create interred your values, and we can also create float values. Python also gives us access to use. Complex numbers will say Z is equal toe the real part of the number two and then plus three j the J Here. Justin notes this number as a complex number everywhere to drop down and say print type of the variable Z. Open up a terminal and execute er python scripts. A python three example to DuPuy. We see that the class is complex. Let's go ahead and close this and python. It's very easy to do math operations because they're already built in. We can drop down and save results equals and then X plus why imprint results a terminal when we execute this were given the addition of y plus X. You see that Python doesn't care about these two data types being different. If we wanted to do multiplication, we could use an ass trick. If we wanted subtraction, we could use the hyphen. And if we want a division, we could use a slash these They're all built into python already, so we don't have to do anything specialty uses. However, let's talk about how we can use the math function that we did need to import. Whenever we imported this into our Python script, it gave us access to a lot of new functions that we can use. We can look at the documentation on the Python website, but all of these represent some type of new function that we can use in your Python script . Well, let's go ahead and use one of these. Let's say we want the ceiling the smallest introduce greater than or equal to X. We'll go over and to use that we saw that we need to tighten math, dot seal and then passing the value. So let's drop down and say Print Mad Dog Seal and then we'll pass in the value So it's passing. Why we'll save the file and execute. And we see that the selling function did exactly what we thought it would and return the lowest indigent higher than her number in this case. That was, too. It's okay if you don't quite understand this part, just shit. We'll have a whole lecture on how we can start using packages that other people have built and using their functions inside of them. So don't worry just yet if you don't understand this. But what we should understand from this video is that we had three different data types and numbers where we have integers, floats and complex numbers. And we also have the ability to do simple math operations already built into python, such as addition and subtraction. And that's pretty much it for this video. I'll see you in the next one 7. Lists: Hey, everyone in this video, we'll cover Python lists. Let's get started. Air text editor. Let's go ahead and open up a new file and I'll go ahead and close. He's out in that way, we don't have them. And now the first thing we need to do is let's create a list So we'll say our list. And then remember, we denote these using square brackets and then we passing objects into the square brackets . So let's say a and then we'll say B and then we'll say, Sees Well, I'll savor, follow. That way we get the highlights. So let's say list Stop pod. And remember that list can be a multi type container so we don't have to put in just string values we can put in introduce phone numbers and any other data type that we want as well. We'll drop down and say, print our list, saving this and executing it. I will say Let's stop high and we see that we returned a list in the terminal so we know how to create a list and we can do it just like this. But if you remember, a list is also immutable object and that just means ever able to change it once we create the variable here. So if we wanted to change the Arliss Variable, we could drop down and say our list. And then if we wanted to add something in, we could upend it. So pinned parentheses and then we could upend whatever we won't here. So let's say we wanted to open the letter deep for word of print our list again, we'll see that we have a new list in our terminal, which we see that we do. We now have the string D and are less value. This is possible just because of list is mutable. If we tried to do this with the two people, we wouldn't have the same result if you remember as well, a list also keeps the order of the elements inside of no matter how many times we were to print our list, this will be the order of these elements. Since the static type keeps the ordering, that means that we're able to index values out of it. Indexing is just using the index position of an item inside of a data type to pull a specific element out of it. Let's try to only pull out the element A from our list. We could drop down and say, Print our list. And now any time that we index values out of a data type will use a square bracket. So we have our list, which is the variable here. And then we're using square brackets to pull out certain values within our variable. So for only trying to pull out a python starts in the zero index position. And what that means is that a is in the zero position, so they would be zero b would be one c would be too and so forth to pull out A We use a zero. So I put a zero here and now when we execute, which should this be returned? A. Which we are Like I said, A list keeps the order, so that's what makes this possible. It also makes it possible for us to insert elements at a certain position within our list. Will drop down and say our list, and then we'll insert for in theses. And now we specify the index position of the place that we want to put the element. So let's put it at the very beginning, and now we'll put in the element we'll put in first element as a string. Now, when we print our list, we should have a first element stirring at the very beginning of the list, which we do. We're also able to remove that element from the list if we want to. We can drop down and say our list dot removed and then specify the element that we want to remove. So it's specify first element. And now when we print our list, we shouldn't have the element or list anymore, which we don't. We also could have done this using department that if we wanted to remove a certain index position from our list, we could have used Pop. We'll put parentheses and then we'll specify the index position that we want to remove. So let's remove the last one D, which is in the 0123 4/5 index position. We'll put in a five here and now print our list again. When we execute, we see we no longer have the string of the in the last position of her list. Lastly, Weaken Ness list inside of each other So let's say Nested list is equal to another list. And then we'll pass in a second square bracket, which will be just another list inside of the first list. So this will be the first list. So it's a 123 and then the second list will be 345 All we're saying is that there's one big list with a smaller list. Inside of it will print nested list to see what it looks like. We see that looked exactly like how we talked it in the terminal as well. And that's it for this video. It's important that we remember that a list is a beautiful object and that were also able to keep the order of elements inside of her list. I'll see you in the next video. 8. Strings: everyone. Let's talk about how we can use strings in our Python scripts. Let's get started Over in our Python script, I'm in a file called Strings DuPuy. We've already been using string variables quite a bit, but there's a little bit more that we need to talk about. That's creating the variable called String A. And then, if you remember, we used a D limiter. To specify Stream A D limiter is either a double quote or a single quote. We'll use double quotes here and now. Let's set this equal to a name so we'll just use mine. Derek. It's very easy to create strings and python. However, there's a lot happening behind the scenes. This string and python is actually an array, so we were to drop down and say print. And then we'll use a new function called Ellie in, which just calculates the link of their rape. Well, say link parentheses and then strength. A. Now, when we execute this, we'll see what I'm talking about. We get the return of seven. That's because each letter in my name is actually a single element, and they all combined together to make this string, which has in a very length of seven. So the same way that we were able to index list values, we can actually do that here, too. If we drop down and say print, stringing and then the same way that we index before using square brackets, we can do the same here. So let's pull out the first letter of my name so we'll use a zero now when we execute, we should just be returned to D, which we are. We also have a few different functions that we can apply to strings. How to show a few of these. We can save print stringing, and then we can use the function upper to make my name entirely after case we see this in the terminal. Because every letter in the ray of this string is now capitalized, we also have access to the reverse function of Lower. We're also able to split strings and python. So let's say string be is equal to my name. So Derek, Matt and then let's say Jessica. And now if we wanted to return each name individually, we could drop down and say print, string, be and then use split as a function and then we'll pass in the character that we want to split on. So let's split on the common value will put parentheses and then a comma, say in then execute er file. Now we see that we have three values of strings in a list. We have Derek, Matt and Jessica. So that's pretty much it. We know how to create a string. We know that a string is actually made up of an array of elements instead of just one element. We know that we can calculate the link and how to end excess string. We now know that we have functions that we can apply to the strings and were able to split strings as well. If you have any questions about this, please let me know. I'll see you in the next video. 9. Tuples: everyone. Let's get started talking about two pulls over in a text editor. Let's go out and created two Pulled well, say to people. A is equal to parentheses, cat, dog and mouse. Remember that we specified people using a parentheses and that they're very similar to a list object. The only difference is a tupelo is immutable, so this could be useful If you want to create a list but don't want people to be able to change it, we can create a to pull instead, which is immutable and doesn't allow for that change everywhere. To try to do that here, say to boy upend how we did in our list and passing some type of value so value and say this and executed, we should get an error in a terminal. So to pull stop I, we see that people object has no attribute, upend. That's because it's an immutable object and we can't change it. So let's go ahead and get rid of this line of code or, if you remember, a tipple does keep the order. Therefore, we are able to pull out values from our people using indexing, we can print people a square brackets. And then let's pull out the word dog, which is in the first index position. We'll put in a one, and now when we execute, we should be returned. Just thought people's air one of the more uncommon data types that we haven't. Python. However, we still need to know how to use them. We can sometimes find ourselves using two pools whenever we're working in a coordinate plane. If we have a bunch of X and Y values to pools are probably the way to go. We used to polls from time to time, but really not that often. I'll see you in the next video where we'll talk about sets. 10. Sets and Frozensets: everyone. Let's start talking about sets, sets or just unique element containers. We already saw this briefly, but let's create another one. So let's say set A is equal to curly brackets and then we'll create a set. Let's say 12 and then three. We also know that sets immutable. We can see this missing, say, and then we can add an element to set. We'll put in parentheses. The string for terrorists? A. We'll drop down and say print, set a and see what the return is. Terror terminal Python three then accidentally talked over a previous script of to post op I. But we see that a set is an A northern because we have one for 23 in our return when we put in 123 and four. So it's on a northward. That means we cannot use indexing on a set, and it is mutable. As we were able to add a new element to her previous set, everyone, and to add multiple items to set, we could drop down and say, say and use the function update. Now we put parentheses and we'll put in square brackets to create a list of items and then we'll say five, six and then seven. We'll print, say, and executed their terminal, and we see that we can add one element using ad, and we can add multiple elements using the update function. If we want to get rid of elements from her set, we can use the functions. Discard and remove. Remove dis returns an error. If the item is not in the set, this card will just return none. Both of these were used the same way. So say removed, and then we can put in any element that we want. So let's remove the string six. And now we should no longer have the string six in her output, which we do not now. If we were to try to remove the same element again and it's no longer in the set, we'll see the error that would get returned. So say removed and then we'll remove the same element. Six. We'll just try to do this without printing in them. Will say python 32 pools not by We see that we get the air key. Air six on remove six. If we were to change his second remove function to the discard function, we should no longer get the air. When we execute, we see that just returns it none, and we no longer get in there. Lastly, were able to remove an element from a set using the pop function. We'll drop down and say, Set a dot pop And now this function is kind of dangerous because it's going to remove the last item in the set. However, we know that a set is on ordered, so there's no way of knowing which item will be removed using the pop function. And since I'm such a fan of danger, we're just gonna do it anyways. It's a print, say, and we'll see what happens. We'll execute. And from the terminal we'll see that the string one has been removed. Remember that a set online contains unique values. So if we have multiple elements in a set that are the same value, the several treated like there's only one element of that value. They have frozen, says very similar to set, and we just used the frozen set parentheses and then we can pass in a to we'll create a variable so f set A and what are frozen said. Does his changes are set from immutable toe immutable object. It means that we can no longer do these functions of removed up day ad tar frozen set. So you would use this whenever you wanted to set but didn't want any other values to change . And that's pretty much it for this one. What we need to remember is that a set contains unique on ordered elements. In a frozen said is the immutable version of a set. I'll see you in the next video. 11. Dictionaries: everyone. Let's keep on going and start talking about dictionaries that start off by creating a variable. We'll say our dictionary and we'll set the sequel to curly brackets. How we did before and then Remember that dictionary is full of key value pairs, so the first item and the key value pair is the keep will say key one. How he did before and then value in. We'll put a comma and then we'll actually hit. Enter here and there are first multi non variable. So then we'll say key to colon value to We'll save print our dictionary and then saver file type in Python three. And then the name of this file is dictionaries dot pot. We see that we have a dictionary made up of two key value pairs. Key one is related to value one, and key to is related to Value Tube. Now remember that our keys can be some type of property. So let's say how we did before name and then the value of name for me would be Derek. We could say height and then we can pass in six foot so six foot and now we can also keep on going and create as many key value pairs everyone. So let's say another one and will say location and will give me a location of lost dictionaries air very powerful to us, and we'll use them a lot. The reason why is we can use these keys to pull out information from our addiction here, put square brackets and then we can put name. This should return to us in the terminal of my name, which it does. This makes it very easy for us to pull out properties. Values using a dictionary were also able to change these values. Because the dictionary is mutable. We can do the same thing so well. Actually, just take this line of code here. We'll copy it, paste it here and then let's change the name. So instead of Derrick, let's say that my name is no Michael. Now we'll drop down and say, Print our dictionary were readily able to change the values in our dictionaries using this method. This is a very nice feature that you may use a lot, so we know that we can change values. But let's say that we wanted to add a new value to our dictionary. We could do the same thing that we did before, say our dictionary, and try to index the value. But if we change this value to something that's not already in the dictionary, recreate it in our dictionary. So let's say I color is equal to blue. We'll print our dictionary, and since the key eye color is not already in our dictionary, it should create this key interdiction. Here we'll drop down to execute, and now we see that our dictionary has name, height, location and also I color. If we wanted to get rid of this, we could say our dictionary and then use the pop function that we learned in the sets lecture and pass an eye color. It is cap sensitive. So that's why you saw me back space the capitally and replace it with the lower Casey. Print our dictionary. We should remove the eye color key that we just added in. We see that we have Like I said, dictionary is a very powerful and there are very good tool for us. The takeaways from this video are that dictionaries and write up a key value pairs and that we can pull out values using the keys. I'll see you in the next video 12. If Statements: Hello, everyone. Let's talk about if loops here in a text editor. Let's go ahead and create three variables. Will say X is equal and one wise liquidity in ZZ Quarter three. Now to start an in flute, we need to use the keyword If we'll say if and then we need to pass in some type of logical statement. This could be anything like greater day unless they not equal to you. For now, let's say X is less than why and then the end. An if statement We need to use a colon. Now we'll drop down and notice how were indented over. That's because this block of code follows this logical statement line so everything in this block will only be executed. If this is true, we'll say print X is less than what When we open up a terminal were type impact on three and then the name of my father was, If dupuy and we see that this statement is true because we get this block of code return to us. This is because X is equal to one. And why is it what a two and one is lesson to? If we were to change this to greater than an executed file. Again, we should get no return in the terminal, which is exactly what happens in this situation. We need to create an else statement. If we go down and say else, then this means this line of code will only be executed at this line, returns false or drop down and see. That's indented as well, because it follows this else statement and we'll say print and then we'll pass in victory. We'll execute. And now we should see victory in the terminal because X is greater than why returns false. We already saw that we don't have to include the else statement, but sometimes we will inaction toe happen whenever this statement is false. We also have access to a few different operators those operators air and in, or we'll look at how we can use the and function. Now let's go ahead and change us back to less than we used The key word and why is less than Z will print to the terminal and we'll say something simple like yes, so the and keyword just means that both of these logical statements have to be true to get this action toe happen, we'll go ahead and delete this else statement and that when we execute X is less than why and why is also less than see. So we should be returned this action terminal, which we are now. If you were to changes toe, why is greater than seed and execute again? We should see now returned in the terminal. That's because, like we said, one of these statements is not true. There for the whole line returns false everywhere to changes toe or however, and executed again. We'll get the return because in this scenario, only one of these has to be true to return the whole line as true if loops and very straightforward. And they're very powerful tears. All we need to remember is that we started in flute with the keyword. If we have some type of logic statement, we in the line with Colon and then we have an action underneath. We also have access to an else statement. If we want something to happen if this line returns falls, we'll get planning a practice with the flu. So don't worry. If you don't have it down to ship, I'll see you in the next video 13. While Loops: everyone, let's continue on and start talking about while lose a while. Loop just executes a code. While some condition is true, we need to create that condition in the most common way that people do is they say I is equal to one to start a while, Luke will drop down and use the keyword wall. And now we need to say some logical condition. We already have eyes equal of one. So what we'll do is we'll say I is less than 10 and then we'll inter wildly statement with Colon. Now we need to create some action here. It's important that we don't create an infinite wildly, so we need to somehow make this variable I greater than 10 to enter wild. So for each iteration to this wild, let's say I is equal to I plus one. Now we can do some type of action. So let's say print I. So looking at this while this statement returns true, we want this action to be repeated over and over. Well, saver file. And then we're open up a terminal and say python during four loops dot Pie is the name of my fall return, and we see that we integrate through that action until I is greater than 10 because reprint each time and we see that we just generate 23456 and so on. While loops are very straightforward, if you understand the syntax of Python we started while with the keyword while we have some type of logical operator, and then we have the action of this line indented underneath. We can also mess while loops the same way that we nested. If loops we can drop down and actually use. And if so, if I've is equal, let's say six. That's let's say that we want to break, and that just means that we want to stop any of the looping action. What do this will say and execute? And now, instead of while being less than 10 we can say, if I is equal to six, we break the while loop, which is exactly what we've done here while loops or just one more tool that we can use in her looping process. If you have any questions, please let me know. In the next video, we'll start talking about how we can use four loops and our problem scripts. I'll see that 14. For Loops: Let's talk about the last of her it aeration techniques and talk about four looping here in a text editor. Let's go out and create a string. We'll set a variable of name equal to my name again. So Derek, now to create a for loop, we start with the keyword fourth. And now what we need to specify is what we want. Each individual element inside the larger grouping to be called. So let's say for element in name if you remember, a string is not just one string by actually an array of string values. So here we have one string value here, one string value here and some work Here we have seven string values. When we say four element in name were saying each element. So each string value each letter in the variable name we can print each element, which is just what we're calling each letter in this name. So print element, we'll save and execute Python three and then this one is for loop Stop I And now we see that for each letter in my name reprint to the terminal. We can use four loops in a lot of different ways, so Let's say that we have a list A and this is composed of a grouping of names. So Derek, Michael and then Jennifer we'll drop down and let's say four Name and list a colon will print name now, since the elements are actually list items instead of the individual string, characters will return each name to the adoration. So we'll go down and print these since the values making up a list are actually the groupings of the strings rather than the individual letters making up, the strings were returned each complete string through the adoration. If we were to put in numbers entire list, we could expect the same league. So we'll say. And now, when we iterated were returned, all the string groupings and the numbers four loops are a great way to pull out values, but they're also a great way to do operations. So let's create a new list will say, Let's be, and then this will be a list of numbers. 123454 Number and list B. Well, say print number plus five. This is saying that we want to add five toe every number in the list beat. We'll execute, and we see that our list of one thing five now becomes a list of 60 10. Lastly, afford leave doesn't necessarily have to use this key word here. Instead, we could just say Print five. This will return five to us for each element in the list. So since we have five elements in the list will be returned. The number five Terror terminal. Five times we can execute, and we see that we have the number 55 times in the terminal, four loops of one of the most common integration practices that will use. And we'll get plenty of practice in the upcoming videos. If you have any questions, please let me know. I'll see you in the next video. 15. Python Functions video for courses: Hey, everyone, welcome to another video. So you made it through all the tough parts of python. You understand the basic building blocks. So let's start thinking about how we can combine those bone walks together and create functions. Let's get started here in a text editor. We can declare function by using D E f. Now we use the name of the function that we want. So let's say that we're creating a function that adds 2.6 to any value. Having pass it, we'll say add to six and then put parentheses after it. Now we need to pass on the parameters that we want this function toe have, since we just want to take in a number, that means we can just assign any variable that we won't hear. Let's say X now in the function with colon underneath it, we need to make the action of the function. So we want to add 2.6 to any number pastor function. We'll say result. So we're creating a new variable is equal to X plus 2.6. Now we want to print results, So this seems like a very basic example. But we can do a lot with functions here. There's a few important things that we need to talk about. A function always starts lower case, and if all is the same, naming convention as a variable. So it starts lower case in each of the words are separated by an underscored and ideally, a function should only do one thing. So here we're only adding 2.6, which is fine. But if you need to do several different operations, you should create different functions for each of them will drop down now, and we have this function created. So now we can just create available will say amount is equal terror function at 26 and then we'll pass in a parameter, which will be treated his ex. So let's pass in an entered your value of seven will savor file. We'll drop down and type python three, and then the name of the foul is function Sopot. We can see that were returned 9.6. This may not seem like a lot, but creating a function can actually be very useful to us here. We just use one line of code when before we would need to. We even need to add 2.6 and then print the result. Instead, we created a function to do both of those for us. The more complex your operation is that more useful, it is to create a function. So instead of just adding 2.6, that's saying we needed to add 2.6 and then divided by 5.5. And now we start to see just how power for a python function is. We see that we can start creating pattern functions that automate processes that we do repeatedly. And the next video. We'll talk about how we can take this even farther and start creating class objects. I'll see you then. 16. Class Objects Course Video: Hello, everyone. Let's dive into the true object or, in a program nature, a python. We'll look at how we can create our first class. Let's get started. So this video might get pretty technical pretty quick, but I'll try to keep it very simple here and then put all the technical stuff in a different video later on to create a class. It's very similar to a function will call in class and set of DF. And for a class, it's common to capitalize the first letter. So let's say that our class is going to be report. We'll put a colon and then we'll drop down. Not very. Simply put, a class is just an object that we can use to create. Other objects made up of functions and attributes will create this class object here that will use to create other objects that will have to initialize using an instance. I'll talk to all of that right now because I know it sounds complicated. The first thing we need to do is to create the initializing function well, say DF two underscores, which just means that this is a private function, initialize to underscores parentheses and now the first argument and your initialized function always has to be self. Now. That said a few attributes to our report class, let's say that the report needs a title so titled and it needs an author. We'll put a colon and then for us to assign these, we need to say self and then that tribute. So that tribute here is title and author. So self doubt title is equal to title, and then we'll do the same thing. Self. The author is equal to author. So what we've done so far is that whenever someone uses this class object to create their own object when it initialize is, we're setting these attributes. So now let's drop down and create a method which is just the function inside of a class will say D f and then write a report parentheses, and this will take in itself. And then it will also take in text. We'll put a colon and drop down, and now we want this to return to the terminal. Whenever someone uses it so well, type in return parentheses. Then we'll put Carly brackets that will use for the title. We'll say bye and then more curly brackets that will use the format with the author will say, a new line, which we can do with the backslash. And then an end will put curly brackets, which will be the text here. And then we'll use dot format, which is just a function that we can use to format these blanks. And then we'll pass them what we want to fill in those blanks in these parentheses so well myself. That title, which is just dis attribute right here, self the author, and then we'll put in text, which is just the function that we use your here. We'll save this and drop down what decrease or end it all the way over. That way, we're out of the class. And now let's use this class. Let's say that on the one writing the report, my report. And then we'll initialize the class by typing the class name so report. And now we need to pass in the attributes of a report here, but I don't need to be the 1st 1 so let's say the title is I should of studied art and then we'll pass in the second parameter, which is the author which is me. Several type in Derek. So what this one is doing is creating a new object from the class object of report by initializing a new instance now that we have this initialized were able to use all the methods and all the attributes within the class. So we'll drop down on one side print and then it's initialized here. My report. So we'll say my report dot right report as a function which is just this method right here inside of her class object. And then we need to pass in the parameters of that function, which is just a text variable that we define here. So let's say this is object oriented programming will say the file. We'll open up a command proper terminal and type in python during in the name of my fathers class, that pie, and we see that we successfully used a method inside of a class object that we initialized here and then use the method of that class object here. The more practice that we give with class objects, the better we'll get. I hope this was a good baseline on how we can start using class objects in our Patton scripts. I'll see you in the next video