Page 104 - KEC Khaitan C8 Flipbook
P. 104

Output
                   Original string: 'Hello Orange Education'
                   Length of string: 22
                   Lowercase: hello orange education
                   Uppercase: HELLO ORANGE EDUCATION
                   Capitalized: Hello orange education
                   Title Case: Hello Orange Education
                   Swap Case: hELLO oRANGE eDUCATION
                   Casefolded: hello orange education
                   Index of 'Hello': 6
                   Replaced 'Hello' with 'Welcome to': Welcome to Orange Education
                   Split string: ['Hello', 'Orange', 'Education']
                   Joined string with '-': Hello-Orange-Education
                   Stripped string: 'Hello Orange Education'






                            LIST


                  In Python, a list is a type of container that is used to store a list of values of any type. One can
                  store an integer, string as well as objects in a single list. Each element in a list is assigned an index
                  number. The first index is 0, the second index is 1, the third is 2, and so on.


                  CREATING A LIST

                  Lists can be created by inserting the elements in square brackets []. The elements in the list are
                  separated by a comma.

                  Program 10: To create a list


                      Program10.py
                   File  Edit  Format   Run    Options   Window    Help
                   a= [10, 20, 30, 40, 50]                                      Output
                   print (a[2])                                               30




                  Let us study about some of the ways through which we can create different types of lists.


                  Empty List
                  An empty list in Python is created using square brackets [ ]. You can also create a empty list by

                  using the list() function.







                  102   Premium Edition-VIII
   99   100   101   102   103   104   105   106   107   108   109