Page 72 - tp_Modula_v2.0
P. 72

On running the above program, you will get the following output:

                      Output

                   Hello
                   Python!
                   ython




                      PYTHON BUILT-IN FUNCTIONS


                  Python includes the following built-in functions to manipulate strings:
                      len( ): The len( ) function calculates and returns the length of a string supplied as an argument.
                      Syntax of using len( ) function is:
                          len(string_name)

                      lower( ): 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 letter in capital.
                      Syntax of using capitalize( ) function is:
                          string_name.capitalize( )

                      count(): The count() function returns the number of times substring occurs in the given string.
                      Syntax of using count() function is:
                          str.count(substring, start, end)

                      replace(): The replace() function replaces all occurrences of a specified part of the string with
                      another part.
                      Syntax of using replace() function is:

                          string_name.replace (old_substring, new_substring, count)
                      strip():  The strip() function removes any leading and trailing whitespace (or  specified
                      characters) from the string.
                      Syntax of using strip() function is:

                          string_name.strip()
                      lstrip(): The lstrip() function removes any leading whitespace (or specified characters) from
                      the string.

                      Syntax of using lstrip() function is:
                          string_name.lstrip()





                   70     Touchpad MODULAR (Version 2.0)
   67   68   69   70   71   72   73   74   75   76   77