Page 248 - AI Computer 10
P. 248

•  Lists: A list in Python is a collection of comma separated values or items within square brackets. You can
                    change or modify the values in the list i.e. it is mutable or changeable. For example:















                 •  Tuples: A tuple is a list of comma separated values. You cannot change or modify the value of a tuple
                    whenever required, i.e, it is immutable. It is not necessary that all the available elements in a list are
                    of the same data type. The comma separated values must be enclosed in parenthesis (optional, not
                    necessary). For example:









            Operators

            Operators are some special symbols that trigger the operation on data. Operators are used to carry out some
            operations on operands.

            Arithmetic Operators
            Arithmetic operators are used to perform mathematical operations on variables and values. Arithmetic operators
            used in Python are:

                 Name             Symbol                       Purpose                      Example          Output
                Addition             +                     Adds two values                   16+14             30
               Subtraction           -           Subtracts second values from the first
                                                                value                        16-14              2
             Multiplication          *                   Multiplies two values               10*20            200
                Division             /                    Divides two values                  9/3               3
                Modulus              %            Fnds the remainder after division of
                                                       one number by another.               100%99              1
             Exponentiation          **         Raises the first number to the power of      2**5              32
                                                             the second.
              Floor Division         //            Divides the first number with the         17//3              5
                                                second and returns the whole number
                                                   adjusted left to the number line.

            Comparison or Relational Operators

            Relational operators help us to determine the relationship between two operands. These operators are also
            known as comparison operators because they compare the value of variables and determine the relationship
            based on comparison. If the comparison is true, the relational expression results in the Boolean value True and


                114
                114
   243   244   245   246   247   248   249   250   251   252   253