Find maximum in two number by R4R Team

Example -

let we have a two number
so we can easily judge that 56 is maximum in both of them

Program to find out the maximum number out of two-

a=int(input("Enter first numbern"))
b=int(input("Enter second numbern"))

#fisrt way
if a>b:
print(max(b)+" is maximum")

#second way
print(str(max(a,b))+" is maximum")

output -

Enter first number
Enter second number
6 is maximum
6 is maximum

program to do this in one line -

print(str(max(list(map(int,input("Enter number in list").split()))))+" is maximum")

output -

Enter two value
56 78
78 is maximum

In this program, we done this in one line and that's the beauty of the python programming language. How it works ? Firstly we take string input then with the use of split() we separate the number then using map we type cast the string number to integer number then list is created then max() function is find the maximum out of them and print() function display that.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!