find minimum out of three number in python by R4R Team

Example -

let we have a two number
so we can easily judge that 23 is minimum in all of them.

Program to find out the minimum number out of three-

a=int(input("Enter first numbern"))
b=int(input("Enter second numbern"))
c=int(input("Enter third numbern"))
#first way
if b>a and c>a:
print(str(a)+" is minimum")
elif c>b:
print(str(b)+" is minimum")
print(str(c)+" is minimum")

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


Enter first number
Enter second number
Enter third number
2 is minimum
2 is maximum

program to do this in a single line -

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

output -

Enter three value
2 3 4
2 is minimum

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 seprate the number then using map() we type cast the string number to integer number then list is created then min() function is find the minimum 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!