Conditions may contain more than one comparison at once. You can have a condition that checks whether a value is greater than another and lesser than yet another all at once.
![image](https://community.edyoda.com/uploads/default/original/2X/4/4da7f991b3558ad02d96d54acc204493cc33550e.png)
Q . Write a python program which depicts the chain comparison?
Note : You can take inputs of your choice.
1 Like
Condition 1
num1 = 8
num2 = 9
num3 = 10
if num1 < num2 < num3 :
print(num1, "<" , num2, "<" , num3 )
else :
print("The number are not in increasing order : ")
Condition 2
num1 = 10
num2 = 9
num3 = 8
if num1 > num2 > num3 :
print(num3, "is greater than " , num2 ,"\n So On ", num2 , " is greater than", num1 )
else:
print("Chain Comparison is not True")
Condition 3
num1 = 6
num2 = 9
num3 = 6
if num1 < num2 > num3 :
print("Num1 is smaller than num2 and num2 is smaller than num3")
else:
print("Chain Comparison is not True ")
1 Like
no1 = float(input('Enter your Number: '))
no2 = float(input('Enter your next Number: '))
no3 = float(input('Enter your next Number: '))
if no1 < no2 < no3 :
print('Numbers are entered in an Increasing order')
else :
print('Numbers are not enterd in increasing order')
# 2)
no1 = float(input('Enter your Greatest number : '))
no2 = float(input('Enter your reference Number: '))
no3 = float(input('Enter your reference Number: '))
if no2 < no1 > no3 :
print('Number you entered is the greatest number')
else :
print('Number you entered is not the greatest number')
1 Like