Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 90 - 2607_Traclpad_Pro_5.1_flipbook_C8
P. 90

    l
                       ower(): The lower() function converts all uppercase letters to lowercase. Syntax of using lower()
                       function is:

                       string_name.lower()

                       upper(): The upper() function  converts all  lowercase  letters  to  uppercase.  Syntax  of using
                       upper() function is:

                       string_name.upper()

                       capitalize(): The capitalize() function returns a string with the first character in capital. Syntax
                       of using capitalize() function is:

                       string_name.capitalize()

                     Program 10: To use various string built-in functions.

                         Program10.py
                      File  Edit  Format   Run   Options   Window    Help

                      str = 'Hello'                                               Output
                      print(len(str))                                           5
                      print('Hello'.lower())                                    hello
                      print('hello'.upper())                                    HELLO
                      print('hello'.capitalize())                               Hello

                                              1.  What is a string?
                                                 _____________________________________________________________
                             uiz   Bee        2.  What are escape sequences?

                                                 _____________________________________________________________

                               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.

                                                                                       Functions, String and List in Python  89

| 85 86 87 88 89 90 91 92 93 94 95 |