Page 126 - Plus V4 with Adobe class 8
P. 126

Take Off                                                       Century   #Critical Thinking
                                                                                        21 st
                                                                                        Skills  #Technology Literacy
              Identify and circle the strings in Python from the following:

              1. "Name"                           2. 'Delhi'

              3. 123                              4. 23234.54

              5. "22323.11"                       6. '*&%$#'





        A  list  is a sequence  of  multiple  values  in  a sequence.  In  a list, each element or value  is called  an
        item. A list  is mutable, which  means the  items in  a list can be  modified  by  assigning  new  values.
        It is heterogeneous  in nature, which  means a list can contain numeric as well as character  data.
        In this chapter, you will learn about creating a list, operations performed on the list, and the functions

        of the list.

             CREATING A LIST


        Python  uses  lists  to  store  the  sequential  order  of  different  kinds  of  data.  Because  Python  lists  are
        changeable types, we can change their elements after they’ve been generated. Although Python has six
        data types that may hold sequences, the list is the most popular and dependable form.

        To create a list, you need to place all the elements separated by a comma inside a square bracket [ ]. The
        list can contain any number of elements of different data types such as integer, float, character and so
        on.
        Syntax to Create a List:

        <list_name> = [value1, value 2, value 3, ...]

        An empty list is a list that does not contain the items in it. The example of the empty list is given as
        follows:

        To create empty list:
        List1 = []

        Some other examples of the list are given as follows:

        To create list of 4 integer elements: L1 = [1, 2, 3, 4]
        To create list of characters: L1 = [’a’, ’b’, ’c’]

        To create list of 3 strings: L1 = [“Nikhil”, “Dikshant”, “Jatin”]

        To create list of integer and float numbers: L1 = [1, 1.5, 2.5, 7]

        To create list with mixed data types: L1 = [7, “Hello”, 3.14]







            124  Plus (Ver. 4.0)-VIII
   121   122   123   124   125   126   127   128   129   130   131