Page 251 - COPA VOL II of II - TP -Punjabi
P. 251

ਟਾਸਕ 2 : ਤੁਲਨਾ ਆਪ੍ੇਟ੍
            1   ਤੁਲਨਾ ਆਪਰੇਟਰ ਹੇਠਾਂ ਦਭੱਤੇ ਅਨੁਸਾਰ:

            # Examples of Relational Operators                    print(a > b)
            a = 13                                                # a < b is True
            b = 33                                                print(a < b)
            # a > b is False                                      # a == b is False

                                                                  print(a == b)
                                                                  # a != b is True
             print(a != b)                                        True
             # a >= b is False                                    False

             print(a >= b)                                        True
             # a <= b is True                                     False
             print(a <= b)                                        True
             Output:
             False

            ਟਾਸਕ 3 : ਲਾਜ਼ੀਕਲ ਓਪ੍ੇਟ੍
            ਹੇਠ ਲਭਖੇ ਅਨੁਸਾਰ 1 ਲਾਜ਼ੀਕਲ ਆਪਰੇਟਰ:

            # Examples of Logical Operator                        print(a or b)
                                                                  # Print not a is False
            a = True                                              print(not a)
            b = False                                             output:
            # Print a and b is False                              False
            print(a and b)                                        True

            # Print a or b is True                                False

            ਟਾਸਕ 4 : ਬਭੱਟਵਾਈਜ਼ ਓਪ੍ੇਟ੍1 ਬਭੱਟਵਾਈਜ਼ ਆਪ੍ੇਟ੍ ਹੇਠਾਂ ਦਭੱਤੇ ਅਨੁਸਾ੍
            # Examples of Bitwise operators                       # print bitwise right shift operation
                                                                  print(a >> 2)
            a = 10                                                # print bitwise left shift operation
            b = 4                                                 print(a << 2)

            # Print bitwise AND operation                         Output:
            print(a & b)                                          0
            # Print bitwise OR operation                          14
            print(a | b)                                          -11

            # Print bitwise NOT operation                         14
            print(~a)                                             2
            # print bitwise XOR operation                         40
            print(a ^ b)










                                      IT & ITES - COPA - (NSQF ਸੋਧੇ - 2022) - ਅਿਭਆਸ 1.39.05                    237
   246   247   248   249   250   251   252   253   254   255   256