Page 63 - Touhpad Ai
P. 63

Bitwise NOT: -11
                   Bitwise Left Shift: 40
                   Bitwise Right Shift: 2

                     AI REBOOT

                    Answer the following questions:

                       1.  Name any two keywords in Python.

                       2.  What is a token?


                       3.  Which operator is used to represent exponent in Python?

                       4.  Which operator returns the quotient after division as an integer?





                 Membership Operators
                 Membership operators are used to test whether a value is present in a sequence (such as a string, list, tuple, etc.) or not.


                                     Operator                         Description

                                        in      Returns True if a specific value is present in a sequence
                                      not in    Returns True if a specific value is not present in a sequence

                    Program 10: To demonstrate the use of membership operators

                   # Uses of Membership Operators

                   # in operator
                   my_list = [1, 2, 3, 4, 5]
                   print("Is 3 in the list?", 3 in my_list)

                   # not in operator
                   print("Is 6 not in the list?", 6 not in my_list)
                   Output:

                   Is 3 in the list? True
                   Is 6 not in the list? True
                 Identity Operators
                 Identity operators are used to compare the memory locations of two objects rather than their values.


                                  Operator                            Description

                                     is      Returns True if both variables are the same object in the memory.

                                    is not   Returns True if both variables are not the same object in the memory.




                                                                                 Basic Concepts of Artificial Intelligence  61
   58   59   60   61   62   63   64   65   66   67   68