PYTHON LIST

                               PYTHON  PROGRAMMING  --  LIST


LIST:

       1. Lists are used to store multiple items in a single variable.  

       2.It  is mutable. this means that once defined ,they can be changed. 

       3.List is the most versatile data-type available in Python that can be written as a collection of comma-separated values or items between square brackets.

       4.A single list can contain different Data-Types such as integers ,strings ,as well as objects .

   Example:

       A=[23,'Hello',23.4,'y']

NESTED   LIST:

         list can contain any sort object, even another list (sublist), which in turn can contain sublists themselves, and so on.

     Example:

          A=[[1,2,3],['red','blue'],23]

LIST  OPERATORS:

         1. '+'  OPERATOR  FOR  CONCATENATION:

                Concatenation of lists is an operation where the elements of one list are added at the end of another list

EXAMPLE:


               2. '*'  OPERATOR  FOR REPEATING  THE ELEMENTS:

                           the * operator repeats the items in a list a given number of times.     

    EXAMPLE:

LIST   SLICINIG:

       List slicing refers to accessing a specific portion or a subset of the list for some operation while the original list remains unaffected.

    SYNTAX:

           variable[start : end : step]

    EXAMPLE:


LIST   METHODS:

        1.APPEND ( ):

                  The append() method in Python adds a single item to the end of the existing list. After appending to the list, the size of the list increases by one.

              EXAMPLE:

    2.INSERT ( ):

           insert() is an inbuilt function in Python that inserts a given element at a given index in a list. Parameters : index - the index at which the element has to be inserted.

          EXAMPLE:



    3.REMOVE ( ):

            remove() is an built-in function  that removes a given object from the list. The method does not return any value but removes the given object from the list.

         EXAMPLE:



    4.CLEAR ( ):

            The clear() method removes all the elements from a list.

          EXAMPLE:



    5.COUNT ( ):

             The count() is a built-in function . It will return the count of a given element in a list. The count() method returns an integer value. 

          EXAMPLE:

     6.INDEX ( ):

              The index() method return the position value of a given  element.

          EXAMPLE:



        7.POP ( ):

                 The value at index is popped out and removed. If the index is not given, then the last element is popped out and removed.

          EXAMPLE:



        8.REVERSE ( ):

                  The reverse() method will reverse the list without creating a new list.

          EXAMPLE:



        9.SORT ( ):

                    sort() method that modifies the list in-place.

          EXAMPLE:

   10.MAX ( ):
             . The max() method returns the elements from the list with maximum value.

          Example:
                 




   11.min ( ) :
             The min() method returns the elements from the list with minimum value.
        
          Example:

               



           

Comments