Python – Relational Operators

Relational operators:

  • Operators are > , < , >= , <= , == , !=
  • These operators validate the relation among operands and return a boolean value.
  • If relation is valid returns True else False
print(“Relational operations”)
print(“5>3 :”, 5>3)
print(“5==3 :”, 5==3)
print(“5<3 :”, 5<3)
print(“5!=3 :”, 5!=3)
print(“5>=3 :”, 5>=3)
print(“5<=3 :”, 5<=3)

Condition to check the number is Positive

N>=0

Condition to check the number is equal to zero

N==0

Condition to check the 2 numbers equal

A==B

Condition to check First Num greater than Second Num

A>B

Square of First Number not equals to Second Number

A!=B

Condition to check sum of 2 numbers equal to 10

A+B==10

Condition to check the number divisible by 3

N%3==0

Condition to check the number is Even

N%2==0

Condition to check the last digit of Number is 0

N%10==0

Condition to check the last digit of Number is Even

N%10%2==0

Condition to check the multiplication of 2 numbers not equals to 3rd number

A*B==C

Condition to check average of 4 subjects marks greater than 60

(A+B+C+D)/4>60

Condition to check the sum of First 2 numbers equals to last digit of 3rd number

A+B == C%10

Condition to check average of 3 numbers equals to first number

(A+B+C)/3==A

Condition to check the given quantity of fruits exactly in dozens

A%12==0

Condition to person is eligible for Vote

AGE>=18
Scroll to Top