Programming Examples

Python program to find the difference between greatest and smallest digits presents in the number


Write a python program to accept an integer number to find out and print the difference between greatest and smallest digits presents in the number .

Solution

number=int(input("Enter any Number"))
min=9
max=0
while(number>0):
    digit=number%10;
    if(min>digit):
        min=digit;
    if(max<digit):
        max=digit;
    number=number//10;
diff=max-min
print("Greatest  Digit : ",max);
print("Smallest  Digit : ",min);
print("Difference  Between Greatest and Smallest  Digit : ",diff);  
Output

Enter any Number34528

Greatest  Digit :  8

Smallest  Digit :  2

Difference  Between Greatest and Smallest  Digit :  6

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad