More power to Data Analysis through Python
If you already work with data in Excel, and want to add more power to your data analysis and evaluation using Python, then this is the course for you. Frank is a data scientist, and he will teach you how to use Python to work with data. Hi, everyone, my name is Frank and draw that. And this is my Python course for Excel users. I created this course to help Excel users move from Excel to Python. That why Python? Well, in Python, we can do most of the things we will do in Excel, such as working with data, making charts, and pivot tables. But that's not all. We can use all the power of Python to automate tasks, work with large data, and do lots of things. Thanks to the 1000s of Free Libraries Python has on top of that, Python can help you become a better data analyst or get into new fields like data science, I divided this Python course for Excel users in three modules. In module one, I'll teach you all the Python core concepts you need to know for data analysis. Then in module two, we'll learn pandas, pandas is a Python data analysis library that will help us do most of the things, we can do an excel in module three, we'll put into practice what we learned in this course, by creating a pivot table and visualizations such as line plots, bar plots, and pie charts. Remember that in the description, you will find the files code, as well as a free PDF Python cheat sheet I created for this course. There, you will find the concepts, methods and functions we will see in this course. By the way, I'm Frank, and I will be your instructor in this course. So let's get started. To download Anaconda, we go to anaconda.com and click on get started. Then we choose their last option download Anaconda is Tollers. And then we have here that different Anaconda is taught. So there are Windows, Mac, and Linux. So in my case, I'm going to choose Mac, and I'm gonna choose the 64 bit graphical installer. So now I'm downloaded Anaconda.
And once it's downloaded, I'm gonna click on it, and a message will pop up. Do you just have to click on Allow us I'm going to do right now. So just click on Allow and then click on continue until the installation starts. So I just click Continue and then agree and then continue. And it's going to start installing Anaconda. In case you're on Windows and you're installing Python or Anaconda for the first time, make sure to check the first box you see now on screen. So I'm going to speed up the video now. Okay, the installation is almost done. And now it's telling me that Anaconda works with pi term. And now I'm just going to click on Continue to finish that installation. So I click Continue. And then we'll see just a summary of what was installed. And now I'm going to close this window and I'm going to open Anaconda. So I'm going to locate that icon, it's green icon, this one that you see here. And I'm going to open Anaconda. I'm going to wait a couple of seconds. And let's see what was installed. So here we have that you put your lab and Jupyter notebook, which are widely used in data science. So I'm going to launch Jupyter Notebook. So here it's opening Jupyter Notebook. Let's give it a second. And now we open a new notebook with python three. So python three was installed to and that's it. In the following videos, we'll learn how to use Jupyter Notebook. In this video, I will introduce you to the Jupyter notebook interface. Jupyter Notebook is an open source web application that allows us to create and share documents that contain live code equations, visualizations, and text. This is a perfect text editor for doing data cleaning and transformation. That visualization and data analysis this is why Jupyter Notebook is widely used in data science and also machine learning. As you might remember, we installed Jupyter notebook in Python with the Anaconda navigator in this means that we already have installed some popular libraries used in Python for data analysis.
By the way, one of the terms of Jupyter Notebook is Jupiter lab. Both are similar, but we're going to use Jupyter notebook in this course, because of its simplicity. So let's open Jupyter Notebook. And to do that, we have to click here on the launch button. So I click here. Now we wait a couple of seconds Now we have here the interface of Jupyter Notebook. So I'm gonna maximize this. And by default Jupyter Notebook opens the root directory of your computer, it's a good idea to create a folder where all your Python scripts will be located. In my case, this folder is called Anaconda scripts. So I click here. And now I can navigate through the folders. And the folder I'm going to use for this example is this one that says my course here, we're going to create our first python script. To do that, we click here on the New button. So click here, and we have to click on the first option that says, python three, there are other options like text file folder, or the terminal, but we're not going to use these options in this course. So click on python three. And now we have a Python script powered by Jupyter Notebook. So here on the right, you can see that it says python three, and also there is the Python logo. And on the left, you can see here the Jupyter Notebook logo, and also the name of this Jupyter Notebook file, we can change the name of the file by clicking here on on title. So I click here, and I can change it to, let's say, example. So I write example, in I click on Rename, and now we rename these up or not file. Alright, now let's navigate through this menu bar that we have here in this Jupyter Notebook file. So the first option is the file. In here, we can create a new notebook with python three. So if we click here, we're going to open a new Jupyter Notebook file from scratch as we did before, then we have the open and in this case, we can open a Jupyter Notebook we created before we can also make a copy to Jupyter Notebook and then change the name, we can save a Jupyter Notebook file and rename the file as we did before, we only click here and rename the file, then we can save all the progress we make in Jupyter Notebook.
For example, after writing many lines of code, you can save all the progress you make by pressing Ctrl S or Command S on Mac, and you're going to create a checkpoint. And later you can revert to a previous checkpoint by using this option here. So here you will see many checkpoints and you can revert to a previous checkpoint. By the way, by default Jupyter Notebook makes saves every third seconds or maybe one minute. So there is no need to press Ctrl S every time. So keep that in mind. Then we have other options that I don't use so much like print this Jupyter notebook or export that Jupyter Notebook file to HTML or PDF and so on. Okay, now let's see the second option that says Edit. And here we can edit all the cells we have here in this Jupyter Notebook. By the way, here, what you see here on the screen is a cell. So we can edit with this edit option. For example, we can cat cells, we can copy cells paste cells above and delete cells. On the right, you can see the shortcuts that we're going to see on the next video in detail. And well, you can check all the edit options that you can perform on Jupyter notebook here, then in the V option, we can toggle the header, the toolbar and also line numbers. So here, if I click on toggle header, the header is going to disappear. And if I click on toggle toolbar, this toolbar disappears to also here and toggle line numbers we can show here line numbers. So if I write anything, we can see that it says 123 and so on. And I'm not going to use this for this course, I'm going to leave it with the default options. So here I'm going to revert to the original options. So without line numbers, and I want to show the header and also the toolbar, but you can personalize it as you want.
Next in the insert options, we can insert cells above or below, we only click here. And well we're going to see the shortcuts later in the next video. Then we have the cell options, we can run cells or run all the cells in this Jupyter Notebook file. And then we have the kernel option. And a kernel is a computational engine that executes the code contained in a notebook document. When we open Jupyter Notebook. A kernel is automatically launched. And we can interrupt this kernel by clicking here. So by interrupting we can pause the execution of our code we can also restart everything and do more things here. Sometimes, for example, I interrupt the kernel when I line of code or a cell takes too much time to execute. And well you can do the same here with restart or interrupt. Then we have the Navigate option that doesn't actually have anything here, widgets that I don't use so much and will help that, I think it will send you to that documentation of Jupyter Notebook. And you can read it if you want. All right here. Then we have the toolbar, and here you will find some shortcuts of the menu bar that we've seen before. For example, here, you can save and make checkpoint. So here I click here. And as you can see, here, it says checkpoint graded, or something like that, yeah, checkpoint created and the time that he was created, then you can here with this plus button, insert, cell below sway click here, and as you can see, we can insert a cell below. And also you can use shortcuts, but that I'm going to show you in the next video, then we can cap selected cells with this button, we can copy a cell with this bottom. And also we can pace sales below. Also, we can move a cell above or below, for example, I'm going to write anything here in this cell, I can move it evolve with this button or below, as you can see here, then we can run this code, for example, I can write the number one, and then run the code.
And as you can see here, the code ran and it shows the number one and well, those are some of the frequently used buttons in the toolbar. And that's everything you need to know about this Jupyter Notebook file. Okay, now, before finishing this video, I'm going to show you some other options that you can find here in the user notebook interface. In here, you can see that there are some other options. So right now we are in the Files tab. And we can change to the running tab here. And here you can see all the currently running Jupyter Notebook processes. For example, we can see here that Jupyter Notebook file we created and that we opened. So you can recognize that you put your notebook file is open, or that is running, because here the icon will be in green. So here if we go back to the Files tab, we can see that this Jupyter Notebook file, which by the way has the IP y and b extension is in green, so the icon is in green. So this indicates that the file is running in well, it was opened. So here we can see that is open, and we can shut down this file. And this is different from closing this file. For example, here I have the file. And if I close this file, here, we can see that file is still running. Here we see running is in green, and in the running tab, it still shows up. So if we want to shut down this file, we click here. And it says that there are not not books running. And we can see here that the notebook has a great icon. Alright, then we have the clusters tab and this tab I don't use so much. And actually, it doesn't show anything here. And then we have the NB Extensions tab. Here, you can install any extension to personalize Jupyter Notebook even more, and we're going to see some cool Jupyter Notebook extensions in the next videos. And by the way, this NBA Extensions tab doesn't show up in some versions of Jupyter Notebook, but we can easily install it and we'll also see how to install these ennemi extension step in the next videos.
Finally, we have this box that shows our directory. So here this folder indicates that root directory. So if I click here, we are not in the root. And if I click on the folders, Anaconda script and then my course I go to the folder where I was before. And that's it. These are all the things you need to know about the Jupyter notebook interface. Okay, in this video, we're gonna see some cell types and cell modes in Jupyter Notebook. So first, we're going to open that Jupiter notebook file that we created in the previous video, which is this one example that I p y and b. So we click on it. And here we have the Jupyter Notebook file opened. In here by default, we have these four sold in command mode. And we can say that this is command mode because here this blue color indicates that the cell is in command mode. And when we are in command mode, we can do things outside the scope of any individual cell. So basically all the tools we see here in the toolbar, we can apply it in command mode. Also in command mode, we can apply some shortcuts that I'm going to show you later. And for example, if we want to see the shortcut window, we press the letter H in command mode, and we can see the keyboard shortcuts here. So here You can see all the shortcuts in all the shortcuts that you can apply in commandment. Now I'm going to close this one. And also you can apply different shortcuts like for example, if you press B in the command mode, you will see that there is a new cell because B is the shortcut that introduces a new cell below. Now, if we press enter, you're going to see that the color is going to change to green. So here we have green color. And this green color indicates that we are in Edit mode. And the edit mode is for all the actions you will usually perform in the context of the cell.
For example, introducing text or writing code. So here I can write, say 123. So if I write 123, and then I click on this run button, I'm going to run this cell. And as you can see here, I run this first cell. And also after running the cell, you can see that we are again in command mode. So to go to Edit Mode, we press Enter again, and now we can edit the numbers we introduced. So for example, I can write 456, and then run again. And here you can see that the output shows 12345, and six. By the way, if you try to use the shortcut in edit mode, it won't work here, press enter. And now I'm on edit mode. And if I press the nether H, you can see that nothing happens, we don't have the shortcut window. And if I press the letter B, you can see that we don't insert any cell below. This happens because those shortcuts work only on command mode. So to escape this edit mode, we have to press the Escape button. So press escape. And now I'm again in command mode. So if I press H, we have here that keyboard shortcut. And if I press B, you can see that we inserted a new cell. And that's it for the command in the edit mode. Now we'll see the cell types in Jupyter notebook in Jupyter Notebook. There are three main cell types. And we can see all of them in this drop down here. Right now the type of this cell is code. So here it says code. But if we press here, you can see other cell types like Markdown and row and B convert. So we're gonna see first a code cell, and it already has the check. So this one is a code cell. So now I press here, and now well, it's in code cell. If I press Enter, I'm in edit mode. And here I can introduce any code I want. So here I can write any number 99. If I press Control, Enter, we can see that here, this is the input in here we got the output of this code, we're going to see how the code cell works throughout this course. But now it's time to see how that markdown cell works in Jupyter Notebook.
So here, I'm going to the cell. Now I'm going to change the cell type. So I press here in the drop down. And now I select markdown in the markdown cell, we can introduce any type of text we want. For example, we can introduce titles. So if I delete this and press the hash sign, we can get title. So one hash, it means title. So here I press a space in now I write title. Now I press Ctrl, enter or this run button to run the cell. In here, we got the title. By the way, you shouldn't get this one number because I use modify the default behavior of Jupyter Notebook. So mine enumerates the titles and subtitles, but in your case, you will see only the word title. And if you want, you can introduce also subtitles here. So for example, I'm going to insert a new cell with this button is plus button. And now I'm going to move this cell up with this button here. So I press this in now I'm going to change the cell type from code cell to markdown cell. So I go to the drop down and select markdown. And by the way, you can change the cell type also with shortcuts. So if you're in command mode, you can press the Y button to change the code cell. So I press the Y button. And as you can see here, it says in and this in with square brackets indicates that this is a code cell. So here I can press enter and introduce any code here I introduce numbers and press the Run button. And here you can see that we have an input and an output. So this is a code cell. But now we can press the M button to make this cell a markdown cell. So now we press M and here we are in command mode. So now we can get this markdown cell in here. You don't see that in Word with the square brackets anymore. So now I'm going to edit mode so I just press here or Well, you can press enter to Go to Edit mode. In order to introduce a subtitle, I'm gonna write double hash sign. So I press hash sign twice.
Now let's paste in. Now I'm going to write a subtitle. So I write subtitle, I press Ctrl, Enter, or the run button to run the cell. And we've got here a subtitle. And we can also introduce text, I'm going to introduce a new cell with a plus button. And you can also do it without beat shortcuts. I'm going to do it with a B shortcut, right now, I press B. And here I got this new cell. And we can move this with this button here. And now we have this cell in the position we want it. So here, I can introduce text by converting the cell to markdown. So here, I choose markdown. Now you press Enter to go to Edit Mode. And here I can introduce any text. For example, I can write hello, I press Control, Enter. And now we can see that we have here this text. And finally, the last type of cell is that row and B convert. And this type of cell is not ever loaded by the notebook kernel. So if we convert this code cell to a row cell, this cell won't be emulated by the notebook kernel. So let's try here, I press row, and be converted. Now we can see that this looks like a plain cell. And well this type of cell is not used that often, actually, we're going to use only that code cell and a markdown cell in this course. And that's it. In this video, you'll learn the cell types and cell modes in Jupyter Notebook. Okay, in this video, we're going to see some common shortcuts used in Jupyter Notebook. And we're going to start with the F shortcut. And by the way, to use this shortcut, you have to make sure you're in the command mode and to verify during the command mode, make sure that the cell has this blue color. Okay, now during the command mode, you can press the letter F, and you're going to see these Find and Replace. So this first shortcut allows us to find our word in a cell and then replace it with another word. For example, I can write here the word hello. And here, it found the word hello, inside this hello, world sentence.
And now I can replace this word with the world. Say hi, for example. So here, I write Hi, in red, we can see the match. And in green, we can see the word that we're going to insert. So here, let's click on Replace all. And now you can see that it doesn't say hello world anymore. But now it says Hi, world. So now I press Ctrl Enter, which is another shortcut to run the cell. So you can press here and run or only press Ctrl Enter to run this cell. So press Control Enter. And now we ran this cell in another way to run cells is to press shift, enter. But in this case, we're going to run an insert a new cell below. So now let's see I press Shift Enter a note here, it ran the cell because now test in n three inside square brackets. In here, we can see that we have a new cell. Okay, now another shortcut that is often used is the y and m shortcut. So now this cell is a code cell. And if we want to make this a markdown cell, we only have to press the M letter, so we press M and this is going to be converted to a markdown cell. And if we press the letter y, this is going to be converted to a Kotel and also you can change the heading here, you can make the heading bigger or smaller. So here, I'm going to locate the cell A now to make this one smaller, we can press the numbers. So if we press the number two, we can see that this one gets smaller. And if I press number three, the title gets smaller for smaller and so on. So as you can see the more hash signs, the smaller the text. So here I'm going to delete this hash signs. And one hash sign represents the biggest phone size, which is the title. So now we press Ctrl, enter, and now we have this in heading one. But if I press number five, and then press Control Enter, we can see that now this cell has had in five and it's smaller. So now I'm going to revert to heading one. So you press one, and then Ctrl, enter. Okay, now we can navigate through the cells by pressing on the up or down keys on our keyboard.
And as you can see here, we can navigate through all the cells here or we can also press with the mouse, we can press on the cells we want. Okay, now we can insert a new cell above by pressing the A key so if I press a we get here a new cell above and if I press enter b, we get a new cell below. Now if I press x, we're going to Cat the cell. So I press X, and you can see that the cell was Cat A. Now if we press V, we paste that cell below. So I press V, now we got the cell. And if I press Shift plus V, we get the cell pasted above. So I press shift in V, and we get this new cell above this cell I have here, okay, now I can delete cells by pressing D twice. So impressed the two times. And as you can see here, that title disappeared. So now it tried again, and we don't have the title anymore. But now if we press the letter Z, we can Undo those changes. So let's undo what we did before. I press Z, and we get here, the title back. Okay, another useful shortcut is ctrl S, that allows us to save the changes we made in this Jupyter Notebook file. So I press Ctrl S, and you can see here that says, checkpoint created. So I'm going to press again Ctrl S, and here it says checkpoint created in here also says the time and it says these are some of the most common shortcuts used in Jupyter Notebook. But you can see other shortcuts by pressing the letter H. So press H. And here you can see more keyboard shortcuts. Or you can also go here to help and then go to keyboard shortcuts here, and you get the same window. So here you can see a list of shortcuts for command mode. And also for the edit mode, you can see the description of a shortcut, and also how to do it in your operating system. One of the typical ways to get started with a programming language like Python, is printing a simple message, you can write any message you want. But it's traditional among coders to start with a Hello World.
So let's try it. Let's print our first message using the print function. The print function prints a message to the screen. So I'm going to write here, print. And then I'm going to open parenthesis, every time we use a function. In Python, we have to open parenthesis, well, in this case for the print function. And as you can see, here, the functions get green color in Jupyter Notebook. So that's how you can identify them. So inside these parentheses, I'm going to write the message. So in this case, it's going to be Hello, world. So this is our first message. Now, to execute this first line of code, we have to press Ctrl N, Enter, or command and enter if you're on Mac. So I'm going to press this. And as you can see, here, we have our first hello world. Another way to run this first cell is pressing here on the run button is going to have that same effect. So I pressed and it rang. So as you can see here, it says in which represents a code cell. And this is a markdown cell, as we've seen before, one of the advantages that Jupyter notebook has is that it allows us to print the last object in a code cell without specifying the print function. So for example, here, I can print this Hello World with without writing this print function. So I'm going to copy this Hello World message that it's inside quotes. And I'm gonna run this code. So just Ctrl, Enter. And as you can see, here, we have this message printed. So this is one of the advantages that has up or not, if you do this in another Python ID, it will work. So here you can try yourself, you can write any message you want. Apart from the first hello world, you can try with your name. So we write prayer and then parentheses, and we open quotes, because we need to define a string. I'm going to tell you about strings a little bit later. But yes, so you know right now. And here, for example, I can write my name. So my name is Frank, and I can print my name, then I can print also numbers.
So I print my age 26. And it's gonna work too. And besides writing code, you can also add comments, comments are a useful way to describe what we're doing in our code. So here, we can use comments. We just have to write their hash sign, which is this one. So you write hash sign in, then you write the comment. In this case, I'm gonna write my name. And I'm going to say printing my name so we know what our code is doing here in the front. message we wrote, We can also add a comment. So we write hash sign. And then we can say printing my first message. As you can see here, the comments also have a different colors. So, so far, we have three colors, this color for their comments, green color, for God functions in red color for the string, this is just a useful functionality most texts a to have, that allows us to easily read code. Okay, now let's see some data types in Python. Every volume in Python is an object, an object has different data types. Let's see the most common data types in Python. So one of the most common is that the types in Python are integer and floats. Both are numbers. But integers are numbers that can be written without our fractional component, just like, for example, the number one, number 2345, and so on. So all of them are integers. And we can check these value or this data type by using the type function. So this is our second function we're going to see so we write type, and then parentheses, and we execute, we run this code. And as you can see here, in the output, it says, I n t, which represents integer, so this is an integer. Okay, the second type of data I want to show you is float. Floats are numbers that contain floating decimal points. So basically 2.3, let's say 1.25 5.4, and so on. So here, we have another type of data. And let's check out if these are actually floats. So we use type, and then parentheses, and we run this code.
And we say that we have float. And just like on Excel, you can perform math operations in Python using these numbers. So some operations, you can use our addition, for example, you can say one plus two, and then execute this code, and you get three, you can use subtraction, so four minus one execute, and you run this code and you get three. You can also do multiplication, division, exponents in more in Python. But now let's see the third data type that we will see often on Python, and it's the Boolean, Boolean are true or false values. And we can check this using again, that type function, and we write type. And within parentheses, we write for example, true. And we run this code and we see that we got that bool, which represent a boolean data type. So we can also write type, and in this case, false, and run this code, and we get bool. Again, so this is Boolean. And we're going to use Boolean, often when we use conditionals. Okay, now the fourth data type I want to show you and it's very common is the string. A string represents a series of characters. And in Python, anything inside quotes, either single quotes or double quotes, is a string. So let's see them actually, we already see one kind of string here when we printed this Hello, world. And you're actually familiar with this, but we're going to see it again. So to create a string, we have to open either single or double quotes. So in this case, I'm going to use double quotes. So you see it now. And now I'm going to write any message. So I'm going to write, for example, again, hello world. And again, to verify the type, we can use that type function, parentheses, run this code, and we get the STR that represents a string. And one cool thing a string has is methods, we can apply different functions to strings, as we will do in Microsoft Excel, for example. However, in Python, we use methods a method is a function that belongs to an object.
To call a method, we use the dot sign after the object. Let's see some string methods to change the case of text. So here, I'm gonna write again, hello world. But now I'm going to use some string methods. So write hello world. In this case, I'm going to use the upper method to make this uppercase, so I'm going to use the print function. But actually, we don't need to use the print function because as I told you before, and Jupyter Notebook, we don't need to use the print, because it automatically prints the last line of code. So since this is the only line of code in this cell block, it's going to print it automatically. So we just run this cell. And we have hello world in upper case. So as you might expect, now, we can also change the case of the text. In this case, it can be on lower case, or title case. So I'm gonna just copy and paste this twice. In here, I'm going to write instead of upper, I'm going to use flour, and then title. So you can see how it's going to change the case. So here, I'm going to run, and let's see what happens. So as you can see, here, it only printed the last one, because I told you before, it only prints the last one. And if we want to print the three of them, we have two options. So we can maybe here cut and paste on each cell. Or what we can do is to print each of them. So here, for example, I can do print here, and I can do the same for them. So instead of using more cells, we can print all of them. And here, we can print this one too. Actually, we don't need them, we don't need it, because it's going to print the last line. But just for the sake of this video, I'm going to print the three of them. So here, I'm gonna run this code. And as you can see here, the first it has an uppercase, the second has lowercase. And the third has a title case. So that's how you do it on Python, other string method that you can find Python is the count method.
So I'm going to delete this, and actually this one too. And we're going to see this now. So first, I copy this. And now I paste it here. And here, I'm going to use the count. So the count method, so I write count. And then here I open single quotes, and I write the letter that we want to count. So here, for example, I'm going to write that l letter. And what this string method is going to do is going to count how many times these l letter is included in this string. So as we can see, there are two L's, so it should set two times. So I run these code, and actually is three because there are two in kilo and one in world. So I was wrong. And here, another string method that you can use is the replace method. So we can replace one letter for another. So here, let me copy this, and I'm going to paste it here. And instead of writing count, I can write replaced. So here, the first letter that we're going to see here is the letter that we want to replace. So in this case, I'm going to change the L with O. And the second letter is the letter that you want to put in that string. So I'm going to use the U. So I'm going to change every time that an O appears here in the string, we're going to replace it for you vowel. So let's try it. So I run this code. And now it says, Well, hello world, but with you. And these are some of the most common string methods in Python. Okay, now it's time to learn something that you're gonna see often in Python, which are variables, variables help us store data values. In Python, we often work with data. So variables are useful to manage this data properly. A variable contains a value, which is the information associated with a variable to assign a value to a variable, we use that equal sign. So let's create a message that says, I'm learning Python, and stored in a variable called message underscore one. So here, I write message underscore one. And we set it to that is string.
I'm learning Python. So are you open double quotes in here I Right, I'm learning Python. So this is string. We've seen this before. And this is the variable, and we assign this value to the variable using the equal sign. Now I'm going to run this. And as you can see, nothing happens. But actually, we just assigned that string to the variable message underscore one. Now, if we want to obtain the message, I'm learning Python, we only have to type the variable name, and then execute that code. So I'm gonna copy and paste it here. And then we run this code. And as you can see, by running this cell, we obtain the content inside the variable message underscore one, we can create as many variables as we want, just make sure to sign different names to new variables. So let's create a new message that says, It's fine and stored in a variable called message underscore two. So first, I write message. So Ms search and underscore two, and then we set this equal to open double quotes, and right, and it's fun. This is my second variable, and I'm gonna run this cell. So as we can see, the string was assigned to the second variable. And if I copy and paste this variable here and run this code, we can see that the message it's there. By the way, if you're using single quotes, instead of double quotes, or some using in this video, probably you have the following issue. So here, I'm going to copy this one and paste it here so you can see what I'm talking about. So let's say you're let's say you're using single quotes, instead of double quotes. So you get this, this is a problem that you will have when using single quotes. Because in the English language, we use this apostrophes often. So a simple way to deal with this is using double quotes. So as you can see here, if I use double quotes, everything is okay. Everything remains as a string. But with single quotes, it doesn't happen. So only the i gets this string by dress, it doesn't get a string value, or the string datatype.
So just make sure you use double quotes every time you have these apostrophes, and that's it. Okay, now, let's put these two messages together. So message one with message two, I want to put them together. So this is called a string concatenation. If we want to put message one, in message two, together, we can use the plus operator. And we can just do this. So I'm going to copy message one, or the variable message one. And now I'm going to copy the variable message underscore two. And I use the plus in the middle to concatenate this first message with this second message. So run it, let's see what happens. So here, we can see that the two messages were concatenated. But here, there isn't a space between these two messages. So this is the first message and this is the second and there isn't any blank space in the middle. So what we can do here is to just add a blank space. So I'm going to copy this one and paste it here and show you how to do it. So here I add a new plus operator in the middle, we open A string. So with single quotes, or double quotes, in this case, I'm going to use single quotes here, integrate this blank space, I'm going to press a space. And here we have our blank space here. And then we run this code. And now let's see. And here as we can see, there's a space between Python and that. And we have this blank space. And we want we can assign this new message to a new variable. So I'm gonna assign this to a variable called message. And I write message here. And I include here below the code in here, I can print this so as you can see, if I run this, we can see that the message is there. Okay, now let me show you an alternative way to join two strings. So this is called the F string, and it works like this. You write F and you open A string, so we write a single quotes here. So one and two in here. As you can see the whole, the whole thing is red.
So it's like everything is a string in here inside, we can write the message. So let's see, let's say we write a simple Hello World. So hello, world. And we run this. And as you can see here, this is a string, it just has this F, in front of that string. In here, one of the advantages that this f string has is that it can have variables inside the string. So here, for example, we can write a variable opening these curly braces. So these collaborations can have variables inside it. So here, I can write message, underscore one, and we can print it. So if we print, we have this string, I'm learning Python a now if we want to concatenate this first message with our second message, we just have to include curly braces, again, I put it here. And now I write message two. And between message one in message two, I just have to press pace. And we have this. So I'm learning Python, and it's fun. So here, we just press is pace. And this pace also appears here. So for example, if we add some random text, let's say ABC, we get this ABC, between Python in between. So this is how f string works, do you just have to write the F, then open single quotes, and inside you can write any message. And to include any variable, just you have to open these curly braces, write the variable name, and that's how to join strings. Okay, now it's time to see a data type that is used. Often in data analysis, I'm talking about this. In Python lists are used to store multiple items in a single variable list are order and mutable containers. In Python, we call mutable, two objects that can change their values, that is, elements within LA's can change their values to great Alice, we have to introduce that element inside the square brackets separated by commas. So let's create our first list. First, we have to set the name of the list. In this case, I'm going to name it countries. And now to create the list, we have to open square brackets SAS said before.
So here, we open square brackets. And here we have to write the elements. So I'm gonna include in these countries list just strings, and they're going to be names of countries. So the first one, I'm going to write the United States. So this is the first element in my list. And to write the second, we have to use the comment. So here, comma, and now the second. So let's write India, tomorrow. So now China, and finally Brazil. So these are the four countries, as you can see here, these are lists. So we have the square brackets that represent the list. And we have four strings. And this is how we define or how you create a list. So now I'm going to run this one. And to see the content, I'm going to paste the name of this list in now I run here, I include only strings. But keep in mind that lists can have elements of different types. So for example, one string and the other and integer, and then a float, and so on. And also lists can have duplicated elements. So for example, I can have here, United States, written twice. So here, for example, I can write United States, twice m, that's okay, because this can have duplicate elements, but I don't want it that way. So I'm gonna delete it and leave it as it is. Okay. Now, if we want to get an element inside this list, we have to use something called indexing. By indexing, we can obtain an element by its position. So each item in a list has an index, which is the position in the list. Python uses zero based indexing, that is the first element so United States has an index zero, the second So India has an index one, and so on. To access an element by its index, we need to use the square brackets again. So let's see some examples. Let's start by getting the first element. So United States. So what we have to do is to write the name of the list, in this case countries, and then open square brackets, in inside square brackets, we have to write the position of this element.
So it starts with zero, so we write zero to get that first element. And then we run this code. And as you can see, we get the first element. So if we write here, countries square brackets, one, we get India. And if we write countries square brackets to we get China, and we do this, with the number three, we get Brazil. So to verify this, I'm gonna print each of them. So let's see what happens. So here print. And finally print this one. In now I'm going to run and we shall get each element of the list from the United States to Brazil. So let's try out. So here we have each of them, United States, the first one, then India, then China, and then Brazil. So it's correct. So this is the most common way to use indexing, but there is also negative index, this helps us get elements is starting on the last position of the list. So instead of using indexes from zero and above, we'll use indexes from minus one and below. So let's get the last element of the list. But now using a negative index, so we want to get the last element which is Brazil. And we did it before with countries square brackets three. But now we're going to do it with negative indexing. So here, I'm going to write countries and copy and paste it here. And now I open square brackets. And instead of writing three, we're going to write minus one. And these minus one represents the first element is Talend. From the last position to Brazil will be minus one, China is minus two, India minus three United States minus four. And that's how it works. So I'm going to run this one countries, square brackets, minus one, and we will get Brazil and we got it. So let's do this one more time. And in this case, I want to get United States, which is minus 123, and four, so it's countries minus four. So we run this and we got United States, but now using a negative index. Okay, now let's see something called as slicing is slicing means accessing parts of the list, as lies is a subset of list elements is slice notation takes the form of a list.
So the list name, and then a square brackets and this tart, then this colon and stop this is Todd represents the index of the first element in his top represents that element to stop at without including it in the slides. So let's see some examples. So I'm going to use this country's list again, and use I'm going to copy this one, and I'm going to paste it here. So this is the name of my list. And now I open square brackets. And we're going to get, let's say, we're going to talk at position number zero, and then column and let's get from zero to position number two, so we have to write three, because it stops at three without including these elements in the position number three. So let's run this one. And as you can see, here, we have index zero, index one and index two. So it didn't include index number three, you know, let's say we want just the first element, so we write from zero to one. So it's only zero and one no, because it doesn't include one, and it's topped at one. So here I run, and we got only United States. So now let's try something different. Let's say we want to get elements from index one to the last one. So let's say let me see here. We want to get from India to Brazil. So it's one two and three. So we have to write four because it stops at four and we got three. So let's write here 124 English we'll get Yeah, India, China, and Brazil. So this is one way to do it. But another way to do it is just delete this and leave it as it is and then run the code. And as we can see, we got the same result. So every time you want to get from one position to the last one, you can omit the top element, and just leave it without that element. So just as we did here, and the same goes for the start. So let's say we want to get from the first position, so index zero to two.
So we don't include that start element, and we write only colon, and two. So we're on this, and we get United States. And then we get India, because this is the first and this is the second. So every time we want to get from the first element, or into the last element, we can omit that target and its top elements, as we did in these two examples. Okay, now let's see how we can add elements to a list. There are different methods that help us add a new element two lists. So let's have a look. The first one is called append. And we're going to use that counters list as an example. So I'm going to write countries just so you can remember. And here it's countries. And as you can see, it has four elements. And let's say we want to add any country to this country's list. So what we can do is just right here, or paste here, countries, you know, add, append, or that append in here, as you can see is this method. So inside parentheses, we can write the new country, we want to add to this list. So let's say we want to add the country Canada. So write Canada. And now we'll run this code. As you can see, nothing is printed, but it will print the counters list again, we see here a new element. So as you can see here, that append method adds a new element at the end of the list. So this is by default at the end. But what happens if you want to add an element in a different position. So here, you can use another method, which is called that insert method. So let me show you here, I'm gonna copy countries, you know, I'm going to use the Insert method. So I write that insert, then parentheses, and this one accepts two arguments. The first one is the index. So the position of the element do want to insert. So let's say we want these are the first position. And the second argument that it takes is the new element do want to add. So in this case, let's say we want to add that Elements pane, so these, another country, and it's going to be in the first position, so index zero.
So let's try I run this one. And again, nothing happens, apparently, nothing happens. And here, if I run this country's list, again, we can see that there is a new element, and this element is pain. It's located in the first position. Unlike Canada, that was placed in the last position. This is one of the difference between the append method and the insert method. So with insert, we can specify the position, we want to insert this new element, but with append, the element is added at the last position. Another thing you can do is to join two lists, using the plus operator would use the task operator to concatenate strings before but you can also join two lists. So let me show you here. I'm going to create a new list just to show you how it works. So my new list is going to be called countries underscore two. So I'm gonna include different countries. So in this case, it's going to be the UK, then Germany am. That's right, Austria. So we have three countries in this new list. And now I'm going to run this one. And if we want to concatenate these first list countries, with the second list, countries to We can use the plus operator. So here, I write plus. And then I run this one. And as you can see, I got five elements from the first list. And three elements from the second list in another cool thing you can do in Python is putting these two lists inside another list, which is called nested list. So let's try out. So here, I'm gonna create a new list, it's gonna be called nested underscore list. In here, I'm going to open square brackets to create a new list. And as elements, I'm going to write countries, which is my first list, and then comma, and then countries underscore two. And this is my second list. So as you can see here, these elements inside this list, the first is a list in the second is the list. So we have lists inside another list, which is called a nested list.
So I run this one, and then I paste nested underscore list, and we run and we get here. The first is as first element and the second list as second element, you won't see these nested lists so often, but you will encounter this a couple of times, so it's good for you to know. So now we're going to say the opposite of adding an element to a list, which is removing an element. So here, I guess, pasted the country slate we had before. And what we're going to do is to remove some of the elements of this list. So there are different methods that help us remove an element from the list. One of them is the remove method. So to remove an element using this, we have to first write the name of the list, and then use that that sign and then write remove, and write parentheses in inside here, we have to write the element we want to get rid of. So first, it's United States. So write United States. And let's run this one. And as you can see, apparently, nothing happens. But if we paste countries, here, we have all the elements, but United States is not there. So as you can see, the first matching value was removed. But you can also remove an element by its index. So this is accomplished without pop methods. So I'm going to copy all of this. And now I'm going to paste it here. So instead of writing that, remove, I'm gonna write that pop in here, I'm not gonna use the name of the element, but its index. So I write the index. In this case, let's remove the last one. So it's going to be index minus one. And what pop is going to do is to remove that element with index minus one, and then returns this element. So this element is Canada, I didn't run this code here, so you can ignore it. So I'm going to come in this one. And our reference is going to be this this list. And to verify we use write countries, and then run, and here, as you can see, there isn't Canada anymore.
And that's how you remove an element using the pop method. But there's still another way to remove an item using an a specific index. And it's that Dell. So I'm going to show you here, del, it's the function del function. And here, we have to write the countries list. And then again, open square brackets in here, write that index. So I write here, the index. And unlike the pop method, we're not going to get the name of the element we're getting rid of, but just deleting the element. So I run this one. And here, we didn't get anything. And I'm gonna print this. So countries and that element at index zero was removed. So it's pain because that's the first element so we delete it or we remove the first element. So we only got India, China and Brazil. And there you have it three different ways to remove an element from a list. Okay, now let's see how to sort a list. We can easily solve a list using the stock method. Let's create a new list called numbers. And then sorted from the smallest to the largest number. So here first I write numbers, and then open square brackets. So I'm going to write some random numbers. So force four, then three, then 10, then seven, one, and then two. So this is my list. So I run this code. And now to sort it from the smallest to the largest number, we write numbers, then sort, then open parentheses. And by default, this is going to be sorted from the smallest to the largest number. So I run numbers again, in here, it starts with one, and it ends with 10. And as you can see, it's from the smallest to the largest number. So that's the default behavior of the SOC method. But we can control how this works. So we can add that reverse argument to the SOAR method to control the order. So if we want it to be descendant, we set reverse to true. So here, again, I'm going to create again, the numbers list, and then write numbers. That sort in inside parenthesis, I write the reverse argument in, I'm going to set it to true here.
And then I'm gonna print numbers. So here, I get an error, because here it I wrote number and its numbers. So here, I'm going to add the s, and here s two, so run again. And here we have, from the end here, we see that the list is sorted from the largest number to the smallest number. So as you can see, the default behavior of this sort method is reverse equal to false. So you can control it here, by writing reverse equal to true as we did here, okay, now let's see how we can update values. And always, to update a value on a list, we use indexing to okay, that element we want to update, and then we set it to a new value using that equal sign. So let's say we want to update the first element of this numbers list. So now it's four, but we want it to be, let's say, 1000. So we write here numbers. And we use indexing. So we write numbers, the first element has index zero, so we write numbers of square brackets than zero, then we set it equal to the new value we want to include. So in this case, I'm going to write 1,000th. And now I'm going to print the numbers, please, to see the results. So run this one. And as you can see, here, the number of leads we got is from the last change we made, so the one that's taught with 10. So it's not this one, but this one because it's the last one we ran. So instead of 10, we replace this one with 1000, because this is the first element with index zero. So with ID, numbers, square bracket zero, and we update that first element with 1000. Okay, finally, we can make copies of the list we created. So there are different options to create a copy of a list. One of them is that slicing technique. So as you might remember, to do slicing, we have first to write the name of that list, which in this case, is countries. And then we open square brackets, then we're supposed to write the start and stop. So in this case, we're not going to write start in a stop but only column.
So if we don't write start in, we don't write stop, it means we want the whole list. So let's try this out. I'm going to run this one. And as you can see, here, we got the whole list. So the counter sleaze doesn't have the original values, because of the changes we made when we added and remove elements. So I'm going to pace the original counters list with four original values that are the United States, India, China and Brazil. And here let's see the changes in how we test it out. In as you can see, we got the whole list. So from the first element United States to the last element Brazil, because we're slicing the whole list. So if we write here, new underscore list, and we set this equal to countries with this slicing, what is going to happen This new list is going to have the same values as the country list. So I write here new list. And as you can see here, it has the same values. So recreated copy of that counters list. So this is one way how you can create a copy. And the second way is more straightforward, or is it more explicit, so is using the copy method. So we write, again, countries the name of the list, and then we use the copy method. So write, copy, and then parentheses. So with this, we create a copy of this list. So let's run this code. And as you can see here, it returns the list. But if we assign these to a new list, we're going to create a copy. So here, I'm going to write new underscore list underscore two. So here, we assign this copy to this new list. So I'm going to copy this new list and paste here. And as you can see, here, we have the values of this list, which are the same as the original countries list that is here. And that's it. That's how you make a copy of a list. So now let's see how dictionaries work in Python. In Python, a dictionary is an unordered collection of items used to store data values, and a dictionary contains a key and a value.
So this is what you will often see in a dictionary. So here, for example, the name of my dictionary is my underscore dict. And to create this dictionary, we have to use these curly braces. So we open curly braces in inside, we write our first item in the first item consists of a key here on the left, and then our value here, and it's separated with the colon. So here we have the key, then column, and then the volume. And then we have here the second item. So the second key and the second value. So now let's create a dictionary that has some basic information about me. So I'm going to name this dictionary, my underscore data. And now to create this dictionary, I'm gonna open curly braces. And the first key is going to be name. So I write name, and it has a value that is my name. So I'm going to write Frank. So I open single quotes, and then write Frank. And then I'm going to add a new item. So I write coma. And then the second key is going to be age. And the second value is going to be my age. So in this case, I'm going to write my age, which is 26. So as you can see here, the first is a strength, the first value is a string, and the second is integer. So we can mix different datatypes. So now I press Ctrl, enter to run this code, and we created this dictionary. So now I write my underscore data in here you have the dictionary we created. So here we can get the keys of this dictionary, we only have to write my underscore data that keys so this is the keys method. So we run this, and we get this dict underscore keys. And the values are name and age, which are the keys of this dictionary we created. So name the first key and age the second key. Now we can get also the values. So my name and my age. So we just have to use the values method. So I'm going to paste this one here. And instead of writing that keys, I'm going to write that values. And now run this and we get my name and then my age.
So next, I'm going to get the items. So as I said before, an item is this. So this is the first item. And this is the second item. So we can say that the item is a pair of key and volume. So we can get this by using the items method. So instead of writing dot values, I'm going to write here that items and then run this one. So here we got the first item. So the first pair, key and value, which is my name am well that key name and then my name Frank. And then the second items so the key name, age and the age which is 26. Now we can add a new pair of key value in this dictionary we created. So let's say we want to add my height. So I write my data in. Let's say we want to add the key name height. So I write height. So we use square brackets here. And then we set this to the value. So let's say it's 1.7. So I write my data, and then square brackets, then hide inside it, and then equal to 1.7. So if I run this, in, then I run the dictionary, we can see that there is a new item, and it's the height. So height, column, and then 1.7. This is how you add a new item to the dictionary, a now we can update this height. So let's say I'm not 1.7, but I'm 1.8 meters. So what we can do is to use that update method to update this value. So I write my underscore data. In here, I can use the update method. So I write update, and then inside parentheses, we have to open curly braces to update this new item. So I'm gonna write the key, which is height. And then I'm going to set the new height, which is 1.8. So let's try this out. I run this, and then let's see the values. So let's see if it was updated. So I ran this, and we got the height 1.8. So it's perfect. So now let's see how we can make a copy of a dictionary, the same way we did before for the lists. So to make a copy, we just have to write the name of the dictionary, in this case, it's my underscore data. And then just as we did for the list, we can use that copy method.
So we write that copy with parentheses, and then we create an a copy. So here you can see the copy. And now I can assign these to a new dictionary. So I'm going to write new underscore dict. And now, I'm going to copy this one, I'm going to run and then I write new underscore dict. And run this. And as you can see, it has the value of the my underscore data dictionary. And something I didn't tell you when I make a copy of the list is that if you change the data inside that my underscore data dictionary, so the old dictionary, that effect is not going to be seen in the new dictionary. So for example, if we write one, that nine, and here, I update this in the old dictionary, so here you can see height 1.9. And if we run this new underscore dict, we can see that after running, this height, remains with the same value 1.8. And he doesn't change to 1.9. This doesn't happen if you make one of these copies most people do. So let me show you what I'm talking about. So most people just make a copy doing new data, underscore to equal to my data. So this is the old dictionary, and this is my new dictionary. So what happens if I run this, and then I, I'm going to show you the values of this new dictionary. So this is 1.9. And if I update this to, let's say, one point, 95. So update here, update here, here is one point 95. And if I run this new underscore dict underscore two, we can see that the value was updated to and this shouldn't happen. So if you want to create a new
And once it's downloaded, I'm gonna click on it, and a message will pop up. Do you just have to click on Allow us I'm going to do right now. So just click on Allow and then click on continue until the installation starts. So I just click Continue and then agree and then continue. And it's going to start installing Anaconda. In case you're on Windows and you're installing Python or Anaconda for the first time, make sure to check the first box you see now on screen. So I'm going to speed up the video now. Okay, the installation is almost done. And now it's telling me that Anaconda works with pi term. And now I'm just going to click on Continue to finish that installation. So I click Continue. And then we'll see just a summary of what was installed. And now I'm going to close this window and I'm going to open Anaconda. So I'm going to locate that icon, it's green icon, this one that you see here. And I'm going to open Anaconda. I'm going to wait a couple of seconds. And let's see what was installed. So here we have that you put your lab and Jupyter notebook, which are widely used in data science. So I'm going to launch Jupyter Notebook. So here it's opening Jupyter Notebook. Let's give it a second. And now we open a new notebook with python three. So python three was installed to and that's it. In the following videos, we'll learn how to use Jupyter Notebook. In this video, I will introduce you to the Jupyter notebook interface. Jupyter Notebook is an open source web application that allows us to create and share documents that contain live code equations, visualizations, and text. This is a perfect text editor for doing data cleaning and transformation. That visualization and data analysis this is why Jupyter Notebook is widely used in data science and also machine learning. As you might remember, we installed Jupyter notebook in Python with the Anaconda navigator in this means that we already have installed some popular libraries used in Python for data analysis.
By the way, one of the terms of Jupyter Notebook is Jupiter lab. Both are similar, but we're going to use Jupyter notebook in this course, because of its simplicity. So let's open Jupyter Notebook. And to do that, we have to click here on the launch button. So I click here. Now we wait a couple of seconds Now we have here the interface of Jupyter Notebook. So I'm gonna maximize this. And by default Jupyter Notebook opens the root directory of your computer, it's a good idea to create a folder where all your Python scripts will be located. In my case, this folder is called Anaconda scripts. So I click here. And now I can navigate through the folders. And the folder I'm going to use for this example is this one that says my course here, we're going to create our first python script. To do that, we click here on the New button. So click here, and we have to click on the first option that says, python three, there are other options like text file folder, or the terminal, but we're not going to use these options in this course. So click on python three. And now we have a Python script powered by Jupyter Notebook. So here on the right, you can see that it says python three, and also there is the Python logo. And on the left, you can see here the Jupyter Notebook logo, and also the name of this Jupyter Notebook file, we can change the name of the file by clicking here on on title. So I click here, and I can change it to, let's say, example. So I write example, in I click on Rename, and now we rename these up or not file. Alright, now let's navigate through this menu bar that we have here in this Jupyter Notebook file. So the first option is the file. In here, we can create a new notebook with python three. So if we click here, we're going to open a new Jupyter Notebook file from scratch as we did before, then we have the open and in this case, we can open a Jupyter Notebook we created before we can also make a copy to Jupyter Notebook and then change the name, we can save a Jupyter Notebook file and rename the file as we did before, we only click here and rename the file, then we can save all the progress we make in Jupyter Notebook.
For example, after writing many lines of code, you can save all the progress you make by pressing Ctrl S or Command S on Mac, and you're going to create a checkpoint. And later you can revert to a previous checkpoint by using this option here. So here you will see many checkpoints and you can revert to a previous checkpoint. By the way, by default Jupyter Notebook makes saves every third seconds or maybe one minute. So there is no need to press Ctrl S every time. So keep that in mind. Then we have other options that I don't use so much like print this Jupyter notebook or export that Jupyter Notebook file to HTML or PDF and so on. Okay, now let's see the second option that says Edit. And here we can edit all the cells we have here in this Jupyter Notebook. By the way, here, what you see here on the screen is a cell. So we can edit with this edit option. For example, we can cat cells, we can copy cells paste cells above and delete cells. On the right, you can see the shortcuts that we're going to see on the next video in detail. And well, you can check all the edit options that you can perform on Jupyter notebook here, then in the V option, we can toggle the header, the toolbar and also line numbers. So here, if I click on toggle header, the header is going to disappear. And if I click on toggle toolbar, this toolbar disappears to also here and toggle line numbers we can show here line numbers. So if I write anything, we can see that it says 123 and so on. And I'm not going to use this for this course, I'm going to leave it with the default options. So here I'm going to revert to the original options. So without line numbers, and I want to show the header and also the toolbar, but you can personalize it as you want.
Next in the insert options, we can insert cells above or below, we only click here. And well we're going to see the shortcuts later in the next video. Then we have the cell options, we can run cells or run all the cells in this Jupyter Notebook file. And then we have the kernel option. And a kernel is a computational engine that executes the code contained in a notebook document. When we open Jupyter Notebook. A kernel is automatically launched. And we can interrupt this kernel by clicking here. So by interrupting we can pause the execution of our code we can also restart everything and do more things here. Sometimes, for example, I interrupt the kernel when I line of code or a cell takes too much time to execute. And well you can do the same here with restart or interrupt. Then we have the Navigate option that doesn't actually have anything here, widgets that I don't use so much and will help that, I think it will send you to that documentation of Jupyter Notebook. And you can read it if you want. All right here. Then we have the toolbar, and here you will find some shortcuts of the menu bar that we've seen before. For example, here, you can save and make checkpoint. So here I click here. And as you can see, here, it says checkpoint graded, or something like that, yeah, checkpoint created and the time that he was created, then you can here with this plus button, insert, cell below sway click here, and as you can see, we can insert a cell below. And also you can use shortcuts, but that I'm going to show you in the next video, then we can cap selected cells with this button, we can copy a cell with this bottom. And also we can pace sales below. Also, we can move a cell above or below, for example, I'm going to write anything here in this cell, I can move it evolve with this button or below, as you can see here, then we can run this code, for example, I can write the number one, and then run the code.
And as you can see here, the code ran and it shows the number one and well, those are some of the frequently used buttons in the toolbar. And that's everything you need to know about this Jupyter Notebook file. Okay, now, before finishing this video, I'm going to show you some other options that you can find here in the user notebook interface. In here, you can see that there are some other options. So right now we are in the Files tab. And we can change to the running tab here. And here you can see all the currently running Jupyter Notebook processes. For example, we can see here that Jupyter Notebook file we created and that we opened. So you can recognize that you put your notebook file is open, or that is running, because here the icon will be in green. So here if we go back to the Files tab, we can see that this Jupyter Notebook file, which by the way has the IP y and b extension is in green, so the icon is in green. So this indicates that the file is running in well, it was opened. So here we can see that is open, and we can shut down this file. And this is different from closing this file. For example, here I have the file. And if I close this file, here, we can see that file is still running. Here we see running is in green, and in the running tab, it still shows up. So if we want to shut down this file, we click here. And it says that there are not not books running. And we can see here that the notebook has a great icon. Alright, then we have the clusters tab and this tab I don't use so much. And actually, it doesn't show anything here. And then we have the NB Extensions tab. Here, you can install any extension to personalize Jupyter Notebook even more, and we're going to see some cool Jupyter Notebook extensions in the next videos. And by the way, this NBA Extensions tab doesn't show up in some versions of Jupyter Notebook, but we can easily install it and we'll also see how to install these ennemi extension step in the next videos.
Finally, we have this box that shows our directory. So here this folder indicates that root directory. So if I click here, we are not in the root. And if I click on the folders, Anaconda script and then my course I go to the folder where I was before. And that's it. These are all the things you need to know about the Jupyter notebook interface. Okay, in this video, we're gonna see some cell types and cell modes in Jupyter Notebook. So first, we're going to open that Jupiter notebook file that we created in the previous video, which is this one example that I p y and b. So we click on it. And here we have the Jupyter Notebook file opened. In here by default, we have these four sold in command mode. And we can say that this is command mode because here this blue color indicates that the cell is in command mode. And when we are in command mode, we can do things outside the scope of any individual cell. So basically all the tools we see here in the toolbar, we can apply it in command mode. Also in command mode, we can apply some shortcuts that I'm going to show you later. And for example, if we want to see the shortcut window, we press the letter H in command mode, and we can see the keyboard shortcuts here. So here You can see all the shortcuts in all the shortcuts that you can apply in commandment. Now I'm going to close this one. And also you can apply different shortcuts like for example, if you press B in the command mode, you will see that there is a new cell because B is the shortcut that introduces a new cell below. Now, if we press enter, you're going to see that the color is going to change to green. So here we have green color. And this green color indicates that we are in Edit mode. And the edit mode is for all the actions you will usually perform in the context of the cell.
For example, introducing text or writing code. So here I can write, say 123. So if I write 123, and then I click on this run button, I'm going to run this cell. And as you can see here, I run this first cell. And also after running the cell, you can see that we are again in command mode. So to go to Edit Mode, we press Enter again, and now we can edit the numbers we introduced. So for example, I can write 456, and then run again. And here you can see that the output shows 12345, and six. By the way, if you try to use the shortcut in edit mode, it won't work here, press enter. And now I'm on edit mode. And if I press the nether H, you can see that nothing happens, we don't have the shortcut window. And if I press the letter B, you can see that we don't insert any cell below. This happens because those shortcuts work only on command mode. So to escape this edit mode, we have to press the Escape button. So press escape. And now I'm again in command mode. So if I press H, we have here that keyboard shortcut. And if I press B, you can see that we inserted a new cell. And that's it for the command in the edit mode. Now we'll see the cell types in Jupyter notebook in Jupyter Notebook. There are three main cell types. And we can see all of them in this drop down here. Right now the type of this cell is code. So here it says code. But if we press here, you can see other cell types like Markdown and row and B convert. So we're gonna see first a code cell, and it already has the check. So this one is a code cell. So now I press here, and now well, it's in code cell. If I press Enter, I'm in edit mode. And here I can introduce any code I want. So here I can write any number 99. If I press Control, Enter, we can see that here, this is the input in here we got the output of this code, we're going to see how the code cell works throughout this course. But now it's time to see how that markdown cell works in Jupyter Notebook.
So here, I'm going to the cell. Now I'm going to change the cell type. So I press here in the drop down. And now I select markdown in the markdown cell, we can introduce any type of text we want. For example, we can introduce titles. So if I delete this and press the hash sign, we can get title. So one hash, it means title. So here I press a space in now I write title. Now I press Ctrl, enter or this run button to run the cell. In here, we got the title. By the way, you shouldn't get this one number because I use modify the default behavior of Jupyter Notebook. So mine enumerates the titles and subtitles, but in your case, you will see only the word title. And if you want, you can introduce also subtitles here. So for example, I'm going to insert a new cell with this button is plus button. And now I'm going to move this cell up with this button here. So I press this in now I'm going to change the cell type from code cell to markdown cell. So I go to the drop down and select markdown. And by the way, you can change the cell type also with shortcuts. So if you're in command mode, you can press the Y button to change the code cell. So I press the Y button. And as you can see here, it says in and this in with square brackets indicates that this is a code cell. So here I can press enter and introduce any code here I introduce numbers and press the Run button. And here you can see that we have an input and an output. So this is a code cell. But now we can press the M button to make this cell a markdown cell. So now we press M and here we are in command mode. So now we can get this markdown cell in here. You don't see that in Word with the square brackets anymore. So now I'm going to edit mode so I just press here or Well, you can press enter to Go to Edit mode. In order to introduce a subtitle, I'm gonna write double hash sign. So I press hash sign twice.
Now let's paste in. Now I'm going to write a subtitle. So I write subtitle, I press Ctrl, Enter, or the run button to run the cell. And we've got here a subtitle. And we can also introduce text, I'm going to introduce a new cell with a plus button. And you can also do it without beat shortcuts. I'm going to do it with a B shortcut, right now, I press B. And here I got this new cell. And we can move this with this button here. And now we have this cell in the position we want it. So here, I can introduce text by converting the cell to markdown. So here, I choose markdown. Now you press Enter to go to Edit Mode. And here I can introduce any text. For example, I can write hello, I press Control, Enter. And now we can see that we have here this text. And finally, the last type of cell is that row and B convert. And this type of cell is not ever loaded by the notebook kernel. So if we convert this code cell to a row cell, this cell won't be emulated by the notebook kernel. So let's try here, I press row, and be converted. Now we can see that this looks like a plain cell. And well this type of cell is not used that often, actually, we're going to use only that code cell and a markdown cell in this course. And that's it. In this video, you'll learn the cell types and cell modes in Jupyter Notebook. Okay, in this video, we're going to see some common shortcuts used in Jupyter Notebook. And we're going to start with the F shortcut. And by the way, to use this shortcut, you have to make sure you're in the command mode and to verify during the command mode, make sure that the cell has this blue color. Okay, now during the command mode, you can press the letter F, and you're going to see these Find and Replace. So this first shortcut allows us to find our word in a cell and then replace it with another word. For example, I can write here the word hello. And here, it found the word hello, inside this hello, world sentence.
And now I can replace this word with the world. Say hi, for example. So here, I write Hi, in red, we can see the match. And in green, we can see the word that we're going to insert. So here, let's click on Replace all. And now you can see that it doesn't say hello world anymore. But now it says Hi, world. So now I press Ctrl Enter, which is another shortcut to run the cell. So you can press here and run or only press Ctrl Enter to run this cell. So press Control Enter. And now we ran this cell in another way to run cells is to press shift, enter. But in this case, we're going to run an insert a new cell below. So now let's see I press Shift Enter a note here, it ran the cell because now test in n three inside square brackets. In here, we can see that we have a new cell. Okay, now another shortcut that is often used is the y and m shortcut. So now this cell is a code cell. And if we want to make this a markdown cell, we only have to press the M letter, so we press M and this is going to be converted to a markdown cell. And if we press the letter y, this is going to be converted to a Kotel and also you can change the heading here, you can make the heading bigger or smaller. So here, I'm going to locate the cell A now to make this one smaller, we can press the numbers. So if we press the number two, we can see that this one gets smaller. And if I press number three, the title gets smaller for smaller and so on. So as you can see the more hash signs, the smaller the text. So here I'm going to delete this hash signs. And one hash sign represents the biggest phone size, which is the title. So now we press Ctrl, enter, and now we have this in heading one. But if I press number five, and then press Control Enter, we can see that now this cell has had in five and it's smaller. So now I'm going to revert to heading one. So you press one, and then Ctrl, enter. Okay, now we can navigate through the cells by pressing on the up or down keys on our keyboard.
And as you can see here, we can navigate through all the cells here or we can also press with the mouse, we can press on the cells we want. Okay, now we can insert a new cell above by pressing the A key so if I press a we get here a new cell above and if I press enter b, we get a new cell below. Now if I press x, we're going to Cat the cell. So I press X, and you can see that the cell was Cat A. Now if we press V, we paste that cell below. So I press V, now we got the cell. And if I press Shift plus V, we get the cell pasted above. So I press shift in V, and we get this new cell above this cell I have here, okay, now I can delete cells by pressing D twice. So impressed the two times. And as you can see here, that title disappeared. So now it tried again, and we don't have the title anymore. But now if we press the letter Z, we can Undo those changes. So let's undo what we did before. I press Z, and we get here, the title back. Okay, another useful shortcut is ctrl S, that allows us to save the changes we made in this Jupyter Notebook file. So I press Ctrl S, and you can see here that says, checkpoint created. So I'm going to press again Ctrl S, and here it says checkpoint created in here also says the time and it says these are some of the most common shortcuts used in Jupyter Notebook. But you can see other shortcuts by pressing the letter H. So press H. And here you can see more keyboard shortcuts. Or you can also go here to help and then go to keyboard shortcuts here, and you get the same window. So here you can see a list of shortcuts for command mode. And also for the edit mode, you can see the description of a shortcut, and also how to do it in your operating system. One of the typical ways to get started with a programming language like Python, is printing a simple message, you can write any message you want. But it's traditional among coders to start with a Hello World.
So let's try it. Let's print our first message using the print function. The print function prints a message to the screen. So I'm going to write here, print. And then I'm going to open parenthesis, every time we use a function. In Python, we have to open parenthesis, well, in this case for the print function. And as you can see, here, the functions get green color in Jupyter Notebook. So that's how you can identify them. So inside these parentheses, I'm going to write the message. So in this case, it's going to be Hello, world. So this is our first message. Now, to execute this first line of code, we have to press Ctrl N, Enter, or command and enter if you're on Mac. So I'm going to press this. And as you can see, here, we have our first hello world. Another way to run this first cell is pressing here on the run button is going to have that same effect. So I pressed and it rang. So as you can see here, it says in which represents a code cell. And this is a markdown cell, as we've seen before, one of the advantages that Jupyter notebook has is that it allows us to print the last object in a code cell without specifying the print function. So for example, here, I can print this Hello World with without writing this print function. So I'm going to copy this Hello World message that it's inside quotes. And I'm gonna run this code. So just Ctrl, Enter. And as you can see, here, we have this message printed. So this is one of the advantages that has up or not, if you do this in another Python ID, it will work. So here you can try yourself, you can write any message you want. Apart from the first hello world, you can try with your name. So we write prayer and then parentheses, and we open quotes, because we need to define a string. I'm going to tell you about strings a little bit later. But yes, so you know right now. And here, for example, I can write my name. So my name is Frank, and I can print my name, then I can print also numbers.
So I print my age 26. And it's gonna work too. And besides writing code, you can also add comments, comments are a useful way to describe what we're doing in our code. So here, we can use comments. We just have to write their hash sign, which is this one. So you write hash sign in, then you write the comment. In this case, I'm gonna write my name. And I'm going to say printing my name so we know what our code is doing here in the front. message we wrote, We can also add a comment. So we write hash sign. And then we can say printing my first message. As you can see here, the comments also have a different colors. So, so far, we have three colors, this color for their comments, green color, for God functions in red color for the string, this is just a useful functionality most texts a to have, that allows us to easily read code. Okay, now let's see some data types in Python. Every volume in Python is an object, an object has different data types. Let's see the most common data types in Python. So one of the most common is that the types in Python are integer and floats. Both are numbers. But integers are numbers that can be written without our fractional component, just like, for example, the number one, number 2345, and so on. So all of them are integers. And we can check these value or this data type by using the type function. So this is our second function we're going to see so we write type, and then parentheses, and we execute, we run this code. And as you can see here, in the output, it says, I n t, which represents integer, so this is an integer. Okay, the second type of data I want to show you is float. Floats are numbers that contain floating decimal points. So basically 2.3, let's say 1.25 5.4, and so on. So here, we have another type of data. And let's check out if these are actually floats. So we use type, and then parentheses, and we run this code.
And we say that we have float. And just like on Excel, you can perform math operations in Python using these numbers. So some operations, you can use our addition, for example, you can say one plus two, and then execute this code, and you get three, you can use subtraction, so four minus one execute, and you run this code and you get three. You can also do multiplication, division, exponents in more in Python. But now let's see the third data type that we will see often on Python, and it's the Boolean, Boolean are true or false values. And we can check this using again, that type function, and we write type. And within parentheses, we write for example, true. And we run this code and we see that we got that bool, which represent a boolean data type. So we can also write type, and in this case, false, and run this code, and we get bool. Again, so this is Boolean. And we're going to use Boolean, often when we use conditionals. Okay, now the fourth data type I want to show you and it's very common is the string. A string represents a series of characters. And in Python, anything inside quotes, either single quotes or double quotes, is a string. So let's see them actually, we already see one kind of string here when we printed this Hello, world. And you're actually familiar with this, but we're going to see it again. So to create a string, we have to open either single or double quotes. So in this case, I'm going to use double quotes. So you see it now. And now I'm going to write any message. So I'm going to write, for example, again, hello world. And again, to verify the type, we can use that type function, parentheses, run this code, and we get the STR that represents a string. And one cool thing a string has is methods, we can apply different functions to strings, as we will do in Microsoft Excel, for example. However, in Python, we use methods a method is a function that belongs to an object.
To call a method, we use the dot sign after the object. Let's see some string methods to change the case of text. So here, I'm gonna write again, hello world. But now I'm going to use some string methods. So write hello world. In this case, I'm going to use the upper method to make this uppercase, so I'm going to use the print function. But actually, we don't need to use the print function because as I told you before, and Jupyter Notebook, we don't need to use the print, because it automatically prints the last line of code. So since this is the only line of code in this cell block, it's going to print it automatically. So we just run this cell. And we have hello world in upper case. So as you might expect, now, we can also change the case of the text. In this case, it can be on lower case, or title case. So I'm gonna just copy and paste this twice. In here, I'm going to write instead of upper, I'm going to use flour, and then title. So you can see how it's going to change the case. So here, I'm going to run, and let's see what happens. So as you can see, here, it only printed the last one, because I told you before, it only prints the last one. And if we want to print the three of them, we have two options. So we can maybe here cut and paste on each cell. Or what we can do is to print each of them. So here, for example, I can do print here, and I can do the same for them. So instead of using more cells, we can print all of them. And here, we can print this one too. Actually, we don't need them, we don't need it, because it's going to print the last line. But just for the sake of this video, I'm going to print the three of them. So here, I'm gonna run this code. And as you can see here, the first it has an uppercase, the second has lowercase. And the third has a title case. So that's how you do it on Python, other string method that you can find Python is the count method.
So I'm going to delete this, and actually this one too. And we're going to see this now. So first, I copy this. And now I paste it here. And here, I'm going to use the count. So the count method, so I write count. And then here I open single quotes, and I write the letter that we want to count. So here, for example, I'm going to write that l letter. And what this string method is going to do is going to count how many times these l letter is included in this string. So as we can see, there are two L's, so it should set two times. So I run these code, and actually is three because there are two in kilo and one in world. So I was wrong. And here, another string method that you can use is the replace method. So we can replace one letter for another. So here, let me copy this, and I'm going to paste it here. And instead of writing count, I can write replaced. So here, the first letter that we're going to see here is the letter that we want to replace. So in this case, I'm going to change the L with O. And the second letter is the letter that you want to put in that string. So I'm going to use the U. So I'm going to change every time that an O appears here in the string, we're going to replace it for you vowel. So let's try it. So I run this code. And now it says, Well, hello world, but with you. And these are some of the most common string methods in Python. Okay, now it's time to learn something that you're gonna see often in Python, which are variables, variables help us store data values. In Python, we often work with data. So variables are useful to manage this data properly. A variable contains a value, which is the information associated with a variable to assign a value to a variable, we use that equal sign. So let's create a message that says, I'm learning Python, and stored in a variable called message underscore one. So here, I write message underscore one. And we set it to that is string.
I'm learning Python. So are you open double quotes in here I Right, I'm learning Python. So this is string. We've seen this before. And this is the variable, and we assign this value to the variable using the equal sign. Now I'm going to run this. And as you can see, nothing happens. But actually, we just assigned that string to the variable message underscore one. Now, if we want to obtain the message, I'm learning Python, we only have to type the variable name, and then execute that code. So I'm gonna copy and paste it here. And then we run this code. And as you can see, by running this cell, we obtain the content inside the variable message underscore one, we can create as many variables as we want, just make sure to sign different names to new variables. So let's create a new message that says, It's fine and stored in a variable called message underscore two. So first, I write message. So Ms search and underscore two, and then we set this equal to open double quotes, and right, and it's fun. This is my second variable, and I'm gonna run this cell. So as we can see, the string was assigned to the second variable. And if I copy and paste this variable here and run this code, we can see that the message it's there. By the way, if you're using single quotes, instead of double quotes, or some using in this video, probably you have the following issue. So here, I'm going to copy this one and paste it here so you can see what I'm talking about. So let's say you're let's say you're using single quotes, instead of double quotes. So you get this, this is a problem that you will have when using single quotes. Because in the English language, we use this apostrophes often. So a simple way to deal with this is using double quotes. So as you can see here, if I use double quotes, everything is okay. Everything remains as a string. But with single quotes, it doesn't happen. So only the i gets this string by dress, it doesn't get a string value, or the string datatype.
So just make sure you use double quotes every time you have these apostrophes, and that's it. Okay, now, let's put these two messages together. So message one with message two, I want to put them together. So this is called a string concatenation. If we want to put message one, in message two, together, we can use the plus operator. And we can just do this. So I'm going to copy message one, or the variable message one. And now I'm going to copy the variable message underscore two. And I use the plus in the middle to concatenate this first message with this second message. So run it, let's see what happens. So here, we can see that the two messages were concatenated. But here, there isn't a space between these two messages. So this is the first message and this is the second and there isn't any blank space in the middle. So what we can do here is to just add a blank space. So I'm going to copy this one and paste it here and show you how to do it. So here I add a new plus operator in the middle, we open A string. So with single quotes, or double quotes, in this case, I'm going to use single quotes here, integrate this blank space, I'm going to press a space. And here we have our blank space here. And then we run this code. And now let's see. And here as we can see, there's a space between Python and that. And we have this blank space. And we want we can assign this new message to a new variable. So I'm gonna assign this to a variable called message. And I write message here. And I include here below the code in here, I can print this so as you can see, if I run this, we can see that the message is there. Okay, now let me show you an alternative way to join two strings. So this is called the F string, and it works like this. You write F and you open A string, so we write a single quotes here. So one and two in here. As you can see the whole, the whole thing is red.
So it's like everything is a string in here inside, we can write the message. So let's see, let's say we write a simple Hello World. So hello, world. And we run this. And as you can see here, this is a string, it just has this F, in front of that string. In here, one of the advantages that this f string has is that it can have variables inside the string. So here, for example, we can write a variable opening these curly braces. So these collaborations can have variables inside it. So here, I can write message, underscore one, and we can print it. So if we print, we have this string, I'm learning Python a now if we want to concatenate this first message with our second message, we just have to include curly braces, again, I put it here. And now I write message two. And between message one in message two, I just have to press pace. And we have this. So I'm learning Python, and it's fun. So here, we just press is pace. And this pace also appears here. So for example, if we add some random text, let's say ABC, we get this ABC, between Python in between. So this is how f string works, do you just have to write the F, then open single quotes, and inside you can write any message. And to include any variable, just you have to open these curly braces, write the variable name, and that's how to join strings. Okay, now it's time to see a data type that is used. Often in data analysis, I'm talking about this. In Python lists are used to store multiple items in a single variable list are order and mutable containers. In Python, we call mutable, two objects that can change their values, that is, elements within LA's can change their values to great Alice, we have to introduce that element inside the square brackets separated by commas. So let's create our first list. First, we have to set the name of the list. In this case, I'm going to name it countries. And now to create the list, we have to open square brackets SAS said before.
So here, we open square brackets. And here we have to write the elements. So I'm gonna include in these countries list just strings, and they're going to be names of countries. So the first one, I'm going to write the United States. So this is the first element in my list. And to write the second, we have to use the comment. So here, comma, and now the second. So let's write India, tomorrow. So now China, and finally Brazil. So these are the four countries, as you can see here, these are lists. So we have the square brackets that represent the list. And we have four strings. And this is how we define or how you create a list. So now I'm going to run this one. And to see the content, I'm going to paste the name of this list in now I run here, I include only strings. But keep in mind that lists can have elements of different types. So for example, one string and the other and integer, and then a float, and so on. And also lists can have duplicated elements. So for example, I can have here, United States, written twice. So here, for example, I can write United States, twice m, that's okay, because this can have duplicate elements, but I don't want it that way. So I'm gonna delete it and leave it as it is. Okay. Now, if we want to get an element inside this list, we have to use something called indexing. By indexing, we can obtain an element by its position. So each item in a list has an index, which is the position in the list. Python uses zero based indexing, that is the first element so United States has an index zero, the second So India has an index one, and so on. To access an element by its index, we need to use the square brackets again. So let's see some examples. Let's start by getting the first element. So United States. So what we have to do is to write the name of the list, in this case countries, and then open square brackets, in inside square brackets, we have to write the position of this element.
So it starts with zero, so we write zero to get that first element. And then we run this code. And as you can see, we get the first element. So if we write here, countries square brackets, one, we get India. And if we write countries square brackets to we get China, and we do this, with the number three, we get Brazil. So to verify this, I'm gonna print each of them. So let's see what happens. So here print. And finally print this one. In now I'm going to run and we shall get each element of the list from the United States to Brazil. So let's try out. So here we have each of them, United States, the first one, then India, then China, and then Brazil. So it's correct. So this is the most common way to use indexing, but there is also negative index, this helps us get elements is starting on the last position of the list. So instead of using indexes from zero and above, we'll use indexes from minus one and below. So let's get the last element of the list. But now using a negative index, so we want to get the last element which is Brazil. And we did it before with countries square brackets three. But now we're going to do it with negative indexing. So here, I'm going to write countries and copy and paste it here. And now I open square brackets. And instead of writing three, we're going to write minus one. And these minus one represents the first element is Talend. From the last position to Brazil will be minus one, China is minus two, India minus three United States minus four. And that's how it works. So I'm going to run this one countries, square brackets, minus one, and we will get Brazil and we got it. So let's do this one more time. And in this case, I want to get United States, which is minus 123, and four, so it's countries minus four. So we run this and we got United States, but now using a negative index. Okay, now let's see something called as slicing is slicing means accessing parts of the list, as lies is a subset of list elements is slice notation takes the form of a list.
So the list name, and then a square brackets and this tart, then this colon and stop this is Todd represents the index of the first element in his top represents that element to stop at without including it in the slides. So let's see some examples. So I'm going to use this country's list again, and use I'm going to copy this one, and I'm going to paste it here. So this is the name of my list. And now I open square brackets. And we're going to get, let's say, we're going to talk at position number zero, and then column and let's get from zero to position number two, so we have to write three, because it stops at three without including these elements in the position number three. So let's run this one. And as you can see, here, we have index zero, index one and index two. So it didn't include index number three, you know, let's say we want just the first element, so we write from zero to one. So it's only zero and one no, because it doesn't include one, and it's topped at one. So here I run, and we got only United States. So now let's try something different. Let's say we want to get elements from index one to the last one. So let's say let me see here. We want to get from India to Brazil. So it's one two and three. So we have to write four because it stops at four and we got three. So let's write here 124 English we'll get Yeah, India, China, and Brazil. So this is one way to do it. But another way to do it is just delete this and leave it as it is and then run the code. And as we can see, we got the same result. So every time you want to get from one position to the last one, you can omit the top element, and just leave it without that element. So just as we did here, and the same goes for the start. So let's say we want to get from the first position, so index zero to two.
So we don't include that start element, and we write only colon, and two. So we're on this, and we get United States. And then we get India, because this is the first and this is the second. So every time we want to get from the first element, or into the last element, we can omit that target and its top elements, as we did in these two examples. Okay, now let's see how we can add elements to a list. There are different methods that help us add a new element two lists. So let's have a look. The first one is called append. And we're going to use that counters list as an example. So I'm going to write countries just so you can remember. And here it's countries. And as you can see, it has four elements. And let's say we want to add any country to this country's list. So what we can do is just right here, or paste here, countries, you know, add, append, or that append in here, as you can see is this method. So inside parentheses, we can write the new country, we want to add to this list. So let's say we want to add the country Canada. So write Canada. And now we'll run this code. As you can see, nothing is printed, but it will print the counters list again, we see here a new element. So as you can see here, that append method adds a new element at the end of the list. So this is by default at the end. But what happens if you want to add an element in a different position. So here, you can use another method, which is called that insert method. So let me show you here, I'm gonna copy countries, you know, I'm going to use the Insert method. So I write that insert, then parentheses, and this one accepts two arguments. The first one is the index. So the position of the element do want to insert. So let's say we want these are the first position. And the second argument that it takes is the new element do want to add. So in this case, let's say we want to add that Elements pane, so these, another country, and it's going to be in the first position, so index zero.
So let's try I run this one. And again, nothing happens, apparently, nothing happens. And here, if I run this country's list, again, we can see that there is a new element, and this element is pain. It's located in the first position. Unlike Canada, that was placed in the last position. This is one of the difference between the append method and the insert method. So with insert, we can specify the position, we want to insert this new element, but with append, the element is added at the last position. Another thing you can do is to join two lists, using the plus operator would use the task operator to concatenate strings before but you can also join two lists. So let me show you here. I'm going to create a new list just to show you how it works. So my new list is going to be called countries underscore two. So I'm gonna include different countries. So in this case, it's going to be the UK, then Germany am. That's right, Austria. So we have three countries in this new list. And now I'm going to run this one. And if we want to concatenate these first list countries, with the second list, countries to We can use the plus operator. So here, I write plus. And then I run this one. And as you can see, I got five elements from the first list. And three elements from the second list in another cool thing you can do in Python is putting these two lists inside another list, which is called nested list. So let's try out. So here, I'm gonna create a new list, it's gonna be called nested underscore list. In here, I'm going to open square brackets to create a new list. And as elements, I'm going to write countries, which is my first list, and then comma, and then countries underscore two. And this is my second list. So as you can see here, these elements inside this list, the first is a list in the second is the list. So we have lists inside another list, which is called a nested list.
So I run this one, and then I paste nested underscore list, and we run and we get here. The first is as first element and the second list as second element, you won't see these nested lists so often, but you will encounter this a couple of times, so it's good for you to know. So now we're going to say the opposite of adding an element to a list, which is removing an element. So here, I guess, pasted the country slate we had before. And what we're going to do is to remove some of the elements of this list. So there are different methods that help us remove an element from the list. One of them is the remove method. So to remove an element using this, we have to first write the name of the list, and then use that that sign and then write remove, and write parentheses in inside here, we have to write the element we want to get rid of. So first, it's United States. So write United States. And let's run this one. And as you can see, apparently, nothing happens. But if we paste countries, here, we have all the elements, but United States is not there. So as you can see, the first matching value was removed. But you can also remove an element by its index. So this is accomplished without pop methods. So I'm going to copy all of this. And now I'm going to paste it here. So instead of writing that, remove, I'm gonna write that pop in here, I'm not gonna use the name of the element, but its index. So I write the index. In this case, let's remove the last one. So it's going to be index minus one. And what pop is going to do is to remove that element with index minus one, and then returns this element. So this element is Canada, I didn't run this code here, so you can ignore it. So I'm going to come in this one. And our reference is going to be this this list. And to verify we use write countries, and then run, and here, as you can see, there isn't Canada anymore.
And that's how you remove an element using the pop method. But there's still another way to remove an item using an a specific index. And it's that Dell. So I'm going to show you here, del, it's the function del function. And here, we have to write the countries list. And then again, open square brackets in here, write that index. So I write here, the index. And unlike the pop method, we're not going to get the name of the element we're getting rid of, but just deleting the element. So I run this one. And here, we didn't get anything. And I'm gonna print this. So countries and that element at index zero was removed. So it's pain because that's the first element so we delete it or we remove the first element. So we only got India, China and Brazil. And there you have it three different ways to remove an element from a list. Okay, now let's see how to sort a list. We can easily solve a list using the stock method. Let's create a new list called numbers. And then sorted from the smallest to the largest number. So here first I write numbers, and then open square brackets. So I'm going to write some random numbers. So force four, then three, then 10, then seven, one, and then two. So this is my list. So I run this code. And now to sort it from the smallest to the largest number, we write numbers, then sort, then open parentheses. And by default, this is going to be sorted from the smallest to the largest number. So I run numbers again, in here, it starts with one, and it ends with 10. And as you can see, it's from the smallest to the largest number. So that's the default behavior of the SOC method. But we can control how this works. So we can add that reverse argument to the SOAR method to control the order. So if we want it to be descendant, we set reverse to true. So here, again, I'm going to create again, the numbers list, and then write numbers. That sort in inside parenthesis, I write the reverse argument in, I'm going to set it to true here.
And then I'm gonna print numbers. So here, I get an error, because here it I wrote number and its numbers. So here, I'm going to add the s, and here s two, so run again. And here we have, from the end here, we see that the list is sorted from the largest number to the smallest number. So as you can see, the default behavior of this sort method is reverse equal to false. So you can control it here, by writing reverse equal to true as we did here, okay, now let's see how we can update values. And always, to update a value on a list, we use indexing to okay, that element we want to update, and then we set it to a new value using that equal sign. So let's say we want to update the first element of this numbers list. So now it's four, but we want it to be, let's say, 1000. So we write here numbers. And we use indexing. So we write numbers, the first element has index zero, so we write numbers of square brackets than zero, then we set it equal to the new value we want to include. So in this case, I'm going to write 1,000th. And now I'm going to print the numbers, please, to see the results. So run this one. And as you can see, here, the number of leads we got is from the last change we made, so the one that's taught with 10. So it's not this one, but this one because it's the last one we ran. So instead of 10, we replace this one with 1000, because this is the first element with index zero. So with ID, numbers, square bracket zero, and we update that first element with 1000. Okay, finally, we can make copies of the list we created. So there are different options to create a copy of a list. One of them is that slicing technique. So as you might remember, to do slicing, we have first to write the name of that list, which in this case, is countries. And then we open square brackets, then we're supposed to write the start and stop. So in this case, we're not going to write start in a stop but only column.
So if we don't write start in, we don't write stop, it means we want the whole list. So let's try this out. I'm going to run this one. And as you can see, here, we got the whole list. So the counter sleaze doesn't have the original values, because of the changes we made when we added and remove elements. So I'm going to pace the original counters list with four original values that are the United States, India, China and Brazil. And here let's see the changes in how we test it out. In as you can see, we got the whole list. So from the first element United States to the last element Brazil, because we're slicing the whole list. So if we write here, new underscore list, and we set this equal to countries with this slicing, what is going to happen This new list is going to have the same values as the country list. So I write here new list. And as you can see here, it has the same values. So recreated copy of that counters list. So this is one way how you can create a copy. And the second way is more straightforward, or is it more explicit, so is using the copy method. So we write, again, countries the name of the list, and then we use the copy method. So write, copy, and then parentheses. So with this, we create a copy of this list. So let's run this code. And as you can see here, it returns the list. But if we assign these to a new list, we're going to create a copy. So here, I'm going to write new underscore list underscore two. So here, we assign this copy to this new list. So I'm going to copy this new list and paste here. And as you can see, here, we have the values of this list, which are the same as the original countries list that is here. And that's it. That's how you make a copy of a list. So now let's see how dictionaries work in Python. In Python, a dictionary is an unordered collection of items used to store data values, and a dictionary contains a key and a value.
So this is what you will often see in a dictionary. So here, for example, the name of my dictionary is my underscore dict. And to create this dictionary, we have to use these curly braces. So we open curly braces in inside, we write our first item in the first item consists of a key here on the left, and then our value here, and it's separated with the colon. So here we have the key, then column, and then the volume. And then we have here the second item. So the second key and the second value. So now let's create a dictionary that has some basic information about me. So I'm going to name this dictionary, my underscore data. And now to create this dictionary, I'm gonna open curly braces. And the first key is going to be name. So I write name, and it has a value that is my name. So I'm going to write Frank. So I open single quotes, and then write Frank. And then I'm going to add a new item. So I write coma. And then the second key is going to be age. And the second value is going to be my age. So in this case, I'm going to write my age, which is 26. So as you can see here, the first is a strength, the first value is a string, and the second is integer. So we can mix different datatypes. So now I press Ctrl, enter to run this code, and we created this dictionary. So now I write my underscore data in here you have the dictionary we created. So here we can get the keys of this dictionary, we only have to write my underscore data that keys so this is the keys method. So we run this, and we get this dict underscore keys. And the values are name and age, which are the keys of this dictionary we created. So name the first key and age the second key. Now we can get also the values. So my name and my age. So we just have to use the values method. So I'm going to paste this one here. And instead of writing that keys, I'm going to write that values. And now run this and we get my name and then my age.
So next, I'm going to get the items. So as I said before, an item is this. So this is the first item. And this is the second item. So we can say that the item is a pair of key and volume. So we can get this by using the items method. So instead of writing dot values, I'm going to write here that items and then run this one. So here we got the first item. So the first pair, key and value, which is my name am well that key name and then my name Frank. And then the second items so the key name, age and the age which is 26. Now we can add a new pair of key value in this dictionary we created. So let's say we want to add my height. So I write my data in. Let's say we want to add the key name height. So I write height. So we use square brackets here. And then we set this to the value. So let's say it's 1.7. So I write my data, and then square brackets, then hide inside it, and then equal to 1.7. So if I run this, in, then I run the dictionary, we can see that there is a new item, and it's the height. So height, column, and then 1.7. This is how you add a new item to the dictionary, a now we can update this height. So let's say I'm not 1.7, but I'm 1.8 meters. So what we can do is to use that update method to update this value. So I write my underscore data. In here, I can use the update method. So I write update, and then inside parentheses, we have to open curly braces to update this new item. So I'm gonna write the key, which is height. And then I'm going to set the new height, which is 1.8. So let's try this out. I run this, and then let's see the values. So let's see if it was updated. So I ran this, and we got the height 1.8. So it's perfect. So now let's see how we can make a copy of a dictionary, the same way we did before for the lists. So to make a copy, we just have to write the name of the dictionary, in this case, it's my underscore data. And then just as we did for the list, we can use that copy method.
So we write that copy with parentheses, and then we create an a copy. So here you can see the copy. And now I can assign these to a new dictionary. So I'm going to write new underscore dict. And now, I'm going to copy this one, I'm going to run and then I write new underscore dict. And run this. And as you can see, it has the value of the my underscore data dictionary. And something I didn't tell you when I make a copy of the list is that if you change the data inside that my underscore data dictionary, so the old dictionary, that effect is not going to be seen in the new dictionary. So for example, if we write one, that nine, and here, I update this in the old dictionary, so here you can see height 1.9. And if we run this new underscore dict, we can see that after running, this height, remains with the same value 1.8. And he doesn't change to 1.9. This doesn't happen if you make one of these copies most people do. So let me show you what I'm talking about. So most people just make a copy doing new data, underscore to equal to my data. So this is the old dictionary, and this is my new dictionary. So what happens if I run this, and then I, I'm going to show you the values of this new dictionary. So this is 1.9. And if I update this to, let's say, one point, 95. So update here, update here, here is one point 95. And if I run this new underscore dict underscore two, we can see that the value was updated to and this shouldn't happen. So if you want to create a new