Logical Operator in Python

Logical Operator in Python



OperatorDescription
or
If any one of the operand is true, then the condition becomes true.
and
If both the operands are true, then the condition becomes true.
not
Reverses the state of operand/condition.

Example  To test Logical Operators:


#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


Example Result:


Enter a Value for A:50

Enter a Value for B:40

A = 50 and b = 40

The a > b or a == b = True

The a > b and a == b = False

The not a > b = False

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad