Find the Greatest of Two Numbers in Python
Login/Signup to comment
8 comments on “Find the Greatest of Two Numbers in Python”
×


30+ Companies are Hiring
Get Hiring Updates right in your inbox from PrepInsta
Login/Signup to comment
Get Hiring Updates right in your inbox from PrepInsta
n1 = int(input(“enter the first values:”))
n2 = int(input(“enter the second values:”))
num = max(n1,n2)
print(num)
n1 = int(input(“enter the first values:”))
n2 = int(input(“enter the second values:”))
if n1 > n2:
print(“the greatest number is:”, n1)
else:
print(“the greatest number is:”, n2)
num1, num2, num3 = map(int, input(“Enter The Number”).split())
if num1 > num2:
if num1 > num3:
print(num1)
else:
print(num3)
else:
if num2 > num3:
print(num2)
else:
print(num3)
#Whithout nested if else
if num1 >= num2 and num1 >= num3:
print(num1)
elif num2 >= num3 and num2 >= num1:
print(num2)
else:
print(num3)
#with Max function
print(max(num1,num2,num3))
N1 = int(input(“Enter the first number : “))
N2 = int(input(“Enter the second number : “))
diff = N1 – N2
if diff 0:
print(f”{N1} is greater”)
elif diff == 0:
print(“Both the numbers are same”)
not included the equality condition
n,m=map(int,input().split())
if n>=m and n<m:
print("First number",n)
else:
print("Secound Number",m)
n1 = int(input(“Enter the number 1 : “))
n2 = int(input(“Enter the number 2 : “))
if n1 < n2:
print(f"{n2} is Grater")
# elif n1 == n2:
# print(f"{n1} and {n2} are equal")
else:
print(f"{n1} is grater ")
a=int(input(“Enter the First number: “))
b=int(input(“Enter the Last number: “))
if(a>b):
print(“The greatest number is “,a)
elif(b>a):
print(“The greatest number is “,b)
else:
print(“The numbers are equal”)
In this program there is no case for when numbers are equal here the program for that case too.