Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 143 - 2609_Logicode
P. 143

    Output
                      Isosceles triangle

                     Program 21: To perform various list operations

                         Program21.py
                      File  Edit  Format   Run    Options   Window    Help

                      list1=['o','r','a','n','g','e']
                      print (list1[0])
                      print (list1[2])
                      print (list1[3])
                      list2=["Education",[2,0,2,4]]
                      print (list2[0][1])
                      print (list2[1][3])

                     You will get the following output:
                         Output

                      o
                      a
                      n
                      d
                      4

                            Hashtag

                          # Python: Python is an interpreted, object-oriented, high-level programming language

                          # Strings: Strings are a consecutive sequence of characters that are enclosed or surrounded by
                          single or double quotes

                          REVISIT

                      ▶   A consecutive sequence of characters that are enclosed or surrounded by single (‘ ’) or double (“ ”) quotes is
                         known as a string.
                      ▶   A list is a type of container that is used to store a list of values of any type.
                      ▶   Functions help us break our program into smaller pieces or modules.
                      ▶   Python functions can be categorised into in-built functions and user-defined functions.

                                                                                               String and List in Python  141

| 138 139 140 141 142 143 144 145 146 147 148 |