Programming Examples

Python program to print the frequency of digits present in given number


Write a python program to accept an integer number and print the frequency of each digit present in the number .

Sample:

Input : 3255435

Output: 

Digit Frequency

2 1

3 2

4 1

5 3

Solution

number=int(input("Enter any Number"))
print("Digit\tFrequency")
for i in range(0,10):
    count=0;
    temp=number;
    while temp>0:
        digit=temp%10
        if digit==i:
            count=count+1
        temp=temp//10;
    if count>0:
        print(i,"\t",count)
▶ RUN

Output/ Explanation:

Enter any Number3148472

Digit Frequency

1 1

2 1

3 1

4 2

7 1

8 1

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad