Page 90 -
P. 90

textual data











                                These are some of the many built-in string methods that come with
                                Python. Match each method to what it does. We’ve done one for you
                                already.

                      Method                                 What the method does


                      text.endswith(".jpg")                  Return a copy of the string with all occurrences of one
                                                             substring replaced by another.

                      text.upper():
                                                             Return a copy of the string converted to lowercase.


                      text.lower():                          Return the value True if the string has the given
                                                             substring at the beginning.

                      text.replace("tomorrow", "Tuesday"):   Return the value True if the string has the given
                                                             substring at the end.


                      text.strip():                          Return the first index value when the given substring is
                                                             found.

                      text.find("python"):                   Return a copy of the string with the leading and
                                                             trailing whitespace removed.

                      text.startswith("<HTML>")
                                                             Return a copy of the string converted to uppercase.









                                               Which of the above methods do you need to use to locate the
                                               price substring within the Beans’R’Us web page?








                                                                                        you are here 4    55
   85   86   87   88   89   90   91   92   93   94   95