Transcript for:
فهم القوائم في بايثون

foreign onwards we will understand lists in Greater details in this presentation I will introduce you to the concepts of lists so without any further delay let's get started the first topic of this presentation is Introduction to lists the second topic is creating a list and the third topic is features of a list let's start with the first topic that is Introduction to lists so what is a list a list is a collection of similar or different types of data items so a list can have similar types of data items or it can have different types of data items in Python we are allowed to store different types of data items in a list let's now see an example of a list we can have a list of 10 natural numbers so we can have a total of 10 natural numbers in a list and this is how we can imagine a list of 10 natural numbers so this is the visual representation of a list containing 10 natural numbers here we can observe the items stored in this list we have a total of 10 natural numbers in this list and the indices are mentioned here from 0 to 9. the starting index of a list is always 0 and the ending indexes always length minus 1. as there are total 10 items in this list so the end index will be 10 minus 1 which is equal to 9. I hope this is clear so this is how we can represent a list as we have understood what a list is let's move on to the next topic that is creating a list so what do we mean by creating a list and how we can create a list a list is created by placing items inside square brackets separated by commas a list can easily be created by placing items inside square brackets and they are all separated by commas for example we can declare a list of 10 natural numbers easily and in order to do that we need to mention all our numbers within square brackets like this in this case I have created a variable numbers and I have assigned this variable to this list this is important step without a variable we can never refer this list so with the help of this variable we can refer this list in our program in this list we have a total of 10 data items we have all 10 natural numbers within this list the square brackets are used to represent a list in Python and with this we will have this list this is the visual representation of this list with 10 natural numbers and we also have this name mentioned here numbers and this is mentioned because numbers is the variable which is pointing to this list and with the help of this variable we can refer this list I hope it is clear now let's move on to example number two and see what other types of lists we can create let's see example number two now let's see how to create an empty list we are allowed to create an empty list also we first need to declare a variable and assign it an empty list without any item like this numbers equal to square brackets So within square brackets we do not have anything now it is important to understand that an empty list is all about square brackets without any items within it so in this way we can create an empty list let's move on to the example number three we can create a list of duplicate items as well for example we can declare a variable numbers and assign it this list which consists of one two two three three three four four four four these items these are all integers and the items are duplicated as in this case 2 is duplicated twice 3 is duplicated twice and 4 is duplicated four times so there are a total of 10 data items in this list and the visual representation of this list is as follows this is the visual representation of this list numbers I hope this is making sense so let's move on to the example number four this time we want to create a list with different types of items it is possible to create a list with different types of items as I have already mentioned that a list can have similar types of data items or it can have different types of data items for example we can create a list like this this items variable is pointing to this list and in this list we have a total of five data items in this list we have two integers two strings and one floating point value and this is how we can imagine our items list we have this items list with a total of five data items and these are different data items so with this we have also understood that a list can have different types of data items as well I hope with this the concept of creating a list is clear so a list is always created by placing items inside square brackets separated by commas now as we have understood this let's move on to the third topic that is features of a list so what are the features of a list the first feature is that a list can have duplicate items in Python so python allows us to store duplicate items as we have seen in example number three the second feature is that items in a list are mutable what is the meaning of mutable mutable means changeable we can change the items of a list so items in a list are changeable or mutable the third feature is that lists can store items of various types as we have seen in example number four we are allowed to store different types of data items in a list so with this we are done with this topic also we have understood what are the different features of a list as well and this means that we are done with all the topics of this presentation we have understood what is a list and how a list can be represented we have seen how to create a list and we have seen several features of a list with this we are done with this presentation okay friends this is it for now thank you for watching this presentation I will see you in the next one [Music] [Applause] [Music]