Page 105 - KEC Khaitan C8.5 Flipbook
P. 105

Output
                                         Output: Enter the First Number: 12
                                         Enter the Second Number: 45
                                         Enter the Third Number: 23
                                         Second number is the greatest number.







                           STRING

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


                 Program 6: To print a string
                       Program6.py

                    File  Edit  Format   Run   Options   Window    Help

                    str = "This is Shweta's pen."                                 Output
                    print(str)                                                  This is Shweta's pen.



                 CREATING A SINGLE-LINE STRINGS
                 Single-line strings can be created by enclosing characters inside single or double quotes. It is like

                 assigning a value to a variable.
                 Program 7: To create a single-line string

                      Program7.py

                   File  Edit  Format   Run   Options   Window    Help
                   first_name = 'Aadya'
                   print (first_name)
                   last_name = 'Kaushal'
                                                                                    Output
                   print (last_name)
                   str = ' '                                                     Aadya
                   print (str)                                                   Kaushal




                 CREATING MULTILINE STRINGS

                 A multiline string in Python begins and ends with either three single quotes or three double
                 quotes. Any quotes, tabs, or newlines in between the “triple quotes” are considered part of the
                 string.







                                                                                        Control Structures in Python  103
   100   101   102   103   104   105   106   107   108   109   110