Relational operators:
- Operators are > , < , >= , <= , == , !=
- These operators validate the relation among operands and return a boolean value.
- If relation is valid returns True else False
Program to understand Relational operators:
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) |
If-else Conditional Statement:

Check the Number is Zero or Not
n = int(input(“Enter number : “)) if(n==0): print(“Number equals to zero”) else: print(“Number is not zero”) |
Check the Number is Positive or Not
n = int(input(“Enter number : “)) if(n>=0): print(“Positive Number”) else: print(“Negative Number”) |
Check the 2 numbers equal or not
n1 = int(input(“Enter First num : “)) n2 = int(input(“Enter Second num : “)) if(n1==n2): print(“Equal numbers”) else: print(“Not equal Numbers”) |
Check the first number greater than second number or not
n1 = int(input(“Enter First num : “)) n2 = int(input(“Enter Second num : “)) if(n1>n2): print(“First Number is big”) else: print(“Second Number is big”) |
Check the person eligible for vote or not
age = int(input(“Enter age : “)) if(age>=18): print(“Eligible for vote”) else: print(“Not eligible for vote”) |
Check the number is divisible by 7 or not
num = int(input(“Enter number : “)) if(num%7==0): print(“Divisible by 7”) else: print(“Not divisible by 7”) |
Check the number is even or not
num = int(input(“Enter number : “)) if(num%2==0): print(“Even Number”) else: print(“Not Even”) |
Check the last digit of number is zero or not
num = int(input(“Enter number : “)) if(num%10==0): print(“Last digit is zero”) else: print(“Last digit is not zero”) |
Check the sum of 2 numbers equal to 10 or not
n1 = int(input(“Enter First number : “)) n2 = int(input(“Enter Second number : “)) if(n1+n2==10): print(“Equal to 10”) else: print(“Not equal to 10”) |
Check last digits of given 2 numbers equal or not
n1 = int(input(“Enter First number : “)) n2 = int(input(“Enter Second number : “)) if(n1%10 == n2%10): print(“Equal”) else: print(“Not equal”) |
Check the average of 3 numbers greater than 60 or not
print(“Enter 3 numbers :”) n1 = int(input()) n2 = int(input()) n3 = int(input()) if((n1+n2+n3)/3 > 60): print(“avg Greater than 60”) else: print(“Not”) |
Check the last digit of number is divisible by 3 or not
n = int(input(“Enter num : “)) if((n%10)%3==0): print(“Last digit divisible by 3”) else: print(“Not divisible”) |