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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 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 Best Website and Software Company in Allahabad