Page 109 - TP_Pluse_V2.2_Class_6
P. 109

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 five names                            Rachna
                                                                    Sambhav
                       print("Hello World")
                                                                    Akshat
                       print("Rachna")
                                                                    Tushar
                       print("Sambhav")

                       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
                                     Multiline              OR          Multiline

                                     Comment'''                         Comment"""


                        OPERATORS

                 In Python,  operators can  be  defined  as  special  symbols  which perform arithmetic  and  logical

                 computation. 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.
                 Python divides the operators in the following categories.

                      Arithmetic Operators

                 Arithmetic operators perform arithmetic operations between two operands.


                                                                                        Introduction to Programming  107
   104   105   106   107   108   109   110   111   112   113   114