Programming Examples
Python program to input three unequal numbers and display the greatest and the smallest number
Write a Python code to input three unequal numbers. Display the greatest and the smallest numbers.
Sample Input:28,98,56
Sample Output: Greatest Number:98
Smallest Number:28
Solution:
max=min=0
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
c=int(input("Enter third number:"))
if((a>b) and (a>c)):
max=a
if((b>a) and (b>c)):
max=b
if((c>a) and (c>b)):
max=c
if((a<b) and (a<c)):
min=a
if((b<a) and (b<c)):
min=b
if((c<a) and (c<b)):
min=c
print("Greatest Number :",max)
print("Smallest Number :",min)
Output/ Explanation:
Enter first number:5
Enter second number:9
Enter third number:4
Greatest Number : 9
Smallest Number : 4