Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 140 - CodePilot V5.0 C6
P. 140

    By enclosing the text within triple quotes (''' or """):

                      '''                                                             """
                      This is a                                                       This is a
                      multiline comment                            OR                 multiline comment
                      '''                                                             """
                       Program 2     To demonstrate how to use both single-line and multiline comments.

                          Program2.py
                       File  Edit  Format   Run    Options   Window    Help
                                                                                           Write a Python program to

                       #This is a single line comment.                                      display comments about
                                                                                          your best friend in multi line
                       print("Orange Education")
                                                                                         comments and print his name
                       '''
                                                                                           using the print statement.
                       This is a
                       multiline comment
                       using triple quotes                                               Output
                       '''
                                                                                       Orange Education
                       print("I love Python")                                          I love Python

                             OPERATORS

                      Operators are symbols that perform mathematical, logical or relational operations on values
                      called operands. For example, in 15 + 7, 15 and 7 are operands and + is the operator. Python has
                      different categories of operators.

                      ARITHMETIC OPERATORS

                      Arithmetic  operators perform arithmetic  operations  between  two operands. The  arithmetic
                      operators are defined in the following table:

                                                                                                    Example
                       Operator         Name                        Description                                  Output
                                                                                                  (x = 5, y = 3)
                           +       Addition          Adds values on either side of the operator.      x + y          8
                           -       Subtraction       Subtracts the right operand from the left        x - y          2
                                                     operand.
                           *       Multiplication    Multiplies  values on either  side  of the       x * y         15
                                                     operator.
                            /      Division          Divides the left operand by the right and        x / y       1.6667
                                                     returns a float.
                           %       Modulus           Divides the left operand by the right and        x % y          2
                                                     returns the remainder.

                       138
                            CodePilot (V5.0)-VI

         5

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