Page 87 - ThinkGPT_V2.1_C7_Flipbook
P. 87

print("Rachna")                                  Akshat
                   print("Sambhav")                                 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 multi-line comments. For example:

                                  '''This is                         """This is
                                     Multi-Line           OR            Multi-Line
                                     Comment'''                         Comment"""
                 Operators

                 In  Python,  operators  can  be  defined  as  special  symbols  which  perform  arithmetic  and  logical
                 computation. The values that 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 an operator.

                 Python divides the operators in the following categories:
                 Arithmetic Operators

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

                                                                                            Example
                  Operator    Name              Description                                 (x=7 and     Output
                                                                                            y=3)

                                                                                                              10
                      +       Addition          Adds values on either side of the operator.    x + y
                                                                                                              4
                      –       Subtraction       Subtracts  right  hand  operand  from  left    x – y
                                                hand operand.
                                                                                                              21
                      *       Multiplication    Multiplies  values  on  either  side  of  the   x * y
                                                operator.

                                                                                                           2.33333
                      /       Division          Divides  left  hand  operand  by  right  hand   x / y
                                                operand.

                                                                                                              1
                      %       Modulus           Divides  left  hand  operand  by  right  hand   x % y
                                                operand and returns remainder.
                                                                                                             343
                      **      Exponentiation    Performs exponential (power) calculation       x ** y
                                                on operands.
                                                                                                              2
                      //      Floor or Integer  Divides and cuts the fractional part from      x // y
                              division          the result.





                                                                                            More on Python    85
   82   83   84   85   86   87   88   89   90   91   92