Page 35 - 2501_KVS_C-8
P. 35

Keyword: A Keyword is a pre-defined reserved name in a programming language like
                     python  which  has  fixed  working  or  function.  Its  function  cannot  be  changed  at  all
                     during programming. Some of the examples are if, else, in, for, etc.

                 2.3 OPERATORS (ARITHMETIC & RELATIONAL)

                     Operator:  Operators  are  special  symbols  that  are  used  to  perform  operations  on
                     operands. The values that an operator works on are called operands.

                     Expression: An expression is combination of operator and operands.
                     Arithmetic  Operator:  Arithmetic  operator  is  used  to  apply  basic  mathematical
                     operations  like  addition,  subtraction,  multiplication,  division,  etc.  These  operators
                     require two operands to operate. Following are some of the binary operator:


                 Name of Operator Symbol used Purpose                                       Example
                 Addition               +              Summation of Numbers                 x = 5 + 6 will give 11

                 Subtraction            -              Subtraction of Numbers                x = 9 - 5 will give 4

                 Multiplication         *              Product of Numbers                   x = 3 * 4 will give 12

                 Division               /              Division of Numbers                  x = 9 / 3 will give 3.0
                 Modulus                %              Return remainder                     x = 5 % 2 will give 1

                 Floor Division         //             Divides and truncates the            x = 7 // 2 will give 3
                                                       fractional part from result

                 Exponentiation         **             Return base raised to power          x = 3 ** 3 will give 27
                                                       exponent


                     Relational  Operator:  Relational  operators  are  used  to  describe  the  relationship
                     between values or operands. In python, you will use six relational operators to compare
                     values. These operators are also known as comparison operators.

                 The six relational operators are:

                                     Operator                          Example         Result
                                                                       if a=9, b=5

                                     >      Greater than               a>b             True
                                     <      Less than                  a<b             False
                                     >=    Greater than or equal to a>=b               True
                                     <=    Less than or equal to       a<=b            False

                                     ==    Equal to                    a==b            False
                                     !=    Not equal to                a!=b            True

                 You can conclude that the result of a comparison operator will always be either True or
                 False.



                                                                    Recap of Python of Class VII                    33
   30   31   32   33   34   35   36   37   38   39   40