Page 122 - Computer Genius Class 08
P. 122

Description:
                  In  the  above  program,  we  assigned  values  to  different  variables  and  then  performed  different
                  arithmetic operations on it.

                  Example 7: Comparison operators in Python.

                  Program:
                    x = 10
                    y = 12
                    print('x>y=', x>y)
                    print('x<y=', x<y)
                    print('x==y=', x==y)
                    print('x!=y=', x!=y)
                    print('x>=y=', x>=y)
                    print('x<=y=', x<=y)


                  Output:
                    x > y = False
                    x < y = True
                    x == y = False
                    x != y = True
                    x >= y = False
                    x <=y = True

                  Description:

                  In  the  above  program,  we  assigned  values  to  different  variables  and  then  performed  different
                  arithmetic operations on it.
                  Example 8: Logical Operators in Python.

                  Program:
                    x = True
                    y = False

                    print('x and y is', x and y)
                    print('x or y is', x or y)
                    print('not x l x', not x )

                  Output:
                    x and y is False
                    x or y is True
                    not x is False

                  Description:
                  In the above program, we have used two variables and then performed various logical operations on
                  it. Compared variable values logically.





                      120    Computer Genius-VIII
   117   118   119   120   121   122   123   124   125   126   127