Menu Close

Relational operator Question

Chef has started programming. He is reading about relational operators. Relational operators are operators which check relationship between two values. Given two numerical values A nad B you need to help chef in finding hte relationship between them. I.e First one is greater than second one or first one is less than second one or they both are equal. Using T number of cases and using while loop and if/else condition.

T=int(input("Enter the no: of cases: "))
n=0
while(T!=0):
	A=int(input("Enter the first number: "))
	B=int(input("Enter the second number: "))
	n+=1
	if A>B:
		print("Case {}'s relational operator: >".format(n))
	elif A<B:
		print("Case {}'s relational operator: <".format(n))
	else:
		print("Case {}'s relational operator: =".format(n))
	T-=1
	print()

Output:

Enter the no: of cases: 3

Enter the first number: 2
Enter the second number: 3
Case 1’s relational operator: <

Enter the first number: 2
Enter the second number: 3
Case 2’s relational operator: <

Enter the first number: 1
Enter the second number: 1
Case 3’s relational operator: =


Exec. on linux

Morae!Q!