Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 135 - 2609_Logicode
P. 135

    Program3.py
                      File  Edit  Format   Run    Options   Window    Help

                      print('''A sequence of
                      characters are called a string.
                      Strings are used by programming
                      languages to manipulate text such
                      as words and sentences.''')

                     You will get the following output:

                         Output

                      A sequence of
                      characters are called a string.
                      Strings are used by programming
                      languages to manipulate text such
                      as words and sentences.

                     USING ESCAPE SEQUENCES WITH STRING

                     Escape sequences or characters are used to represent special characters that cannot be directly
                     inserted into a string.

                     An escape sequence is a sequence of characters that does not represent itself when used inside
                     a character  or string. It is  typically  used  to  specify  actions  such as carriage  returns and tab
                     movements. The backslash (\) is a special character and is also known as the escape character in
                     Python. To include special characters like quotes within a string, you need to escape them with a
                     backlash. It is used to represent white space characters, for example, '\t' for tab, '\n' for new line,
                     and '\r' is for carriage return.

                     Program 4: To demonstrate the use of escape character

                         Program4.py

                      File  Edit  Format   Run    Options  Window     Help

                      print('I love programming in \n Python')

                     You will get the following output:
                         Output

                      I love programming in
                       Python

                                                                                               String and List in Python  133

| 130 131 132 133 134 135 136 137 138 139 140 |