Page 103 - TP_Play_V2.1_class6
P. 103

Single-line Comment

                 In case, a user wants to specify a single line comment, then comment must start with the symbol
                 #.

                 Example:

                  Program:                                        Output:

                  # printing a string                             Hello World

                  print("Hello world")

                 Multiple-line Comment

                 Python does not have a syntax for multiline comments. To add a multiple line comment, you
                 could insert a # for each line.

                 Example:

                  Program :                                     Output :


                  # printing a string                           Hello World

                  # print four names                            Reeta

                  print("Hello World")                          Chirag


                  print("Reeta")                                Akshat

                  print("Chirag")                               Tushar

                  print("Akshat")

                  print("Tushar")



                 However, the text written inside triple quotes (''' or ''"") is also considered as comment. You can
                 use the triple quotes to write multiline comments. For example:

                                  '''This is                         """This is
                                                           OR
                                     Multiline                          Multiline
                                     Comment'''                         Comment"""

                    OPERATORS

                 In Python, operators can be defined as special symbols which perform arithmetic and logical
                 computations. The values which the operators use to get the output are called operands.
                 For example, in the expression 10–5, 10 and 5 are operands and the minus (–) sign is the
                 operator.

                 Let us learn about various Python operators.


                                                                        Introduction to Programming Python       101
   98   99   100   101   102   103   104   105   106   107   108