Compare Three Numbers In Simple Way
First way :-
Let assume three no's num1 , num2 , num3 which we want to compare.
So we want a technique which we can learn faster and we can remember easily and simple .
----------------------------------------------------------------------------------------------------------------while 1:
print '---------------------------------------------
num1=float(input("Enter 1 no to check > "))
num2=float(input("Enter 2 no to check > "))
num3=float(input("Enter 3 no to check > "))
if num1>num2 and num1>num3:
larger=num1
elif num2>num3:
larger=num2
else:
larger=num3
print ' larger one %f' %larger
-------------------------------------------------------------------------------------------------------
Second way :-
Let assume three no's num1 , num2 , num3 which we want to compare.
This is mostly used by programmer .
------------------------------------------------------------------------------------------------------
while 1:
num1=float(input("Enter 1 no to check > "))
num2=float(input("Enter 2 no to check > "))
num3=float(input("Enter 3 no to check > "))
if num1>=num2 and num1>=num3:
larger=num1
elif num2>=num1 and num2>=num3:
larger=num2
else:
larger=num3
print ' larger number is %f' %larger
num2=float(input("Enter 2 no to check > "))
num3=float(input("Enter 3 no to check > "))
if num1>=num2 and num1>=num3:
larger=num1
elif num2>=num1 and num2>=num3:
larger=num2
else:
larger=num3
print ' larger number is %f' %larger
No comments:
Post a Comment