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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz