LIST METHODS - PYTHON PROGRAMMING

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our channel so in the previous sessions were discussing about the list so in previous sessions we have seen how to create a list how to update a list how to append elements into a list that means insertion of elements interval is and how to access the equals from the list right so in this session let us have a look on some building functions on list right now first one building functions list building functions first there are few functions which will break them in value but doesn't change the list so there are few functions which will return some value but it doesn't change the existing list for example let us consider only the sequence is equal to 1 comma 2 comma 3 comma 4 comma 5 right now let us see some built-in functions which will return some value but doesn't change it the existing list first of all is count so the syntax for this count is listening dot count write count then so this count will return the number of occurrence of this value in the given list example here the list name is sequence so sequence dot count off they hit before so this will return the number of occurrences of 4 so this will return occurrences of 4 so how many times 4 is occurred in this sequence only 1 so that it will return the result as 1 if the see census of 1 comma 2 comma 3 comma 1 comma 4 comma 1 comma 5 see now if we apply sequence see this one let us take sequence 1 sequence 1 dot count of 1 so if we count the number of occurrences of 1 in the given sequence right here we have searching for this sequence 1 counting the occurrence of the given value in the sequence 1 so here the value is 1 so count this value of 1 in the sequence 1 so 1 2 3 so this will result 3 I say well that means the value 1 is occurred three times in the given sequence hope you understand this count so this will return some value but it doesn't change the existing list just it will end unaccompanied right next so this is the first one let us see the second one so second one is index index index of value here also same syntax is listening dot index of life so it will return the index of this given value the first which it appears first time a given sequence so let us explain you so your neck so forth so as we have discussed in the previous session if the index values will always starts from 0 so this is the 0th index first index second index thumb index and put in here this is first set so 0 1 2 3 4 5 6 so this is the index of positions here in for this list and here this is the index positions for this list right now we have we want the index value of 4 in the list sequence so in the history sequence were saying this were your 4 3 so it will return 3 as Anacin so it will return the index of given value and the index of a given value which appears first in the list so it appears postulants so that means if we had a more number of value same value repeatedly the first index value will be returned here see let us take one more example so that you know that understood in this value of one so sequence one dot index of one sequence one dot index of one so I am trying to get the index value of this one from the sequence I meant from the list sequence ma so here in the sequence they have three positions one two three times one has been occurred so what are you later it will return the index of given value that means o index of one which appears first in the list that means zero so it will return the index position as zero right so it will always victims value which are gets first on the list so in a previous case here only one four is there for is not repeated sorry so it will directly return the index of that particular value if it is repeatedly then then it will return only the first occurrence first occurrence no this is about the second one index so the third one is slight difference one more argument will be there where you come a start that means we have to specify the index value from where we have to find the index value I mean we are giving some range so from where we have to consider from from which index value we have to consider so that is a stunt see it also same value come on start for example here let us take for come up one so the starting index value is one if you consider the starting index value is one and from the index position one if we find the index path value for from the index value one we find the position of that is three this is obviously perfect because four is not repeated only one way but in this case but in this case in the second case now if I put here some too that means I am supposed to find the Val and next value of one but I have to consider the released from the index value to right now I am giving the wage so the starting index 1 is 2 from the starting index value - I have to find the index of 1 so now the list is / - so here from this position search will be done from this position to this position now sequence 1 coordinates of one giving you the index of money which happens first so from here what is the first position of 1 3 so if you're obviously little big thing and if we mention here for that means range is starts from for itself we have a consider from from for itself so from further what is the X of 1 from for what is the index of 1 fine so here 5 will be returned right so hopefully understood is sympathy the two variants of index one is with one out with second one is with value and starting ultimate right next so these are the three methods we can see in this first first candidate metimes value but doesn't change as the list that is account index next index off value comma start right next coming to the second category coming to the second category doesn't return a value but changes the list it does not return the value but changes the list that means this method will does not get any value but the list will be changed so in the the first thing which we have seen in the previous sessions that is append append of value so obviously this happens not value will append the given value at the end of the list so happen means adding the value at the end so if we want to add some value it here so we listed a dot happened of sis so here the sis will be appended here so if you if you bring the sequence obviously if we print 1 comma 2 comma 3 4 5 & 6 right hope you understood this this function doesn't return any value but it changes the list so this is the first thing so this already may have seen in the previous thing next similarly extend extend extend see here extent means we can extend this list means adding multiple values into the given list so f it will append only one value to the list and this extent will is usual to append and more values at a time into the list so here the list name dot extend so here we have to mention that at least which way one will extend so 7 comma 8 comma 9 so if I execute this one 7 comma 8 comma 9 and if you want to if you are trying to print the sequence we can get the values inserted in the list so 1 2 3 4 5 6 7 8 & 9 so extend means adding multiple elements into the list so here also it does not return any value but the list will be changed now coming to the third one right insert so it's like a change with this insert function that is so by using append function we can add the elements at the end of the list right by using extend function we get next we can add a multiple elements into the list but here by using this inside function we can insert the increment and the particular index well so whatever index we want we can add the value at the particular index C so sequence dot insert of given x0 comma n so this implies I want to insert the element 10 and they mix position 0 in its list of sequence so what are the elements in the sequence 1 2 3 4 5 6 7 8 9 so here one of the index position 0 1 2 3 4 5 6 7 & 8 right now after executing this command sequence wrote in set of 0 10 in that event X 0 and should be inserted so we will get the result as 10 comma 1 2 3 4 5 6 7 8 9 so at the position 0 the value is inserted and all the remaining elements will be more rights I hope you have assumed there's a fine difference between the insert X 10 n pepid functions so FN will always insert the element at the end of the list so here we can mention the index where we want to add or insert the element right next the next function is remove now how to remove the element from the list so sequence element we have and in this key how can one two three four five six seven eight and no remove remove function so this remove function will remove the value from the given list C sequence dot remove and so this implies we want to remove the value 10 from the missed sequence so it will search for the 10 and it will remove it so here also the first appearance of the value will be remove right so it will remove the first occurrence of the you and it had value from the list so remove the first occurrence of the given value from the list so see if if you achieve this statement automatically the result will be sequence is equal to and will be removed so 1 2 3 4 5 6 7 8 & 9 no second case sequence 1 dot remove 1 so here in this for two examples here we are supposed to remove the value of one from the list sequence 1 but here in the sequence 1 there are three ones in different positions 0 0 position third position fifth position but here we are not mentioning the index way so it will remove the first occurrence of the given value that means directly the value and the first occurrence even here it is in index 0 so obviously after the execution this sequence 1 will be 2 3 1 4 1 & 5 the first occurrence of 1 will be removed from the list right so hope you understood this one and remove function so here also it doesn't return any value but the list will be change next coming to the next one there is function reverse function so automatically the values of this function I mean that is what the list given this will be in printed in the papers on and then Co given in Osaka so let us take an example see let us take in sequence sequence dot members here there will be no argument so just the reverse function will reverse all the events from the ending list so if you try to print this list then this will return sequence is equal to my comma 8 comma 7 6 5 4 3 2 1 and so automatically the elements of the list will be in a bigger star right next so this is our that reverse function here also no value is written but the list is change next coming to the next one that is salt sort function so here as we know that sort function is used to sort the given elements in the list so if you take a list with 100 elements so by using this symbol sort function we can sort the all the equites to the list see let us take here salt here also we will not take any argument for this sort let us take this one sequence 1 dot salt so if you're trying to play the sequence 1 so this will print sequence 1 is equal to so here 1 and there is there are two more ones so 1 comma 1 comma 1 2 3 4 & 5 so this will be the result this sort function so it will sort within this anymore right so here also nobody is rated but the list has been changed right third one now the last one is pop function let us take this pop function so this pop function always and removes the last element if you move the last element from the list okay so here also we're not giving any arguments in this function so let us take this one this example right so sequence one dot oh so automatically it will return a value who children has been deleted right so this element has been deleted now so five is our statement so five element has been deleted if you try to print this sequence one this will give sequels 1 is equal to 1 comma 1 comma 1 2 3 and the 4 because 5 has been removed from the list hope you understood the simple functions so these are the some built-in list functions so hope you understood this session so if you are having any doubts regarding this built-in functions feel free to post your talks in the comment section if you really understood my videos like me like my videos share my sessions with your friends and don't forget to subscribe to our Channel so thanks for listening thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 52,600
Rating: undefined out of 5
Keywords: SUNDEEP, SARADHI, KANTHETY, PYTHON, PROGRAMMING, PORTABLE, FEATURES, APPLICATIONS, INTERPRETER, PYTHON SHELL, PYTHON SCRIPT, INTRODUCTION, BEGINNERS, GUI, GAMING, SIMPLE, PYTHON BASICS, OPERATORS, OPERANDS, IDENTITY, IS, IS NOT, IN, NOT IN, AND, OR, NOT, decision control, iterative statements, simple if, if else, nested if, if elif, true block, false block, indentation, LISTS, CREATING LISTS, UPDATIO, LIST METHODS, COUNT, INDEX, APPEND, REVERSE, INSERT, POP, MIN, MAX, SORT, LIST FUNCTIONS
Id: 8-RDVWGktuI
Channel Id: undefined
Length: 22min 44sec (1364 seconds)
Published: Mon Aug 27 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.