Page 62 - Modular v1.1 Pyhton
P. 62

06                  STRING HANDLING IN



                                                                                                      PYTHON















                          Your Aim

                          to learn about:
                                  String                                   Traversing a String
                                   String Operators                         Python Built-in Functions
                                     Some More Programs




                  Sequence is an ordered collection of items,  which are indexed by positive integers. It is  a

                  combination of mutable (whose value may change)  and immutable  (whose value may not
                  change) data types. There are three types of sequences available in Python:
                  1.  String: Sequence of characters enclosed or surrounded by single (' ') or double (" ") quotes.

                  2.  List: Sequence of multiple values in an ordered sequence.

                  3.  Tuple: Sequence of values enclosed in parentheses and its indices start with 0
                  In this chapter, you will learn about string, how to create, traverse a string and its functions,

                  operators.

                      STRING

                  A sequence of characters which is enclosed or surrounded by single (' ') or double (" ") quotes is
                  known as a string. The sequence may include letters, numbers, special characters or a backslash.
                  Python treats single quotes the same as double quotes.

                  Example of a string: Games = 'Cricket Basketball Baseball'

                  Creating Strings

                  Creating a string is like assigning a value to a variable.

                  Program 1: To create a string.










                   60     Touchpad MODULAR (Version 1.0)
   57   58   59   60   61   62   63   64   65   66   67