Page 302 - Artificial Intellegence_v2.0_Class_9
P. 302

Literals
        It is defined as any data stored in a variable. This data can be String literals are enclosed in single or double
        quotes. For example,
                    "Hello"
                    'Python'

           • Numeric literals: They can be integer, float or complex. For example,
                    14
                    20.5
                    2+5j

           • Boolean literals: They can be True or False. For example,
                    True

           • Special literals: Only None is a special literal. It means something not yet created.

        Punctuators
        Punctuators are special symbols used in Python to organise statements and expressions. Most commonly used
        punctuators in Python are:

        ' " # \ () {} [] @ , : . =

        Operators

        Operators are special symbols used to perform mathematical, logical and relational operations on variables and
        values. The variables or values on which the operators work are called operands. Some commonly used operators
        in Python are arithmetic operators, relational operators, logical operators and augmented assignment operators.


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

        Following arithmetic operators are provided by Python:

                Name          Symbol                 Purpose                   Example            Output
                                                                                 2 + 4               6

           Addition              +       Adds two values.                       2.0 + 4             6.0
                                                                               "hi" + "all"        "hiall"

                                         Subtracts  second  value  form  the     6 – 2               4
           Subtraction           –
                                         first value.                            6.0 – 2            4.0
                                                                                  2 * 3              6

           Multiplication         *      Multiplies two values.                  1.5 * 2            3.0
                                                                                "Hi" * 3           HiHiHi

                                                                                  4 / 2             2.0
                                                                                 6.0 / 2            3.0
           Division               /      Divides two values.
                                                                                 6 / 2.0            3.0
                                                                                 11 / 2             5.5

              300     Touchpad Artificial Intelligence (Ver. 2.0)-IX
   297   298   299   300   301   302   303   304   305   306   307