Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 104 - 2612_Digimind
P. 104

    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.

                      102   Premium Edition-VIII

| 99 100 101 102 103 104 105 106 107 108 109 |