Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 141 - logicode 2609 C6
P. 141

    Single-line Comment
                     Python uses the hash (#) symbol for writing single-line comments.

                     Example:

                     Program:  #printing a string
                                print("Hello TrackPad")
                     Output: Hello TrackPad

                     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: #print three names

                                print("Roli")
                                print("Proloy")

                                print("Devansh")

                     Output: Roli Proloy Devansh
                     However, the text written inside triple quotes (''' or " " ") is also considered a comment. You can
                     use the triple quotes to write multiline comments. For example:
                     '''
                     This is a multiple-line comment that spans two lines in Python.

                     '''

                               OPERATORS IN PYTHON

                     Operators  are the special  symbols that  are used  to  perform
                     computations. The values which the operators use to get the output               20 + 10
                     are called operands.
                                                                                                  Operand      Operator
                       (+) Addition operator: It is an arithmetic operator which is used to
                       perform addition. Arithmetic operators perform arithmetic operations between two operands.
                       Some more arithmetic operators are:
                       (–) Subtraction operator: It subtracts the right-hand operand from the left-hand operand.

                       (*) Multiplication operator: It multiplies values on either side of the operator.
                       (/) Division operator: It divides the left-hand operand by the right-hand operand.

                        (%) Modulus operator: It divides the left-hand operand by the right-hand operand and returns
                       the remainder.

                       (**) Exponentiation operator: It performs exponential (power) calculation on operands.

                       (//) Floor or Integer division operator: It divides and cuts the fractional part from the result.

                                                                                                 Introduction to Python  139

| 136 137 138 139 140 141 142 143 144 145 146 |