Page 122 - Trackpad_V2.1_class8
P. 122

Program 23: To perform various list operations

                      Program23.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.















                  120   Trackpad (V2.1)-VIII
   117   118   119   120   121   122   123   124   125   126   127