Page 66 - tp_Modula_v2.0
P. 66

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.

                      Program1.py
                   File  Edit  Format   Run   Options  Window    Help

                   str = "Orange Education"
                   print(str)




                   64     Touchpad MODULAR (Version 2.0)
   61   62   63   64   65   66   67   68   69   70   71