📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 53question

PYTHON – VARIABLES AND OPERATORS · Part 7

Chapter 2: 3 · COMPUTER SCIENCE

a==b = False The a > b = False The a < b = True The a >= b = False The a <= b = False The a != b = True Coding . To test Relational Operators: (iii) Logical operators In python, Logical operators are used to perform logical operations on the given relational expressions. There are three logical operators they are and, or and not . 12th Computer Chapter - - Python – Variables and Operators Operator Example Result Assume a = and b = , Evaluate the following Logical expressions or >>> a>b or a==b True and >>> a>b and a==b False not >>> not a>b False i.e.

Not True Program . To test Logical Operators: Example – Code Example - Result #Demo Program to test Logical Operators a=int (input("Enter a Value for A:")) b=int (input("Enter a Value for B:")) print ("A = ",a, " and b = ",b) print ("The a > b or a == b = ",a>b or a==b) print ("The a > b and a == b = ",a>b and a==b) print ("The not a > b = ",not a>b) #Program End Enter a Value for A: Enter a Value for B: A = and b = The a > b or a == b = True The a > b and a == b = False The not a > b = False (iv) Assignment operators In Python, = is a simple assignment operator to assign values to variable. Let a = and b = assigns the value to a and to b these two assignment statement can also be given as a,b= , that assigns the value and on the right to the variables a and b respectively. There are various compound operators in Python like +=, -=, *=, /=, %=, **= and //= are also available.

Operator Description Example Assume x= = Assigns right side operands to left variable >>> x= >>> b=”Computer” += Added and assign back the result to left operand >>> x+= # x=x+

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →